Example #1
0
        public void Configuration(IAppBuilder app)
        {
            //var jwtOptions = new JwtBearerAuthenticationOptions()
            //{
            //    AllowedAudiences = new [] { "http://localhost:5000/api" },
            //    IssuerSecurityTokenProviders = new []
            //    {
            //        new SymmetricKeyIssuerSecurityTokenProvider("http://authzserver.demoX", "tTW8HB0ebW1qpCmRUEOknEIxaTQ0BFCYrdjOdOl4rfM=")
            //    }
            //};
            //app.UseJwtBearerAuthentication(jwtOptions);

            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);

            var config = new HttpConfiguration();

            config.Routes.MapHttpRoute("default", "api/{controller}/{id}");
            app.UseWebApi(config);
        }
Example #2
0
        public static IAppBuilder UseDigestAuthentication(this IAppBuilder app, DigestAuthenticationOptions options)
        {
            app.Use(typeof(DigestApplicationMiddleware), options);

            app.UseStageMarker(PipelineStage.Authenticate);

            return(app);
        }