|
|
@ -47,37 +47,29 @@ public class MongoOpenIddictTokenRepository : MongoDbRepository<OpenIddictMongoD |
|
|
await DeleteManyAsync(tokens, autoSave, GetCancellationToken(cancellationToken)); |
|
|
await DeleteManyAsync(tokens, autoSave, GetCancellationToken(cancellationToken)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public virtual async Task<List<OpenIddictToken>> FindAsync(string subject, Guid client, CancellationToken cancellationToken = default) |
|
|
public virtual async Task<List<OpenIddictToken>> FindAsync(string subject, Guid? client, string status, string type, CancellationToken cancellationToken = default) |
|
|
{ |
|
|
{ |
|
|
return await Queryable.Where((await GetMongoQueryableAsync(cancellationToken)), x => x.Subject == subject && x.ApplicationId == client) |
|
|
return await (await GetMongoQueryableAsync(cancellationToken)) |
|
|
.As<IMongoQueryable<OpenIddictToken>>() |
|
|
.WhereIf(!subject.IsNullOrWhiteSpace(), x => x.Subject == subject) |
|
|
.ToListAsync(GetCancellationToken(cancellationToken)); |
|
|
.WhereIf(client.HasValue, x => x.ApplicationId == client) |
|
|
} |
|
|
.WhereIf(!status.IsNullOrWhiteSpace(), x => x.Status == status) |
|
|
|
|
|
.WhereIf(!type.IsNullOrWhiteSpace(), x => x.Type == type) |
|
|
public virtual async Task<List<OpenIddictToken>> FindAsync(string subject, Guid client, string status, CancellationToken cancellationToken = default) |
|
|
|
|
|
{ |
|
|
|
|
|
return await Queryable.Where((await GetMongoQueryableAsync(GetCancellationToken(cancellationToken))), x => x.Subject == subject && x.ApplicationId == client && x.Status == status) |
|
|
|
|
|
.As<IMongoQueryable<OpenIddictToken>>() |
|
|
|
|
|
.ToListAsync(GetCancellationToken(cancellationToken)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public virtual async Task<List<OpenIddictToken>> FindAsync(string subject, Guid client, string status, string type, CancellationToken cancellationToken = default) |
|
|
|
|
|
{ |
|
|
|
|
|
return await Queryable.Where((await GetMongoQueryableAsync(GetCancellationToken(cancellationToken))), x => x.Subject == subject && x.ApplicationId == client && x.Status == status && x.Type == type) |
|
|
|
|
|
.As<IMongoQueryable<OpenIddictToken>>() |
|
|
.As<IMongoQueryable<OpenIddictToken>>() |
|
|
.ToListAsync(GetCancellationToken(cancellationToken)); |
|
|
.ToListAsync(GetCancellationToken(cancellationToken)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public virtual async Task<List<OpenIddictToken>> FindByApplicationIdAsync(Guid applicationId, CancellationToken cancellationToken = default) |
|
|
public virtual async Task<List<OpenIddictToken>> FindByApplicationIdAsync(Guid applicationId, CancellationToken cancellationToken = default) |
|
|
{ |
|
|
{ |
|
|
return await Queryable.Where((await GetMongoQueryableAsync(GetCancellationToken(cancellationToken))), x => x.ApplicationId == applicationId) |
|
|
return await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken))) |
|
|
|
|
|
.Where(x => x.ApplicationId == applicationId) |
|
|
.As<IMongoQueryable<OpenIddictToken>>() |
|
|
.As<IMongoQueryable<OpenIddictToken>>() |
|
|
.ToListAsync(GetCancellationToken(cancellationToken)); |
|
|
.ToListAsync(GetCancellationToken(cancellationToken)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public virtual async Task<List<OpenIddictToken>> FindByAuthorizationIdAsync(Guid authorizationId, CancellationToken cancellationToken = default) |
|
|
public virtual async Task<List<OpenIddictToken>> FindByAuthorizationIdAsync(Guid authorizationId, CancellationToken cancellationToken = default) |
|
|
{ |
|
|
{ |
|
|
return await Queryable.Where((await GetMongoQueryableAsync(GetCancellationToken(cancellationToken))), x => x.AuthorizationId == authorizationId) |
|
|
return await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken))) |
|
|
|
|
|
.Where(x => x.AuthorizationId == authorizationId) |
|
|
.As<IMongoQueryable<OpenIddictToken>>() |
|
|
.As<IMongoQueryable<OpenIddictToken>>() |
|
|
.ToListAsync(GetCancellationToken(cancellationToken)); |
|
|
.ToListAsync(GetCancellationToken(cancellationToken)); |
|
|
} |
|
|
} |
|
|
@ -94,14 +86,16 @@ public class MongoOpenIddictTokenRepository : MongoDbRepository<OpenIddictMongoD |
|
|
|
|
|
|
|
|
public virtual async Task<List<OpenIddictToken>> FindBySubjectAsync(string subject, CancellationToken cancellationToken = default) |
|
|
public virtual async Task<List<OpenIddictToken>> FindBySubjectAsync(string subject, CancellationToken cancellationToken = default) |
|
|
{ |
|
|
{ |
|
|
return await Queryable.Where((await GetMongoQueryableAsync(GetCancellationToken(cancellationToken))), x => x.Subject == subject) |
|
|
return await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken))) |
|
|
|
|
|
.Where(x => x.Subject == subject) |
|
|
.As<IMongoQueryable<OpenIddictToken>>() |
|
|
.As<IMongoQueryable<OpenIddictToken>>() |
|
|
.ToListAsync(GetCancellationToken(cancellationToken)); |
|
|
.ToListAsync(GetCancellationToken(cancellationToken)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public virtual async Task<List<OpenIddictToken>> ListAsync(int? count, int? offset, CancellationToken cancellationToken = default) |
|
|
public virtual async Task<List<OpenIddictToken>> ListAsync(int? count, int? offset, CancellationToken cancellationToken = default) |
|
|
{ |
|
|
{ |
|
|
return await Queryable.OrderBy((await GetMongoQueryableAsync(GetCancellationToken(cancellationToken))), x => x.Id) |
|
|
return await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken))) |
|
|
|
|
|
.OrderBy(x => x.Id) |
|
|
.SkipIf<OpenIddictToken, IQueryable<OpenIddictToken>>(offset.HasValue, offset) |
|
|
.SkipIf<OpenIddictToken, IQueryable<OpenIddictToken>>(offset.HasValue, offset) |
|
|
.TakeIf<OpenIddictToken, IQueryable<OpenIddictToken>>(count.HasValue, count) |
|
|
.TakeIf<OpenIddictToken, IQueryable<OpenIddictToken>>(count.HasValue, count) |
|
|
.As<IMongoQueryable<OpenIddictToken>>() |
|
|
.As<IMongoQueryable<OpenIddictToken>>() |
|
|
@ -129,6 +123,37 @@ public class MongoOpenIddictTokenRepository : MongoDbRepository<OpenIddictMongoD |
|
|
return tokens.Count; |
|
|
return tokens.Count; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public virtual async ValueTask<long> RevokeAsync(string subject, Guid? applicationId, string status, string type, CancellationToken cancellationToken = default) |
|
|
|
|
|
{ |
|
|
|
|
|
var filter = Builders<OpenIddictToken>.Filter.Empty; |
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(subject)) |
|
|
|
|
|
{ |
|
|
|
|
|
filter &= Builders<OpenIddictToken>.Filter.Where(authorization => authorization.Subject == subject); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (applicationId.HasValue) |
|
|
|
|
|
{ |
|
|
|
|
|
filter &= Builders<OpenIddictToken>.Filter.Where(authorization => authorization.ApplicationId == applicationId); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(status)) |
|
|
|
|
|
{ |
|
|
|
|
|
filter &= Builders<OpenIddictToken>.Filter.Where(authorization => authorization.Status == status); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(type)) |
|
|
|
|
|
{ |
|
|
|
|
|
filter &= Builders<OpenIddictToken>.Filter.Where(authorization => authorization.Type == type); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return (await (await GetCollectionAsync(cancellationToken)).UpdateManyAsync( |
|
|
|
|
|
filter : filter, |
|
|
|
|
|
update : Builders<OpenIddictToken>.Update.Set(authorization => authorization.Status, OpenIddictConstants.Statuses.Revoked), |
|
|
|
|
|
options : null, |
|
|
|
|
|
cancellationToken: cancellationToken)).MatchedCount; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public virtual async ValueTask<long> RevokeByAuthorizationIdAsync(Guid id, CancellationToken cancellationToken) |
|
|
public virtual async ValueTask<long> RevokeByAuthorizationIdAsync(Guid id, CancellationToken cancellationToken) |
|
|
{ |
|
|
{ |
|
|
return (await (await GetCollectionAsync(GetCancellationToken(cancellationToken))).UpdateManyAsync( |
|
|
return (await (await GetCollectionAsync(GetCancellationToken(cancellationToken))).UpdateManyAsync( |
|
|
|