Beispiel #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TokenRequestValidator" /> class.
 /// </summary>
 /// <param name="options">The options.</param>
 /// <param name="authorizationCodeStore">The authorization code store.</param>
 /// <param name="resourceOwnerValidator">The resource owner validator.</param>
 /// <param name="profile">The profile.</param>
 /// <param name="deviceCodeValidator">The device code validator.</param>
 /// <param name="extensionGrantValidator">The extension grant validator.</param>
 /// <param name="customRequestValidator">The custom request validator.</param>
 /// <param name="resourceValidator">The resource validator.</param>
 /// <param name="resourceStore">The resource store.</param>
 /// <param name="refreshTokenService"></param>
 /// <param name="events">The events.</param>
 /// <param name="clock">The clock.</param>
 /// <param name="logger">The logger.</param>
 public TokenRequestValidator(IdentityServerOptions options,
                              IAuthorizationCodeStore authorizationCodeStore,
                              IResourceOwnerPasswordValidator resourceOwnerValidator,
                              IProfileService profile,
                              IDeviceCodeValidator deviceCodeValidator,
                              ExtensionGrantValidator extensionGrantValidator,
                              ICustomTokenRequestValidator customRequestValidator,
                              IResourceValidator resourceValidator,
                              IResourceStore resourceStore,
                              IRefreshTokenService refreshTokenService,
                              IEventService events,
                              ISystemClock clock,
                              ILogger <TokenRequestValidator> logger)
 {
     _logger  = logger;
     _options = options;
     _clock   = clock;
     _authorizationCodeStore = authorizationCodeStore;
     _resourceOwnerValidator = resourceOwnerValidator;
     _profile                 = profile ?? throw new ArgumentNullException(nameof(profile));
     _deviceCodeValidator     = deviceCodeValidator;
     _extensionGrantValidator = extensionGrantValidator;
     _customRequestValidator  = customRequestValidator;
     _resourceValidator       = resourceValidator;
     _resourceStore           = resourceStore;
     _events = events ?? throw new ArgumentNullException(nameof(events));
     _refreshTokenService = refreshTokenService ?? throw new ArgumentNullException(nameof(refreshTokenService));
 }
 public TokenRequestValidator(
     IdentityServerOptions options,
     IIssuerNameService issuerNameService,
     IAuthorizationCodeStore authorizationCodeStore,
     IResourceOwnerPasswordValidator resourceOwnerValidator,
     IProfileService profile,
     IDeviceCodeValidator deviceCodeValidator,
     IBackchannelAuthenticationRequestIdValidator backchannelAuthenticationRequestIdValidator,
     ExtensionGrantValidator extensionGrantValidator,
     ICustomTokenRequestValidator customRequestValidator,
     IResourceValidator resourceValidator,
     IResourceStore resourceStore,
     IRefreshTokenService refreshTokenService,
     IEventService events,
     ISystemClock clock,
     ILogger <TokenRequestValidator> logger)
 {
     _logger                 = logger;
     _options                = options;
     _issuerNameService      = issuerNameService;
     _clock                  = clock;
     _authorizationCodeStore = authorizationCodeStore;
     _resourceOwnerValidator = resourceOwnerValidator;
     _profile                = profile;
     _deviceCodeValidator    = deviceCodeValidator;
     _backchannelAuthenticationRequestIdValidator = backchannelAuthenticationRequestIdValidator;
     _extensionGrantValidator = extensionGrantValidator;
     _customRequestValidator  = customRequestValidator;
     _resourceValidator       = resourceValidator;
     _resourceStore           = resourceStore;
     _refreshTokenService     = refreshTokenService;
     _events = events;
 }
 public IdentityServerHostBuilder UseResourceOwnerPasswordValidator <TResourceOwnerPasswordValidator>(
     TResourceOwnerPasswordValidator resourceOwnerPasswordValidator)
     where TResourceOwnerPasswordValidator : class, IResourceOwnerPasswordValidator
 {
     this.internalResourceOwnerPasswordValidator = resourceOwnerPasswordValidator;
     return(this);
 }
