//public static ClientValidator CreateClientValidator( // IClientStore clients = null, // IClientSecretValidator secretValidator = null) //{ // if (clients == null) // { // clients = new InMemoryClientStore(ClientValidationTestClients.Get()); // } // if (secretValidator == null) // { // secretValidator = new HashedClientSecretValidator(); // } // var owin = new OwinEnvironmentService(new OwinContext()); // return new ClientValidator(clients, secretValidator, owin); //} public static TokenRequestValidator CreateTokenRequestValidator( IdentityServerOptions options = null, IScopeStore scopes = null, IAuthorizationCodeStore authorizationCodeStore = null, IRefreshTokenStore refreshTokens = null, IUserService userService = 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 (userService == null) { userService = new TestUserService(); } if (customRequestValidator == null) { customRequestValidator = new DefaultCustomRequestValidator(); } CustomGrantValidator aggregateCustomValidator; if (customGrantValidators == null) { aggregateCustomValidator = new CustomGrantValidator(new [] { new TestGrantValidator() }); } else { aggregateCustomValidator = new CustomGrantValidator(customGrantValidators); } if (refreshTokens == null) { refreshTokens = new InMemoryRefreshTokenStore(); } if (scopeValidator == null) { scopeValidator = new ScopeValidator(scopes); } return new TokenRequestValidator( options, authorizationCodeStore, refreshTokens, userService, aggregateCustomValidator, customRequestValidator, scopeValidator, new DefaultEventService()); }
public UploadCommand(IMessageObserver observer, IGoulRequestHandler gRequestHandler, ICredentialStore credentialStore, IRefreshTokenStore refreshStore) { mObserver = observer; mHandler = gRequestHandler; mCredentialStore = credentialStore; mRefreshStore = refreshStore; }
public AuthorizeCommand(IMessageObserver observer, IRefreshTokenStore refreshStorage, ICredentialStore credentialStore, IGoulRequestHandler handler) { mObserver = observer; mRefreshStorage = refreshStorage; mCredStore = credentialStore; mHandler = handler; }
public static TokenRequestValidator CreateTokenRequestValidator( IdentityServerOptions options = null, IScopeStore scopes = null, IAuthorizationCodeStore authorizationCodeStore = null, IRefreshTokenStore refreshTokens = null, IUserService userService = null, ICustomGrantValidator customGrantValidator = null, ICustomRequestValidator customRequestValidator = null, ScopeValidator scopeValidator = null, IDictionary<string, object> environment = null) { if (options == null) { options = TestIdentityServerOptions.Create(); } if (scopes == null) { scopes = new InMemoryScopeStore(TestScopes.Get()); } if (userService == null) { userService = new TestUserService(); } if (customRequestValidator == null) { customRequestValidator = new DefaultCustomRequestValidator(); } if (customGrantValidator == null) { customGrantValidator = new TestGrantValidator(); } if (refreshTokens == null) { refreshTokens = new InMemoryRefreshTokenStore(); } if (scopeValidator == null) { scopeValidator = new ScopeValidator(scopes); } IOwinContext context; if (environment == null) { context = new OwinContext(new Dictionary<string, object>()); } else { context = new OwinContext(environment); } return new TokenRequestValidator(options, authorizationCodeStore, refreshTokens, userService, scopes, customGrantValidator, customRequestValidator, scopeValidator, context); }
public RevocationRequestValidation() { _refreshTokens = new InMemoryRefreshTokenStore(); _tokenHandles = new InMemoryTokenHandleStore(); _clients = new InMemoryClientStore(TestClients.Get()); _validator = new TokenRevocationRequestValidator(); }
public RevocationEndpointController(IdentityServerOptions options, ClientSecretValidator clientValidator, TokenRevocationRequestValidator requestValidator, ITokenHandleStore tokenHandles, IRefreshTokenStore refreshTokens, IEventService events) { _options = options; _clientValidator = clientValidator; _requestValidator = requestValidator; _tokenHandles = tokenHandles; _refreshTokens = refreshTokens; _events = events; }
public TokenRequestValidator(CoreSettings settings, IAuthorizationCodeStore authorizationCodes, IRefreshTokenStore refreshTokens, IUserService users, IScopeService scopes, IAssertionGrantValidator assertionValidator, ICustomRequestValidator customRequestValidator) { _settings = settings; _authorizationCodes = authorizationCodes; _refreshTokens = refreshTokens; _users = users; _scopes = scopes; _assertionValidator = assertionValidator; _customRequestValidator = customRequestValidator; }
public TokenRequestValidator(IdentityServerOptions options, IAuthorizationCodeStore authorizationCodes, IRefreshTokenStore refreshTokens, IUserService users, IScopeStore scopes, IAssertionGrantValidator assertionValidator, ICustomRequestValidator customRequestValidator) { _options = options; _authorizationCodes = authorizationCodes; _refreshTokens = refreshTokens; _users = users; _scopes = scopes; _assertionValidator = assertionValidator; _customRequestValidator = customRequestValidator; }
public TokenRequestValidator(IdentityServerOptions options, IAuthorizationCodeStore authorizationCodes, IRefreshTokenStore refreshTokens, IUserService users, CustomGrantValidator customGrantValidator, ICustomRequestValidator customRequestValidator, ScopeValidator scopeValidator, IEventService events) { _options = options; _authorizationCodes = authorizationCodes; _refreshTokens = refreshTokens; _users = users; _customGrantValidator = customGrantValidator; _customRequestValidator = customRequestValidator; _scopeValidator = scopeValidator; _events = events; }
public TokenRequestValidator(IdentityServerOptions options, IAuthorizationCodeStore authorizationCodes, IRefreshTokenStore refreshTokens, IUserService users, IScopeStore scopes, ICustomGrantValidator customGrantValidator, ICustomRequestValidator customRequestValidator, ScopeValidator scopeValidator, IOwinContext context) { _options = options; _authorizationCodes = authorizationCodes; _refreshTokens = refreshTokens; _users = users; _scopes = scopes; _customGrantValidator = customGrantValidator; _customRequestValidator = customRequestValidator; _scopeValidator = scopeValidator; _environment = context.Environment; }
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 static TokenRequestValidator CreateTokenValidator( CoreSettings settings = null, IScopeService scopes = null, IAuthorizationCodeStore authorizationCodeStore = null, IRefreshTokenStore refreshTokens = null, IUserService userService = null, IAssertionGrantValidator assertionGrantValidator = null, ICustomRequestValidator customRequestValidator = null) { if (settings == null) { settings = new TestSettings(); } if (scopes == null) { scopes = new InMemoryScopeService(TestScopes.Get()); } if (userService == null) { userService = new TestUserService(); } if (customRequestValidator == null) { customRequestValidator = new DefaultCustomRequestValidator(); } if (assertionGrantValidator == null) { assertionGrantValidator = new TestAssertionValidator(); } if (refreshTokens == null) { refreshTokens = new InMemoryRefreshTokenStore(); } return new TokenRequestValidator(settings, authorizationCodeStore, refreshTokens, userService, scopes, assertionGrantValidator, customRequestValidator); }
public static TokenRequestValidator CreateTokenValidator( IdentityServerOptions options = null, IScopeStore scopes = null, IAuthorizationCodeStore authorizationCodeStore = null, IRefreshTokenStore refreshTokens = null, IUserService userService = null, IAssertionGrantValidator assertionGrantValidator = null, ICustomRequestValidator customRequestValidator = null) { if (options == null) { options = Thinktecture.IdentityServer.Tests.TestIdentityServerOptions.Create(); } if (scopes == null) { scopes = new InMemoryScopeStore(TestScopes.Get()); } if (userService == null) { userService = new TestUserService(); } if (customRequestValidator == null) { customRequestValidator = new DefaultCustomRequestValidator(); } if (assertionGrantValidator == null) { assertionGrantValidator = new TestAssertionValidator(); } if (refreshTokens == null) { refreshTokens = new InMemoryRefreshTokenStore(); } return new TokenRequestValidator(options, authorizationCodeStore, refreshTokens, userService, scopes, assertionGrantValidator, customRequestValidator); }
public void Setup() { mFactory = new Factory(new DefaultModuleConfiguration(), new ITModuleConfiguration()); mObserver = (RecordingObserver)mFactory.Build<IMessageObserver>(); mApp = mFactory.Build<IApp>(); mFile = new DotNetFile(); mRefreshToken = new RefreshTokenStore(mFile, "refreshToken.txt"); mCredentials = new CredentialStore(mFile, "credentials.txt"); var provider = new TestConfigurationProvider(); provider.SetupCredentialsFile(); provider.SetupRefreshTokenFile(); provider.SetupDummyFile(); mFileManager = new GDriveFileManager(mCredentials.Get(), mRefreshToken.Get()); new Retry(30, 125) .WithWork(x => { mFileManager.CleanGDriveAcct(); Assert.That(mFileManager.ListAllFilesOnRootById().ToArray(), Is.Empty); }) .Start(); mFolderManager = new FolderManager(mCredentials.Get(), mRefreshToken.Get()); }
/// <summary> /// Initializes a new instance of the <see cref="DefaultRefreshTokenService" /> class. /// </summary> /// <param name="store">The refresh token store.</param> /// <param name="events">The events.</param> public DefaultRefreshTokenService(IRefreshTokenStore store, IEventService events, ILoggerFactory loggerFactory) { _logger = loggerFactory.CreateLogger<DefaultRefreshTokenService>(); _store = store; _events = events; }
/// <summary> /// Initializes a new instance of the <see cref="DefaultRefreshTokenService"/> class. /// </summary> /// <param name="store">The refresh token store.</param> public DefaultRefreshTokenService(IRefreshTokenStore store) { _store = store; }
/// <summary> /// Initializes a new instance of the <see cref="DefaultRefreshTokenService" /> class. /// </summary> /// <param name="store">The refresh token store.</param> /// <param name="events">The events.</param> public DefaultRefreshTokenService(IRefreshTokenStore store, IEventService events) { _store = store; _events = events; }
private async Task<ValidatedTokenRequest> CreateValidatedRequest(Client client, IRefreshTokenStore store) { var refreshToken = new RefreshToken { AccessToken = new Token("access_token"), ClientId = client.ClientId, LifeTime = 600, CreationTime = DateTime.UtcNow }; var handle = Guid.NewGuid().ToString(); await store.StoreAsync(handle, refreshToken); var validator = Factory.CreateTokenRequestValidator( refreshTokens: store); var parameters = new NameValueCollection(); parameters.Add(Constants.TokenRequest.GrantType, "refresh_token"); parameters.Add(Constants.TokenRequest.RefreshToken, handle); var result = await validator.ValidateRequestAsync(parameters, client); result.IsError.Should().BeFalse(); return validator.ValidatedRequest; }
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()); }
public DefaultRefreshTokenServiceTests() { originalNowFunc = DateTimeOffsetHelper.UtcNowFunc; DateTimeOffsetHelper.UtcNowFunc = () => UtcNow; roclient_absolute_refresh_expiration_one_time_only = new Client { ClientName = "Resource Owner Client", Enabled = true, ClientId = "roclient_absolute_refresh_expiration_one_time_only", ClientSecrets = new List<Secret> { new Secret("secret".Sha256()) }, Flow = Flows.ResourceOwner, RefreshTokenExpiration = TokenExpiration.Absolute, RefreshTokenUsage = TokenUsage.OneTimeOnly, AbsoluteRefreshTokenLifetime = 200 }; roclient_sliding_refresh_expiration_one_time_only = new Client { ClientName = "Resource Owner Client", Enabled = true, ClientId = "roclient_sliding_refresh_expiration_one_time_only", ClientSecrets = new List<Secret> { new Secret("secret".Sha256()) }, Flow = Flows.ResourceOwner, RefreshTokenExpiration = TokenExpiration.Sliding, RefreshTokenUsage = TokenUsage.OneTimeOnly, AbsoluteRefreshTokenLifetime = 10, SlidingRefreshTokenLifetime = 4 }; roclient_absolute_refresh_expiration_reuse = new Client { ClientName = "Resource Owner Client", Enabled = true, ClientId = "roclient_absolute_refresh_expiration_reuse", ClientSecrets = new List<Secret> { new Secret("secret".Sha256()) }, Flow = Flows.ResourceOwner, RefreshTokenExpiration = TokenExpiration.Absolute, RefreshTokenUsage = TokenUsage.ReUse, AbsoluteRefreshTokenLifetime = 200 }; refreshTokenStore = new InMemoryRefreshTokenStore(); service = new DefaultRefreshTokenService(refreshTokenStore, new DefaultEventService()); user = IdentityServerPrincipal.Create("bob", "Bob Loblaw"); }
public TokenRevocationRequestValidator(ITokenHandleStore tokenHandles, IRefreshTokenStore refreshTokens) { _tokenHandles = tokenHandles; _refreshTokens = refreshTokens; }