Пример #1
0
    public static IAppBuilder UseDigestAuthentication(this IAppBuilder app, DigestAuthenticationOptions options)
    {
        app.Use(typeof(DigestAuthenticationMiddleware), options);

        // Line added
        app.UseStageMarker(PipelineStage.Authenticate);

        return(app);
    }
        public void ConfigureAuth(IAppBuilder)
        {
            var digestOptions = new DigestAuthenticationOptions()
            {
                Realm = "magical",
                GenerateNonceBytes = () =>
                {
                    byte[] bytes = new byte[16];
                    using (var provider = new RNGCryptoServiceProvider())
                    {
                        provider.GetBytes(bytes);
                    }

                    return(bytes);
                }
            };

            app.UseDigestAuthentication(digestOptions);
        }
    public void Configuration(IAppBuilder app)
    {
        var digestOptions = new DigestAuthenticationOptions()
        {
            Realm = "magical",
            GenerateNonceBytes = () =>
            {
                byte[] bytes = new byte[16];
                using (var provider = new RNGCryptoServiceProvider())
                {
                    provider.GetBytes(bytes);
                }

                return(bytes);
            }
        };

        app.UseDigestAuthentication(digestOptions);

        var config = new HttpConfiguration();

        config.Routes.MapHttpRoute("default", "api/{controller}/{id}");
        app.UseWebApi(config);
    }
Пример #4
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Configure the db context and user manager to use a single instance per request
            //app.CreatePerOwinContext(ApplicationDbContext.Create);
            //app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);

            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            //app.UseCookieAuthentication(new CookieAuthenticationOptions());
            //app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Configure the application for OAuth based flow
            //PublicClientId = "self";
            //OAuthOptions = new OAuthAuthorizationServerOptions
            //{
            //    TokenEndpointPath = new PathString("/Token"),
            //    Provider = new ApplicationOAuthProvider(PublicClientId),
            //    AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"),
            //    AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),
            //    // In production mode set AllowInsecureHttp = false
            //    AllowInsecureHttp = true
            //};

            // Enable the application to use bearer tokens to authenticate users
            //app.UseOAuthBearerTokens(OAuthOptions);

            // Uncomment the following lines to enable logging in with third party login providers
            //app.UseMicrosoftAccountAuthentication(
            //    clientId: "",
            //    clientSecret: "");

            //app.UseTwitterAuthentication(
            //    consumerKey: "",
            //    consumerSecret: "");

            //app.UseFacebookAuthentication(
            //    appId: "",
            //    appSecret: "");

            //app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
            //{
            //    ClientId = "",
            //    ClientSecret = ""
            //});

            var digestOptions = new DigestAuthenticationOptions()
            {
                Realm = "magical",
                GenerateNonceBytes = () =>
                {
                    var bytes = new byte[16];
                    using (var provider = new RNGCryptoServiceProvider())
                    {
                        provider.GetBytes(bytes);
                    }
                    return(bytes);
                }
            };

            app.UseDigestAuthentication(digestOptions);
        }