Exemplo n.º 1
0
        public LoginController(IOptions <IssuerOptions> jwtOptions, ILoggerFactory loggerFactory)
        {
            _jwtOptions = jwtOptions.Value;
            ThrowIfInvalidOptions(_jwtOptions);

            _logger            = loggerFactory.CreateLogger <LoginController>();
            _serializeSettings = new JsonSerializerSettings
            {
                Formatting = Formatting.Indented
            };
        }
Exemplo n.º 2
0
        private static void ThrowIfInvalidOptions(IssuerOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

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

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

            if (options.JtiGenerator == null)
            {
                throw new ArgumentNullException(nameof(IssuerOptions.JtiGenerator));
            }
        }
Exemplo n.º 3
0
 public UserService(IUserRepository userRepository, IOptions <IssuerOptions> jwtOptions)
 {
     _userRepository = userRepository;
     _jwtOptions     = jwtOptions.Value;
 }