private static void ThrowIfInvalidOptions(JwtTokenProviderOptions options) { if (string.IsNullOrEmpty(options.Path)) { throw new ArgumentNullException(nameof(JwtTokenProviderOptions.Path)); } if (string.IsNullOrEmpty(options.Issuer)) { throw new ArgumentNullException(nameof(JwtTokenProviderOptions.Issuer)); } if (string.IsNullOrEmpty(options.Audience)) { throw new ArgumentNullException(nameof(JwtTokenProviderOptions.Audience)); } if (options.Expiration == TimeSpan.Zero) { throw new ArgumentException("Must be a non-zero TimeSpan.", nameof(JwtTokenProviderOptions.Expiration)); } if (options.SigningCredentials == null) { throw new ArgumentNullException(nameof(JwtTokenProviderOptions.SigningCredentials)); } if (options.NonceGenerator == null) { throw new ArgumentNullException(nameof(JwtTokenProviderOptions.NonceGenerator)); } }
public JwtTokenProvider(RequestDelegate next, UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager, IOptions <JwtTokenProviderOptions> options) { _userManager = userManager; _signInManager = signInManager; _next = next; _options = options.Value; ThrowIfInvalidOptions(_options); _serializerSettings = new JsonSerializerSettings { Formatting = Formatting.Indented }; }