public static DeviceAuthorizationRequestValidator CreateDeviceAuthorizationRequestValidator( IdentityServerOptions options = null, IResourceStore resourceStore = null, IResourceValidator resourceValidator = null) { if (options == null) { options = TestIdentityServerOptions.Create(); } if (resourceStore == null) { resourceStore = new InMemoryResourcesStore(TestScopes.GetIdentity(), TestScopes.GetApis(), TestScopes.GetScopes()); } if (resourceValidator == null) { resourceValidator = CreateResourceValidator(resourceStore); } return(new DeviceAuthorizationRequestValidator( options, resourceValidator, TestLogger.Create <DeviceAuthorizationRequestValidator>())); }
public CachingResourceStoreTests() { _store = new InMemoryResourcesStore(_identityResources, _apiResources, _apiScopes); _subject = new CachingResourceStore <InMemoryResourcesStore>( _options, _store, _identityCache, _apiCache, _scopeCache, _resourceCache, _apiResourceNamesCache); }
public static AuthorizeRequestValidator CreateAuthorizeRequestValidator( IdentityServerOptions options = null, IResourceStore resourceStore = null, IClientStore clients = null, IProfileService profile = null, ICustomAuthorizeRequestValidator customValidator = null, IRedirectUriValidator uriValidator = null, ScopeValidator scopeValidator = null) { if (options == null) { options = TestIdentityServerOptions.Create(); } if (resourceStore == null) { resourceStore = new InMemoryResourcesStore(TestScopes.GetIdentity(), TestScopes.GetApis()); } if (clients == null) { clients = new InMemoryClientStore(TestClients.Get()); } if (customValidator == null) { customValidator = new DefaultCustomAuthorizeRequestValidator(); } if (uriValidator == null) { uriValidator = new StrictRedirectUriValidator(); } if (scopeValidator == null) { scopeValidator = new ScopeValidator(resourceStore, new LoggerFactory().CreateLogger <ScopeValidator>()); } var sessionId = new MockSessionIdService(); return(new AuthorizeRequestValidator( options, clients, customValidator, uriValidator, scopeValidator, sessionId, TestLogger.Create <AuthorizeRequestValidator>())); }
private void RebuildStores() { _resourceManager.EnterWriteLock(); try { var newClients = _configurations.Values.SelectMany(x => x.Clients).ToList(); var newIdentityResources = _configurations.Values.SelectMany(x => x.IdentityResources).ToList(); var newApiResources = _configurations.Values.SelectMany(x => x.ApiResources).ToList(); _clients = new InMemoryClientStore(newClients); _resources = new InMemoryResourcesStore(newIdentityResources, newApiResources); } finally { _resourceManager.ExitWriteLock(); } }
public UserInfoResponseGeneratorTests() { _client = new Client { ClientId = "client" }; _user = IdentityServerPrincipal.Create("bob", "bob", new Claim[] { new Claim("foo", "foo1"), new Claim("foo", "foo2"), new Claim("bar", "bar1"), new Claim("bar", "bar2"), }); _resourceStore = new InMemoryResourcesStore(_identityResources, _apiResources); _subject = new UserInfoResponseGenerator(_mockProfileService, _resourceStore, TestLogger.Create <UserInfoResponseGenerator>()); }
public UserInfoResponseGeneratorTests() { _client = new Client { ClientId = "client" }; _user = new IdentityServerUser("bob") { AdditionalClaims = { new Claim("foo", "foo1"), new Claim("foo", "foo2"), new Claim("bar", "bar1"), new Claim("bar", "bar2") } }.CreatePrincipal(); _resourceStore = new InMemoryResourcesStore(_identityResources, _apiResources, _apiScopes); _subject = new UserInfoResponseGenerator(_mockProfileService, _resourceStore, TestLogger.Create <UserInfoResponseGenerator>()); }
public DeviceAuthorizationResponseGeneratorTests() { var resourceStore = new InMemoryResourcesStore(identityResources, apiResources); var scopeValidator = new ScopeValidator(resourceStore, new NullLogger <ScopeValidator>()); testResult = new DeviceAuthorizationRequestValidationResult(new ValidatedDeviceAuthorizationRequest { Client = new Client { ClientId = Guid.NewGuid().ToString() }, IsOpenIdRequest = true, ValidatedScopes = scopeValidator }); generator = new DeviceAuthorizationResponseGenerator( options, new DefaultUserCodeService(new IUserCodeGenerator[] { new NumericUserCodeGenerator(), fakeUserCodeGenerator }), deviceFlowCodeService, clock, new NullLogger <DeviceAuthorizationResponseGenerator>()); }
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>())); }
public static AuthorizeRequestValidator CreateAuthorizeRequestValidator( IdentityServerOptions options = null, IIssuerNameService issuerNameService = null, IResourceStore resourceStore = null, IClientStore clients = null, IProfileService profile = null, ICustomAuthorizeRequestValidator customValidator = null, IRedirectUriValidator uriValidator = null, IResourceValidator resourceValidator = null, JwtRequestValidator jwtRequestValidator = null, IJwtRequestUriHttpClient jwtRequestUriHttpClient = 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 (clients == null) { clients = new InMemoryClientStore(TestClients.Get()); } if (customValidator == null) { customValidator = new DefaultCustomAuthorizeRequestValidator(); } if (uriValidator == null) { uriValidator = new StrictRedirectUriValidator(); } if (resourceValidator == null) { resourceValidator = CreateResourceValidator(resourceStore); } if (jwtRequestValidator == null) { jwtRequestValidator = new JwtRequestValidator("https://identityserver", new LoggerFactory().CreateLogger <JwtRequestValidator>()); } if (jwtRequestUriHttpClient == null) { jwtRequestUriHttpClient = new DefaultJwtRequestUriHttpClient(new HttpClient(new NetworkHandler(new Exception("no jwt request uri response configured"))), options, new LoggerFactory()); } var userSession = new MockUserSession(); return(new AuthorizeRequestValidator( options, issuerNameService, clients, customValidator, uriValidator, resourceValidator, userSession, jwtRequestValidator, jwtRequestUriHttpClient, TestLogger.Create <AuthorizeRequestValidator>())); }
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 ResourceStore(Func <ApplicationDbContext> dbFactory) { this.dbFactory = dbFactory; store = new InMemoryResourcesStore(identityResources, apiResources, apiScopes); }