Example #1
0
        public static void AddMsftJsonWebToken(
            this AuthenticationConfiguration configuration,
            string issuer, string audience,
            X509Certificate2 signingCert,
            AuthenticationOptions options,
            AuthenticationScheme scheme)
        {
            var validationParameters = new TokenValidationParameters()
            {
                AllowedAudience    = audience,
                SigningToken       = new X509SecurityToken(signingCert),
                ValidIssuer        = issuer,
                ValidateExpiration = true
            };

            var handler = new JWTSecurityTokenHandlerWrapper(validationParameters);

            configuration.AddMapping(new AuthenticationOptionMapping
            {
                TokenHandler = new SecurityTokenHandlerCollection {
                    handler
                },
                Options = options,
                Scheme  = scheme
            });
        }
        public static void AddMsftJsonWebToken(this AuthenticationConfiguration configuration, string issuer, string audience, X509Certificate2 signingCertificate)
        {
            var validationParameters = new TokenValidationParameters()
            {
                AllowedAudience    = audience,
                SigningToken       = new X509SecurityToken(signingCertificate),
                ValidIssuer        = issuer,
                ValidateExpiration = true
            };

            var handler = new JWTSecurityTokenHandlerWrapper(validationParameters);

            configuration.AddMapping(new AuthenticationOptionMapping {
                TokenHandler = new SecurityTokenHandlerCollection {
                    handler
                },
                Options = AuthenticationOptions.ForAuthorizationHeader(JwtConstants.Bearer),
                Scheme  = AuthenticationScheme.SchemeOnly(JwtConstants.Bearer)
            });
        }