Beispiel #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TokenRequestValidator" /> class.
 /// </summary>
 /// <param name="options">The options.</param>
 /// <param name="authorizationCodeStore">The authorization code store.</param>
 /// <param name="resourceOwnerValidator">The resource owner validator.</param>
 /// <param name="profile">The profile.</param>
 /// <param name="deviceCodeValidator">The device code validator.</param>
 /// <param name="extensionGrantValidator">The extension grant validator.</param>
 /// <param name="customRequestValidator">The custom request validator.</param>
 /// <param name="resourceValidator">The resource validator.</param>
 /// <param name="resourceStore">The resource store.</param>
 /// <param name="tokenValidator">The token validator.</param>
 /// <param name="events">The events.</param>
 /// <param name="clock">The clock.</param>
 /// <param name="logger">The logger.</param>
 public TokenRequestValidator(IdentityServerOptions options,
                              IAuthorizationCodeStore authorizationCodeStore,
                              IResourceOwnerPasswordValidator resourceOwnerValidator,
                              IProfileService profile,
                              IDeviceCodeValidator deviceCodeValidator,
                              ExtensionGrantValidator extensionGrantValidator,
                              ICustomTokenRequestValidator customRequestValidator,
                              IResourceValidator resourceValidator,
                              IResourceStore resourceStore,
                              ITokenValidator tokenValidator,
                              IEventService events,
                              ISystemClock clock,
                              ILogger <TokenRequestValidator> logger)
 {
     _logger  = logger;
     _options = options;
     _clock   = clock;
     _authorizationCodeStore = authorizationCodeStore;
     _resourceOwnerValidator = resourceOwnerValidator;
     _profile                 = profile;
     _deviceCodeValidator     = deviceCodeValidator;
     _extensionGrantValidator = extensionGrantValidator;
     _customRequestValidator  = customRequestValidator;
     _resourceValidator       = resourceValidator;
     _resourceStore           = resourceStore;
     _tokenValidator          = tokenValidator;
     _events = events;
 }
 public AccountController(UserContext userContext, IEventService events, IIdentityServerInteractionService interaction, IResourceOwnerPasswordValidator usersValidator, IMapper mapper)
 {
     _events         = events;
     _interaction    = interaction;
     _usersValidator = usersValidator;
     _mapper         = mapper;
     _userContext    = userContext;
 }
Beispiel #6
0
 public ResourceOwnerPasswordValidatorTest()
 {
     _accountGetterServiceMock        = new Mock <IAccountGetterService>();
     _accountVerificationServiceMock  = new Mock <IAccountVerificationService>();
     _accountClaimsCreatorServiceMock = new Mock <IAccountClaimsCreatorService>();
     _resourceOwnerPasswordValidator  = new ResourceOwnerPasswordValidator(_accountGetterServiceMock.Object,
                                                                           _accountVerificationServiceMock.Object, _accountClaimsCreatorServiceMock.Object);
 }
Beispiel #7
0
        public TBuilder UseResourceOwnerPasswordValidator <TResourceOwnerPasswordValidator>(
            TResourceOwnerPasswordValidator resourceOwnerPasswordValidator)
            where TResourceOwnerPasswordValidator : class, IResourceOwnerPasswordValidator
        {
            this.internalResourceOwnerPasswordValidator = resourceOwnerPasswordValidator;

            return((TBuilder)this);
        }
 public DiscoveryEndpoint(IdentityServerOptions options, IScopeStore scopes, ILogger <DiscoveryEndpoint> logger, IKeyMaterialService keys, ExtensionGrantValidator extensionGrants, SecretParser parsers, IResourceOwnerPasswordValidator resourceOwnerValidator)
 {
     _options                = options;
     _scopes                 = scopes;
     _logger                 = logger;
     _extensionGrants        = extensionGrants;
     _parsers                = parsers;
     _keys                   = keys;
     _resourceOwnerValidator = resourceOwnerValidator;
 }
 public TokenRequestValidator(IdentityServerOptions options, IPersistedGrantService grants, IResourceOwnerPasswordValidator resourceOwnerValidator, IProfileService profile, ExtensionGrantValidator extensionGrantValidator, ICustomTokenRequestValidator customRequestValidator, ScopeValidator scopeValidator, IEventService events, ILogger <TokenRequestValidator> logger)
 {
     _logger  = logger;
     _options = options;
     _grants  = grants;
     _resourceOwnerValidator = resourceOwnerValidator;
     _profile = profile;
     _extensionGrantValidator = extensionGrantValidator;
     _customRequestValidator  = customRequestValidator;
     _scopeValidator          = scopeValidator;
     _events = events;
 }
