Beispiel #1
0
        private void Validate(BasicTokenProviderOptions options)
        {
            if (string.IsNullOrEmpty(options.Path))
            {
                throw new ArgumentNullException(nameof(BasicTokenProviderOptions.Path));
            }

            if (string.IsNullOrEmpty(options.Issuer))
            {
                throw new ArgumentNullException(nameof(BasicTokenProviderOptions.Issuer));
            }

            if (string.IsNullOrEmpty(options.Audience))
            {
                throw new ArgumentNullException(nameof(BasicTokenProviderOptions.Audience));
            }

            if (options.Expiration == TimeSpan.Zero)
            {
                throw new ArgumentException("Must be a non-zero TimeSpan.", nameof(BasicTokenProviderOptions.Expiration));
            }

            if (options.SigningCredentials == null)
            {
                throw new ArgumentNullException(nameof(BasicTokenProviderOptions.SigningCredentials));
            }

            if (options.NonceGenerator == null)
            {
                throw new ArgumentNullException(nameof(BasicTokenProviderOptions.NonceGenerator));
            }
        }
Beispiel #2
0
        public BasicTokenProviderOptions GetProviderOptions()
        {
            var secretKey = this.GetSecretKey();

            var hundredTokenProviderOptions = new BasicTokenProviderOptions
            {
                Path               = configuration.GetSection(BasicTokenProviderConfig.TokenPathSectionName).Value,
                Audience           = configuration.GetSection(BasicTokenProviderConfig.AudienceSectioName).Value,
                Issuer             = configuration.GetSection(BasicTokenProviderConfig.IssuerSectioName).Value,
                SigningCredentials = new SigningCredentials(secretKey, SecurityAlgorithms.HmacSha256)
                                     //IdentityResolver = identityResolver
            };

            return(hundredTokenProviderOptions);
        }