public async Task CanAddUpdateAndDeleteConsents() { using( var db = new OperationalDbContext(OperationalConnectionStringName) ) { db.Consents.Add(new Consent { ClientId = "test-client", Subject = "test-consent-subject", Scopes = "foo", }); await db.SaveChangesAsync(); } using( var db = new OperationalDbContext(OperationalConnectionStringName) ) { var consent = await db.Consents.FirstAsync(t => t.Subject == "test-consent-subject"); Assert.Equal("foo", consent.Scopes); consent.Scopes += ",bar"; await db.SaveChangesAsync(); } using( var db = new OperationalDbContext(OperationalConnectionStringName) ) { var consent = await db.Consents.FirstAsync(t => t.Subject == "test-consent-subject"); Assert.Equal("foo,bar", consent.Scopes); db.Consents.Remove(consent); await db.SaveChangesAsync(); } using( var db = new OperationalDbContext(OperationalConnectionStringName) ) { var consent = await db.Consents.FirstOrDefaultAsync(t => t.Subject == "test-consent-subject"); Assert.Null(consent); } }
public async Task CanAddAndDeleteTokens() { using( var db = new OperationalDbContext(OperationalConnectionStringName) ) { db.Tokens.Add(new Token { ClientId = "test-client", SubjectId = "test-token-subject", Key = "token-key", TokenType = IdentityServer3.EntityFramework.Entities.TokenType.AuthorizationCode, JsonCode = "{\"json\":\"fake\"}", }); await db.SaveChangesAsync(); } using( var db = new OperationalDbContext(OperationalConnectionStringName) ) { var token = await db.Tokens.FirstAsync(t => t.SubjectId == "test-token-subject"); Assert.Equal("token-key", token.Key); db.Tokens.Remove(token); await db.SaveChangesAsync(); } using( var db = new OperationalDbContext(OperationalConnectionStringName) ) { var token = await db.Tokens.FirstOrDefaultAsync(t => t.SubjectId == "test-token-subject"); Assert.Null(token); } }
public ConsentStore(OperationalDbContext context) { if (context == null) { throw new ArgumentNullException("context"); } this.context = context; }
protected BaseTokenStore(OperationalDbContext context, TokenType tokenType, IScopeStore scopeStore, IClientStore clientStore) { if (context == null) { throw new ArgumentNullException("context"); } if (scopeStore == null) { throw new ArgumentNullException("scopeStore"); } if (clientStore == null) { throw new ArgumentNullException("clientStore"); } this.context = context; this.tokenType = tokenType; this.scopeStore = scopeStore; this.clientStore = clientStore; }
private async Task ClearTokens() { try { Logger.Info("Clearing tokens"); using (var db = new OperationalDbContext(this.options.ConnectionString, this.options.Schema)) { var query = from token in db.Tokens where token.Expiry < DateTimeOffset.UtcNow select token; db.Tokens.RemoveRange(query); await db.SaveChangesAsync(); } } catch (Exception ex) { Logger.ErrorException("Exception cleanring tokens", ex); } }
public AuthorizationCodeStore(OperationalDbContext context, IScopeStore scopeStore, IClientStore clientStore) : base(context, TokenType.AuthorizationCode, scopeStore, clientStore) { }
private async Task ClearTokens() { try { Logger.Info("Clearing tokens"); using (var db = new OperationalDbContext(this.options.ConnectionString, this.options.Schema)) { var query = from token in db.Tokens where token.Expiry < DateTimeOffset.UtcNow select token; db.Tokens.RemoveRange(query); await db.SaveChangesAsync(); } } catch(Exception ex) { Logger.ErrorException("Exception cleanring tokens", ex); } }
public RefreshTokenStore(OperationalDbContext context, IScopeStore scopeStore, IClientStore clientStore) : base(context, TokenType.RefreshToken, scopeStore, clientStore) { }
public TokenHandleStore(OperationalDbContext context, IScopeStore scopeStore, IClientStore clientStore) : base(context, Entities.TokenType.TokenHandle, scopeStore, clientStore) { }
public ConsentStore(OperationalDbContext context) { if (context == null) throw new ArgumentNullException("context"); this.context = context; }