Beispiel #1
0
        public static void AddSaml2AndJwt(this AuthenticationConfiguration configuration, string issuerThumbprint, X509Certificate2 signingCertificate, string issuerName, string audienceUri, X509CertificateValidator certificateValidator, AuthenticationOptions options, AuthenticationScheme scheme, X509Certificate2 encryptionCertificate)
        {
            var validationParameters = new TokenValidationParameters()
            {
                AllowedAudience = audienceUri,
                SigningToken    = new X509SecurityToken(signingCertificate),
                ValidIssuer     = issuerName,
            };

            var jwtHandler = new JwtSecurityTokenHandlerWrapper(validationParameters);

            var samlHandlerConfig = CreateSaml2SecurityTokenHandlerConfiguration(issuerThumbprint, issuerName, audienceUri, certificateValidator, encryptionCertificate);
            var saml2Handler      = new HttpSaml2SecurityTokenHandler()
            {
                Configuration = samlHandlerConfig
            };

            configuration.AddMapping(new AuthenticationOptionMapping
            {
                TokenHandler = new SecurityTokenHandlerCollection {
                    jwtHandler, saml2Handler
                },
                Options = options,
                Scheme  = scheme
            });
        }
        public static void AddJsonWebToken(
            this AuthenticationConfiguration configuration, 
            TokenValidationParameters validationParameters,
            AuthenticationOptions options,
            AuthenticationScheme scheme,
            Dictionary<string, string> claimMappings = null)
        {
            var handler = new JwtSecurityTokenHandlerWrapper(validationParameters, claimMappings);

            configuration.AddMapping(new AuthenticationOptionMapping
            {
                TokenHandler = new SecurityTokenHandlerCollection { handler },
                Options = options,
                Scheme = scheme
            });
        }
        public static void AddSaml2AndJwt(this AuthenticationConfiguration configuration, string issuerThumbprint, X509Certificate2 signingCertificate, string issuerName, string audienceUri, X509CertificateValidator certificateValidator, AuthenticationOptions options, AuthenticationScheme scheme, X509Certificate2 encryptionCertificate)
        {
            var validationParameters = new TokenValidationParameters()
            {
                AllowedAudience = audienceUri,
                SigningToken = new X509SecurityToken(signingCertificate),
                ValidIssuer = issuerName,
            };

            var jwtHandler = new JwtSecurityTokenHandlerWrapper(validationParameters);

            var samlHandlerConfig = CreateSaml2SecurityTokenHandlerConfiguration(issuerThumbprint, issuerName, audienceUri, certificateValidator, encryptionCertificate);
            var saml2Handler = new HttpSaml2SecurityTokenHandler() { Configuration = samlHandlerConfig };

            configuration.AddMapping(new AuthenticationOptionMapping
            {
                TokenHandler = new SecurityTokenHandlerCollection { jwtHandler, saml2Handler },
                Options = options,
                Scheme = scheme
            });
        }