Beispiel #10
0
 public AccountController(UserContext userContext, IEventService events,
                          IIdentityServerInteractionService interaction, IResourceOwnerPasswordValidator usersValidator,
                          IMapper mapper, IMailService mailService, IMailTemplateService mailTemplateService, ICurrentUserService currentUserService)
 {
     _events              = events;
     _interaction         = interaction;
     _usersValidator      = usersValidator;
     _mapper              = mapper;
     _userContext         = userContext;
     _mailService         = mailService;
     _mailTemplateService = mailTemplateService;
     _currentUserService  = currentUserService;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TokenRequestValidator"/> class.
 /// </summary>
 /// <param name="options">The options.</param>
 /// <param name="authorizationCodeStore">The authorization code store.</param>
 /// <param name="refreshTokenStore">The refresh token store.</param>
 /// <param name="resourceOwnerValidator">The resource owner validator.</param>
 /// <param name="profile">The profile.</param>
 /// <param name="extensionGrantValidator">The extension grant validator.</param>
 /// <param name="customRequestValidator">The custom request validator.</param>
 /// <param name="scopeValidator">The scope validator.</param>
 /// <param name="events">The events.</param>
 /// <param name="logger">The logger.</param>
 public TokenRequestValidator(IdentityServerOptions options, IAuthorizationCodeStore authorizationCodeStore, IRefreshTokenStore refreshTokenStore, IResourceOwnerPasswordValidator resourceOwnerValidator, IProfileService profile, ExtensionGrantValidator extensionGrantValidator, ICustomTokenRequestValidator customRequestValidator, ScopeValidator scopeValidator, IEventService events, ILogger <TokenRequestValidator> logger)
 {
     _logger  = logger;
     _options = options;
     _authorizationCodeStore = authorizationCodeStore;
     _refreshTokenStore      = refreshTokenStore;
     _resourceOwnerValidator = resourceOwnerValidator;
     _profile = profile;
     _extensionGrantValidator = extensionGrantValidator;
     _customRequestValidator  = customRequestValidator;
     _scopeValidator          = scopeValidator;
     _events = events;
 }
 public DiscoveryResponseGenerator(
     IdentityServerOptions options,
     IResourceStore resourceStore,
     IKeyMaterialService keys,
     ExtensionGrantValidator extensionGrants,
     ISecretsListParser secretParsers,
     IResourceOwnerPasswordValidator resourceOwnerValidator,
     ILogger <DiscoveryResponseGenerator> logger,
     GlobalSettings globalSettings)
     : base(options, resourceStore, keys, extensionGrants, secretParsers, resourceOwnerValidator, logger)
 {
     _globalSettings = globalSettings;
 }
Beispiel #13
0
 public AccountController(
     IIdentityServerInteractionService interaction,
     IClientStore clientStore,
     IHttpContextAccessor httpContextAccessor,
     IEventService events,
     IResourceOwnerPasswordValidator resOwnerValidator, IUserRepository userRepo)
 {
     _interaction       = interaction;
     _events            = events;
     _account           = new AccountService(interaction, httpContextAccessor, clientStore);
     _resOwnerValidator = resOwnerValidator;
     _userRepo          = userRepo;
 }
Beispiel #14
0
        public AccountController(
            IIdentityServerInteractionService interaction,
            IClientStore clientStore,
            IAuthenticationSchemeProvider schemeProvider,
            IEventService events,
            UserManager <User> users,
            IUserStore <User> userStore,
            IResourceOwnerPasswordValidator validator,
            IPasswordHasher <User> passwordHasher,
            SignInManager <User> signInManager,
            AuthenticationContext authenticationContext,
            IConfiguration configuration,
            IJsonHelper jsonHelper)
        {
            // if the TestUserStore is not in DI, then we'll just use the global users collection
            // this is where you would plug in your own custom identity management library (e.g. ASP.NET Identity)
            _users                 = users;
            _userStore             = userStore;
            _signInManager         = signInManager;
            _interaction           = interaction;
            _clientStore           = clientStore;
            _schemeProvider        = schemeProvider;
            _events                = events;
            _validator             = validator;
            _passwordHasher        = passwordHasher;
            _authenticationContext = authenticationContext;
            _jsonHelper            = jsonHelper;

            var invalidToken = "6d6b44d78b09fed0c5559e34c71db291d0d322d4d4de0000";

            _origin = configuration["Fido2:Origin"];
            var MDSAccessKey    = configuration["fido2:MDSAccessKey"];
            var MDSCacheDirPath = configuration["fido2:MDSCacheDirPath"] ?? Path.Combine(Path.GetTempPath(), "fido2mdscache");

            _mds = string.IsNullOrEmpty(MDSAccessKey) ? null : MDSMetadata.Instance(MDSAccessKey, MDSCacheDirPath);
            if (null != _mds)
            {
                if (false == _mds.IsInitialized())
                {
                    _mds.Initialize().Wait();
                }
            }

            _lib = new Fido2(new Fido2Configuration()
            {
                ServerDomain    = configuration["Fido2:ServerDomain"],
                ServerName      = "Fido2 Identity Server",
                Origin          = _origin,
                MetadataService = _mds
            });
        }
Beispiel #15
0
        public TokenRequestValidator(IdentityServerOptions options, IAuthorizationCodeStore authorizationCodes, IRefreshTokenStore refreshTokens, IResourceOwnerPasswordValidator resourceOwnerValidator, IProfileService profile, CustomGrantValidator customGrantValidator, ICustomRequestValidator customRequestValidator, ScopeValidator scopeValidator, IEventService events, ILoggerFactory loggerFactory)
        {
            _logger = loggerFactory.CreateLogger<TokenRequestValidator>();

            _options = options;
            _authorizationCodes = authorizationCodes;
            _refreshTokens = refreshTokens;
            _resourceOwnerValidator = resourceOwnerValidator;
            _profile = profile;
            _customGrantValidator = customGrantValidator;
            _customRequestValidator = customRequestValidator;
            _scopeValidator = scopeValidator;
            _events = events;
        }
        public TokenRequestValidator(IdentityServerOptions options, IAuthorizationCodeStore authorizationCodes, IRefreshTokenStore refreshTokens, IResourceOwnerPasswordValidator resourceOwnerValidator, IProfileService profile, CustomGrantValidator customGrantValidator, ICustomRequestValidator customRequestValidator, ScopeValidator scopeValidator, IEventService events, ILoggerFactory loggerFactory)
        {
            _logger = loggerFactory.CreateLogger <TokenRequestValidator>();

            _options                = options;
            _authorizationCodes     = authorizationCodes;
            _refreshTokens          = refreshTokens;
            _resourceOwnerValidator = resourceOwnerValidator;
            _profile                = profile;
            _customGrantValidator   = customGrantValidator;
            _customRequestValidator = customRequestValidator;
            _scopeValidator         = scopeValidator;
            _events = events;
        }
 public AccountController(
     IIdentityServerInteractionService interaction,
     IClientStore clientStore,
     IAuthenticationSchemeProvider schemeProvider,
     IEventService events,
     IUserRepository users,
     IResourceOwnerPasswordValidator userValidator)
 {
     _users          = users;// ?? new TestUserStore(TestUsers.Users);
     _userValidator  = userValidator;
     _interaction    = interaction;
     _clientStore    = clientStore;
     _schemeProvider = schemeProvider;
     _events         = events;
 }
Beispiel #18
0
 public LoginController(/*SpidUserManager userManager,
                         * SpidSignInManager signInManager,*/
     AuthRequest authRequest,
     JoueurRepository repo,
     IConfiguration configuration,
     ILoggerFactory loggerFactory,
     IResourceOwnerPasswordValidator pv)
 {
     //  _userManager = userManager;
     //  _signInManager = signInManager;
     _configuration = configuration;
     _logger        = loggerFactory.CreateLogger <AccountController>();
     _pv            = pv;
     _authRequest   = authRequest;
     _repo          = repo;
 }
 public AccountController(
     IIdentityServerInteractionService interaction,
     IClientStore clientStore,
     IHttpContextAccessor httpContextAccessor,
     IAuthenticationSchemeProvider schemeProvider,
     IEventService events,
     IResourceOwnerPasswordValidator passwordValidator,
     IUserService userService)
 {
     // if the TestUserStore is not in DI, then we'll just use the global users collection
     this.passwordValidator = passwordValidator;
     this.interaction       = interaction;
     this.events            = events;
     this.userService       = userService;
     account = new AccountService(interaction, httpContextAccessor, schemeProvider, clientStore);
 }
Beispiel #20
0
 public AccountController(
     IIdentityServerInteractionService interaction,
     IClientStore clientStore,
     IHttpContextAccessor httpContextAccessor,
     IUserStore userStore,
     IResourceOwnerPasswordValidator passwordValidator,
     IIdentityPlayerManagementClient playerManagementClient,
     ILogger <AccountController> logger)
 {
     // if the TestUserStore is not in DI, then we'll just use the global users collection
     _userStore              = userStore;
     _passwordValidator      = passwordValidator;
     _interaction            = interaction;
     _account                = new AccountService(interaction, httpContextAccessor, clientStore);
     _playerManagementClient = playerManagementClient;
     _logger = logger;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DiscoveryResponseGenerator"/> class.
 /// </summary>
 /// <param name="options">The options.</param>
 /// <param name="resourceStore">The resource store.</param>
 /// <param name="keys">The keys.</param>
 /// <param name="extensionGrants">The extension grants.</param>
 /// <param name="secretParsers">The secret parsers.</param>
 /// <param name="resourceOwnerValidator">The resource owner validator.</param>
 /// <param name="logger">The logger.</param>
 public DiscoveryResponseGenerator(
     IdentityServerOptions options,
     IResourceStore resourceStore,
     IKeyMaterialService keys,
     ExtensionGrantValidator extensionGrants,
     ISecretsListParser secretParsers,
     IResourceOwnerPasswordValidator resourceOwnerValidator,
     ILogger <DiscoveryResponseGenerator> logger)
 {
     Options                = options;
     ResourceStore          = resourceStore;
     Keys                   = keys;
     ExtensionGrants        = extensionGrants;
     SecretParsers          = secretParsers;
     ResourceOwnerValidator = resourceOwnerValidator;
     Logger                 = logger;
 }
        public async Task <IActionResult> Authenticate(
            [FromBody] SigninModel signinModel,
            [FromServices] IResourceOwnerPasswordValidator resourceOwnerPasswordValidator,
            [FromServices] ISystemClock systemClock
            )
        {
            var contx = new ResourceOwnerPasswordValidationContext {
                UserName = signinModel.Username, Password = signinModel.Password
            };

            await resourceOwnerPasswordValidator.ValidateAsync(contx);

            if (!contx.Result.IsError)
            {
                await HttpContext.SignInAsync(contx.Result.Subject.GetSubjectId(), contx.Result.Subject.Claims.ToArray());

                return(NoContent());
            }

            return(this.Unauthorized());
        }
Beispiel #23
0
        public AccountController(
            IIdentityServerInteractionService interaction,
            IClientStore clientStore,
            IAuthenticationSchemeProvider schemeProvider,
            IEventService events,
            ILoggerFactory loggerFactory,
            IResourceOwnerPasswordValidator resourceOwnerPasswordValidator,
            IUserRepository userRepository
            )
        {
            // if the TestUserStore is not in DI, then we'll just use the global users collection
            // this is where you would plug in your own custom identity management library (e.g. ASP.NET Identity)


            _interaction    = interaction;
            _clientStore    = clientStore;
            _schemeProvider = schemeProvider;
            _events         = events;
            _logger         = loggerFactory.CreateLogger("Account");
            _userRepository = userRepository;
            _resourceOwnerPasswordValidation = resourceOwnerPasswordValidator;
        }
Beispiel #24
0
        public static TokenRequestValidator CreateTokenRequestValidator(
            IdentityServerOptions options                          = null,
            IIssuerNameService issuerNameService                   = null,
            IResourceStore resourceStore                           = null,
            IAuthorizationCodeStore authorizationCodeStore         = null,
            IRefreshTokenStore refreshTokenStore                   = null,
            IResourceOwnerPasswordValidator resourceOwnerValidator = null,
            IProfileService profile = null,
            IDeviceCodeValidator deviceCodeValidator = null,
            IEnumerable <IExtensionGrantValidator> extensionGrantValidators = null,
            ICustomTokenRequestValidator customRequestValidator             = null,
            IRefreshTokenService refreshTokenService = null,
            IResourceValidator resourceValidator     = null)
        {
            if (options == null)
            {
                options = TestIdentityServerOptions.Create();
            }

            if (issuerNameService == null)
            {
                issuerNameService = new TestIssuerNameService(options.IssuerUri);
            }

            if (resourceStore == null)
            {
                resourceStore = new InMemoryResourcesStore(TestScopes.GetIdentity(), TestScopes.GetApis(), TestScopes.GetScopes());
            }

            if (resourceOwnerValidator == null)
            {
                resourceOwnerValidator = new TestResourceOwnerPasswordValidator();
            }

            if (profile == null)
            {
                profile = new TestProfileService();
            }

            if (deviceCodeValidator == null)
            {
                deviceCodeValidator = new TestDeviceCodeValidator();
            }

            if (customRequestValidator == null)
            {
                customRequestValidator = new DefaultCustomTokenRequestValidator();
            }

            ExtensionGrantValidator aggregateExtensionGrantValidator;

            if (extensionGrantValidators == null)
            {
                aggregateExtensionGrantValidator = new ExtensionGrantValidator(new[] { new TestGrantValidator() }, TestLogger.Create <ExtensionGrantValidator>());
            }
            else
            {
                aggregateExtensionGrantValidator = new ExtensionGrantValidator(extensionGrantValidators, TestLogger.Create <ExtensionGrantValidator>());
            }

            if (authorizationCodeStore == null)
            {
                authorizationCodeStore = CreateAuthorizationCodeStore();
            }

            if (refreshTokenStore == null)
            {
                refreshTokenStore = CreateRefreshTokenStore();
            }

            if (resourceValidator == null)
            {
                resourceValidator = CreateResourceValidator(resourceStore);
            }

            if (refreshTokenService == null)
            {
                refreshTokenService = CreateRefreshTokenService(
                    refreshTokenStore,
                    profile);
            }

            return(new TokenRequestValidator(
                       options,
                       issuerNameService,
                       authorizationCodeStore,
                       resourceOwnerValidator,
                       profile,
                       deviceCodeValidator,
                       aggregateExtensionGrantValidator,
                       customRequestValidator,
                       resourceValidator,
                       resourceStore,
                       refreshTokenService,
                       new TestEventService(),
                       new StubClock(),
                       TestLogger.Create <TokenRequestValidator>()));
        }
Beispiel #25
0
        public static TokenRequestValidator CreateTokenRequestValidator(
            IdentityServerOptions options = null,
            IResourceStore resourceStore  = null,
            IAuthorizationCodeStore authorizationCodeStore         = null,
            IRefreshTokenStore refreshTokenStore                   = null,
            IResourceOwnerPasswordValidator resourceOwnerValidator = null,
            IProfileService profile = null,
            IEnumerable <IExtensionGrantValidator> extensionGrantValidators = null,
            ICustomTokenRequestValidator customRequestValidator             = null,
            ScopeValidator scopeValidator = null)
        {
            if (options == null)
            {
                options = TestIdentityServerOptions.Create();
            }

            if (resourceStore == null)
            {
                resourceStore = new InMemoryResourcesStore(TestScopes.GetIdentity(), TestScopes.GetApis());
            }

            if (resourceOwnerValidator == null)
            {
                resourceOwnerValidator = new TestResourceOwnerPasswordValidator();
            }

            if (profile == null)
            {
                profile = new TestProfileService();
            }

            if (customRequestValidator == null)
            {
                customRequestValidator = new DefaultCustomTokenRequestValidator();
            }

            ExtensionGrantValidator aggregateExtensionGrantValidator;

            if (extensionGrantValidators == null)
            {
                aggregateExtensionGrantValidator = new ExtensionGrantValidator(new[] { new TestGrantValidator() }, TestLogger.Create <ExtensionGrantValidator>());
            }
            else
            {
                aggregateExtensionGrantValidator = new ExtensionGrantValidator(extensionGrantValidators, TestLogger.Create <ExtensionGrantValidator>());
            }

            if (authorizationCodeStore == null)
            {
                authorizationCodeStore = CreateAuthorizationCodeStore();
            }

            if (refreshTokenStore == null)
            {
                refreshTokenStore = CreateRefreshTokenStore();
            }

            if (scopeValidator == null)
            {
                scopeValidator = new ScopeValidator(resourceStore, new LoggerFactory().CreateLogger <ScopeValidator>());
            }

            return(new TokenRequestValidator(
                       options,
                       authorizationCodeStore,
                       refreshTokenStore,
                       resourceOwnerValidator,
                       profile,
                       aggregateExtensionGrantValidator,
                       customRequestValidator,
                       scopeValidator,
                       new TestEventService(),
                       TestLogger.Create <TokenRequestValidator>()));
        }
        public static TokenRequestValidator CreateTokenRequestValidator(
            IdentityServerOptions options = null,
            IScopeStore scopes = null,
            IAuthorizationCodeStore authorizationCodeStore = null,
            IRefreshTokenStore refreshTokens = null,
            IResourceOwnerPasswordValidator resourceOwnerValidator = null,
            IProfileService profile = null,
            IEnumerable<ICustomGrantValidator> customGrantValidators = null,
            ICustomRequestValidator customRequestValidator = null,
            ScopeValidator scopeValidator = null)
        {
            if (options == null)
            {
                options = TestIdentityServerOptions.Create();
            }

            if (scopes == null)
            {
                scopes = new InMemoryScopeStore(TestScopes.Get());
            }

            if (resourceOwnerValidator == null)
            {
                resourceOwnerValidator = new TestResourceOwnerPasswordValidator();
            }

            if (profile == null)
            {
                profile = new TestProfileService();
            }

            if (customRequestValidator == null)
            {
                customRequestValidator = new DefaultCustomRequestValidator();
            }

            CustomGrantValidator aggregateCustomValidator;
            if (customGrantValidators == null)
            {
                aggregateCustomValidator = new CustomGrantValidator(new [] { new TestGrantValidator() }, new Logger<CustomGrantValidator>(new LoggerFactory()));
            }
            else
            {
                aggregateCustomValidator = new CustomGrantValidator(customGrantValidators, new Logger<CustomGrantValidator>(new LoggerFactory()));
            }

            if (refreshTokens == null)
            {
                refreshTokens = new InMemoryRefreshTokenStore();
            }

            if (scopeValidator == null)
            {
                scopeValidator = new ScopeValidator(scopes, new LoggerFactory());
            }

            return new TokenRequestValidator(
                options,
                authorizationCodeStore,
                refreshTokens,
                resourceOwnerValidator,
                profile,
                aggregateCustomValidator,
                customRequestValidator,
                scopeValidator,
                new DefaultEventService(new LoggerFactory()),
                new LoggerFactory());
        }
Beispiel #27
0
 public LoginService(IResourceOwnerPasswordValidator passwordValidator)
 {
     _passwordValidator = passwordValidator;
 }
Beispiel #28
0
        public static TokenRequestValidator CreateTokenRequestValidator(
            IdentityServerOptions options = null,
            IScopeStore scopes            = null,
            IAuthorizationCodeStore authorizationCodeStore = null,
            IRefreshTokenStore refreshTokens = null,
            IResourceOwnerPasswordValidator resourceOwnerValidator = null,
            IProfileService profile = null,
            IEnumerable <ICustomGrantValidator> customGrantValidators = null,
            ICustomRequestValidator customRequestValidator            = null,
            ScopeValidator scopeValidator = null)
        {
            if (options == null)
            {
                options = TestIdentityServerOptions.Create();
            }

            if (scopes == null)
            {
                scopes = new InMemoryScopeStore(TestScopes.Get());
            }

            if (resourceOwnerValidator == null)
            {
                resourceOwnerValidator = new TestResourceOwnerPasswordValidator();
            }

            if (profile == null)
            {
                profile = new TestProfileService();
            }

            if (customRequestValidator == null)
            {
                customRequestValidator = new DefaultCustomRequestValidator();
            }

            CustomGrantValidator aggregateCustomValidator;

            if (customGrantValidators == null)
            {
                aggregateCustomValidator = new CustomGrantValidator(new [] { new TestGrantValidator() }, TestLogger.Create <CustomGrantValidator>());
            }
            else
            {
                aggregateCustomValidator = new CustomGrantValidator(customGrantValidators, TestLogger.Create <CustomGrantValidator>());
            }

            if (refreshTokens == null)
            {
                refreshTokens = new InMemoryRefreshTokenStore();
            }

            if (scopeValidator == null)
            {
                scopeValidator = new ScopeValidator(scopes, new LoggerFactory().CreateLogger <ScopeValidator>());
            }

            var idsvrContext = IdentityServerContextHelper.Create();

            return(new TokenRequestValidator(
                       options,
                       authorizationCodeStore,
                       refreshTokens,
                       resourceOwnerValidator,
                       profile,
                       aggregateCustomValidator,
                       customRequestValidator,
                       scopeValidator,
                       new TestEventService(),
                       TestLogger.Create <TokenRequestValidator>()));
        }
 public LoginService(IResourceOwnerPasswordValidator passwordValidator, IRepository repository)
 {
     _passwordValidator = passwordValidator;
     _repository        = repository;
 }
Beispiel #30
0
        public static TokenRequestValidator CreateTokenRequestValidator(
            IdentityServerOptions options = null,
            IScopeStore scopes            = null,
            IPersistedGrantService grants = null,
            IResourceOwnerPasswordValidator resourceOwnerValidator = null,
            IProfileService profile = null,
            IEnumerable <IExtensionGrantValidator> extensionGrantValidators = null,
            ICustomTokenRequestValidator customRequestValidator             = null,
            ScopeValidator scopeValidator = null)
        {
            if (options == null)
            {
                options = TestIdentityServerOptions.Create();
            }

            if (scopes == null)
            {
                scopes = new InMemoryScopeStore(TestScopes.Get());
            }

            if (resourceOwnerValidator == null)
            {
                resourceOwnerValidator = new TestResourceOwnerPasswordValidator();
            }

            if (profile == null)
            {
                profile = new TestProfileService();
            }

            if (customRequestValidator == null)
            {
                customRequestValidator = new DefaultCustomTokenRequestValidator();
            }

            ExtensionGrantValidator aggregateExtensionGrantValidator;

            if (extensionGrantValidators == null)
            {
                aggregateExtensionGrantValidator = new ExtensionGrantValidator(new[] { new TestGrantValidator() }, TestLogger.Create <ExtensionGrantValidator>());
            }
            else
            {
                aggregateExtensionGrantValidator = new ExtensionGrantValidator(extensionGrantValidators, TestLogger.Create <ExtensionGrantValidator>());
            }

            if (grants == null)
            {
                grants = CreateGrantService();
            }

            if (scopeValidator == null)
            {
                scopeValidator = new ScopeValidator(scopes, new LoggerFactory().CreateLogger <ScopeValidator>());
            }

            return(new TokenRequestValidator(
                       options,
                       grants,
                       resourceOwnerValidator,
                       profile,
                       aggregateExtensionGrantValidator,
                       customRequestValidator,
                       scopeValidator,
                       new TestEventService(),
                       TestLogger.Create <TokenRequestValidator>()));
        }