Пример #1
0
        private static void ThrowIfInvalidOptions(JWTIssuerOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

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

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

            if (options.JtiGenerator == null)
            {
                throw new ArgumentNullException(nameof(JWTIssuerOptions.JtiGenerator));
            }
        }
Пример #2
0
 public JWTFactory(IOptions <JWTIssuerOptions> jwtOptions)
 {
     _jwtOptions = jwtOptions.Value;
     ThrowIfInvalidOptions(_jwtOptions);
 }