diff --git a/backend/extensions/Squidex.Extensions/Squidex.Extensions.csproj b/backend/extensions/Squidex.Extensions/Squidex.Extensions.csproj index 45cd0db46..462397210 100644 --- a/backend/extensions/Squidex.Extensions/Squidex.Extensions.csproj +++ b/backend/extensions/Squidex.Extensions/Squidex.Extensions.csproj @@ -8,15 +8,15 @@ - + - + - - - - + + + + diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Squidex.Domain.Apps.Core.Model.csproj b/backend/src/Squidex.Domain.Apps.Core.Model/Squidex.Domain.Apps.Core.Model.csproj index 6be87fc8b..fe37e1d0a 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Squidex.Domain.Apps.Core.Model.csproj +++ b/backend/src/Squidex.Domain.Apps.Core.Model/Squidex.Domain.Apps.Core.Model.csproj @@ -10,12 +10,12 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/Squidex.Domain.Apps.Core.Operations.csproj b/backend/src/Squidex.Domain.Apps.Core.Operations/Squidex.Domain.Apps.Core.Operations.csproj index 012ce054e..7343aeecf 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/Squidex.Domain.Apps.Core.Operations.csproj +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/Squidex.Domain.Apps.Core.Operations.csproj @@ -18,11 +18,11 @@ - - - - - + + + + + diff --git a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Squidex.Domain.Apps.Entities.MongoDb.csproj b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Squidex.Domain.Apps.Entities.MongoDb.csproj index 6006e9d5e..d62b093fc 100644 --- a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Squidex.Domain.Apps.Entities.MongoDb.csproj +++ b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Squidex.Domain.Apps.Entities.MongoDb.csproj @@ -17,7 +17,7 @@ - + diff --git a/backend/src/Squidex.Domain.Apps.Entities/Squidex.Domain.Apps.Entities.csproj b/backend/src/Squidex.Domain.Apps.Entities/Squidex.Domain.Apps.Entities.csproj index ca915e201..34b9440cf 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Squidex.Domain.Apps.Entities.csproj +++ b/backend/src/Squidex.Domain.Apps.Entities/Squidex.Domain.Apps.Entities.csproj @@ -18,9 +18,9 @@ - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -29,12 +29,12 @@ - - + + all runtime; build; native; contentfiles; analyzers - + diff --git a/backend/src/Squidex.Domain.Users.MongoDb/Infrastructure/MongoPersistedGrantStore.cs b/backend/src/Squidex.Domain.Users.MongoDb/Infrastructure/MongoPersistedGrantStore.cs index 928d6a732..541e71345 100644 --- a/backend/src/Squidex.Domain.Users.MongoDb/Infrastructure/MongoPersistedGrantStore.cs +++ b/backend/src/Squidex.Domain.Users.MongoDb/Infrastructure/MongoPersistedGrantStore.cs @@ -10,6 +10,7 @@ using System.Threading; using System.Threading.Tasks; using IdentityServer4.Models; using IdentityServer4.Stores; +using MongoDB.Bson; using MongoDB.Bson.Serialization; using MongoDB.Driver; using Squidex.Infrastructure.MongoDb; @@ -52,9 +53,9 @@ namespace Squidex.Domain.Users.MongoDb.Infrastructure return await Collection.Find(x => x.SubjectId == subjectId).ToListAsync(); } - public Task StoreAsync(PersistedGrant grant) + public async Task> GetAllAsync(PersistedGrantFilter filter) { - return Collection.ReplaceOneAsync(x => x.Key == grant.Key, grant, UpsertReplace); + return await Collection.Find(CreateFilter(filter)).ToListAsync(); } public Task GetAsync(string key) @@ -62,19 +63,51 @@ namespace Squidex.Domain.Users.MongoDb.Infrastructure return Collection.Find(x => x.Key == key).FirstOrDefaultAsync(); } - public Task RemoveAllAsync(string subjectId, string clientId, string type) + public Task RemoveAllAsync(PersistedGrantFilter filter) { - return Collection.DeleteManyAsync(x => x.SubjectId == subjectId && x.ClientId == clientId && x.Type == type); + return Collection.DeleteManyAsync(CreateFilter(filter)); } - public Task RemoveAllAsync(string subjectId, string clientId) + public Task RemoveAsync(string key) { - return Collection.DeleteManyAsync(x => x.SubjectId == subjectId && x.ClientId == clientId); + return Collection.DeleteManyAsync(x => x.Key == key); } - public Task RemoveAsync(string key) + public Task StoreAsync(PersistedGrant grant) { - return Collection.DeleteManyAsync(x => x.Key == key); + return Collection.ReplaceOneAsync(x => x.Key == grant.Key, grant, UpsertReplace); + } + + private static FilterDefinition CreateFilter(PersistedGrantFilter filter) + { + var filters = new List>(); + + if (!string.IsNullOrWhiteSpace(filter.ClientId)) + { + filters.Add(Filter.Eq(x => x.ClientId, filter.ClientId)); + } + + if (!string.IsNullOrWhiteSpace(filter.SessionId)) + { + filters.Add(Filter.Eq(x => x.SessionId, filter.SessionId)); + } + + if (!string.IsNullOrWhiteSpace(filter.SubjectId)) + { + filters.Add(Filter.Eq(x => x.SubjectId, filter.SubjectId)); + } + + if (!string.IsNullOrWhiteSpace(filter.Type)) + { + filters.Add(Filter.Eq(x => x.Type, filter.Type)); + } + + if (filters.Count > 0) + { + return Filter.And(filters); + } + + return new BsonDocument(); } } } diff --git a/backend/src/Squidex.Domain.Users.MongoDb/Squidex.Domain.Users.MongoDb.csproj b/backend/src/Squidex.Domain.Users.MongoDb/Squidex.Domain.Users.MongoDb.csproj index cf77ef86c..a003a467e 100644 --- a/backend/src/Squidex.Domain.Users.MongoDb/Squidex.Domain.Users.MongoDb.csproj +++ b/backend/src/Squidex.Domain.Users.MongoDb/Squidex.Domain.Users.MongoDb.csproj @@ -18,9 +18,9 @@ - + - + diff --git a/backend/src/Squidex.Domain.Users/Squidex.Domain.Users.csproj b/backend/src/Squidex.Domain.Users/Squidex.Domain.Users.csproj index 58056e58d..05367afb2 100644 --- a/backend/src/Squidex.Domain.Users/Squidex.Domain.Users.csproj +++ b/backend/src/Squidex.Domain.Users/Squidex.Domain.Users.csproj @@ -16,7 +16,7 @@ - + diff --git a/backend/src/Squidex.Infrastructure.Amazon/Squidex.Infrastructure.Amazon.csproj b/backend/src/Squidex.Infrastructure.Amazon/Squidex.Infrastructure.Amazon.csproj index 01c22cc6c..cccb4d123 100644 --- a/backend/src/Squidex.Infrastructure.Amazon/Squidex.Infrastructure.Amazon.csproj +++ b/backend/src/Squidex.Infrastructure.Amazon/Squidex.Infrastructure.Amazon.csproj @@ -6,7 +6,7 @@ enable - + diff --git a/backend/src/Squidex.Infrastructure.Azure/Squidex.Infrastructure.Azure.csproj b/backend/src/Squidex.Infrastructure.Azure/Squidex.Infrastructure.Azure.csproj index d307693ad..bd1a4b57e 100644 --- a/backend/src/Squidex.Infrastructure.Azure/Squidex.Infrastructure.Azure.csproj +++ b/backend/src/Squidex.Infrastructure.Azure/Squidex.Infrastructure.Azure.csproj @@ -6,11 +6,11 @@ enable - - + + - + diff --git a/backend/src/Squidex.Infrastructure.GetEventStore/Squidex.Infrastructure.GetEventStore.csproj b/backend/src/Squidex.Infrastructure.GetEventStore/Squidex.Infrastructure.GetEventStore.csproj index 3de2c7e28..966d97a88 100644 --- a/backend/src/Squidex.Infrastructure.GetEventStore/Squidex.Infrastructure.GetEventStore.csproj +++ b/backend/src/Squidex.Infrastructure.GetEventStore/Squidex.Infrastructure.GetEventStore.csproj @@ -10,7 +10,7 @@ True - + diff --git a/backend/src/Squidex.Infrastructure.GoogleCloud/Squidex.Infrastructure.GoogleCloud.csproj b/backend/src/Squidex.Infrastructure.GoogleCloud/Squidex.Infrastructure.GoogleCloud.csproj index 2ad2ac049..e3c47f7d8 100644 --- a/backend/src/Squidex.Infrastructure.GoogleCloud/Squidex.Infrastructure.GoogleCloud.csproj +++ b/backend/src/Squidex.Infrastructure.GoogleCloud/Squidex.Infrastructure.GoogleCloud.csproj @@ -10,7 +10,7 @@ True - + diff --git a/backend/src/Squidex.Infrastructure.MongoDb/Squidex.Infrastructure.MongoDb.csproj b/backend/src/Squidex.Infrastructure.MongoDb/Squidex.Infrastructure.MongoDb.csproj index 898575b26..158864e4b 100644 --- a/backend/src/Squidex.Infrastructure.MongoDb/Squidex.Infrastructure.MongoDb.csproj +++ b/backend/src/Squidex.Infrastructure.MongoDb/Squidex.Infrastructure.MongoDb.csproj @@ -13,8 +13,8 @@ - - + + diff --git a/backend/src/Squidex.Infrastructure.RabbitMq/Squidex.Infrastructure.RabbitMq.csproj b/backend/src/Squidex.Infrastructure.RabbitMq/Squidex.Infrastructure.RabbitMq.csproj index c28abe580..b58f6ebc1 100644 --- a/backend/src/Squidex.Infrastructure.RabbitMq/Squidex.Infrastructure.RabbitMq.csproj +++ b/backend/src/Squidex.Infrastructure.RabbitMq/Squidex.Infrastructure.RabbitMq.csproj @@ -10,7 +10,7 @@ True - + diff --git a/backend/src/Squidex.Infrastructure/Squidex.Infrastructure.csproj b/backend/src/Squidex.Infrastructure/Squidex.Infrastructure.csproj index 94eb9a6bc..1975ca219 100644 --- a/backend/src/Squidex.Infrastructure/Squidex.Infrastructure.csproj +++ b/backend/src/Squidex.Infrastructure/Squidex.Infrastructure.csproj @@ -15,28 +15,28 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - + + + + + + + all runtime; build; native; contentfiles; analyzers - - + + - + - + diff --git a/backend/src/Squidex.Web/Squidex.Web.csproj b/backend/src/Squidex.Web/Squidex.Web.csproj index bf76eab04..3ab607cf2 100644 --- a/backend/src/Squidex.Web/Squidex.Web.csproj +++ b/backend/src/Squidex.Web/Squidex.Web.csproj @@ -12,7 +12,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/backend/src/Squidex/Areas/IdentityServer/Config/LazyClientStore.cs b/backend/src/Squidex/Areas/IdentityServer/Config/LazyClientStore.cs index ce23bffe7..ba177a4b4 100644 --- a/backend/src/Squidex/Areas/IdentityServer/Config/LazyClientStore.cs +++ b/backend/src/Squidex/Areas/IdentityServer/Config/LazyClientStore.cs @@ -109,9 +109,9 @@ namespace Squidex.Areas.IdentityServer.Config Constants.RoleScope, Constants.PermissionsScope }, - Claims = new List + Claims = new List { - new Claim(OpenIdClaims.Subject, user.Id) + new ClientClaim(OpenIdClaims.Subject, user.Id) } }; } @@ -228,9 +228,9 @@ namespace Squidex.Areas.IdentityServer.Config Constants.RoleScope, Constants.PermissionsScope }, - Claims = new List + Claims = new List { - new Claim(SquidexClaimTypes.Permissions, Permissions.All) + new ClientClaim(SquidexClaimTypes.Permissions, Permissions.All) } }; } diff --git a/backend/src/Squidex/Squidex.csproj b/backend/src/Squidex/Squidex.csproj index a3e297f9b..4610393aa 100644 --- a/backend/src/Squidex/Squidex.csproj +++ b/backend/src/Squidex/Squidex.csproj @@ -34,32 +34,32 @@ - + - + - - - - - + + + + + - - - - - - + + + + + + - - + + - - + + diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Squidex.Domain.Apps.Core.Tests.csproj b/backend/tests/Squidex.Domain.Apps.Core.Tests/Squidex.Domain.Apps.Core.Tests.csproj index c3dd4894b..5398e1d21 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Squidex.Domain.Apps.Core.Tests.csproj +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Squidex.Domain.Apps.Core.Tests.csproj @@ -12,16 +12,16 @@ - + - - - + + + - + all runtime; build; native; contentfiles; analyzers diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Squidex.Domain.Apps.Entities.Tests.csproj b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Squidex.Domain.Apps.Entities.Tests.csproj index 522befece..1eb997e60 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Squidex.Domain.Apps.Entities.Tests.csproj +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Squidex.Domain.Apps.Entities.Tests.csproj @@ -17,18 +17,18 @@ - + - - + + - + all runtime; build; native; contentfiles; analyzers diff --git a/backend/tests/Squidex.Domain.Users.Tests/Squidex.Domain.Users.Tests.csproj b/backend/tests/Squidex.Domain.Users.Tests/Squidex.Domain.Users.Tests.csproj index 759c3072f..7cb2c123f 100644 --- a/backend/tests/Squidex.Domain.Users.Tests/Squidex.Domain.Users.Tests.csproj +++ b/backend/tests/Squidex.Domain.Users.Tests/Squidex.Domain.Users.Tests.csproj @@ -13,14 +13,14 @@ - + - + - + all runtime; build; native; contentfiles; analyzers diff --git a/backend/tests/Squidex.Infrastructure.Tests/Squidex.Infrastructure.Tests.csproj b/backend/tests/Squidex.Infrastructure.Tests/Squidex.Infrastructure.Tests.csproj index b81681a8d..0a5e2ef1b 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/Squidex.Infrastructure.Tests.csproj +++ b/backend/tests/Squidex.Infrastructure.Tests/Squidex.Infrastructure.Tests.csproj @@ -20,13 +20,13 @@ - + - - - - - + + + + + all runtime; build; native; contentfiles; analyzers @@ -34,7 +34,7 @@ - + all runtime; build; native; contentfiles; analyzers diff --git a/backend/tests/Squidex.Web.Tests/Squidex.Web.Tests.csproj b/backend/tests/Squidex.Web.Tests/Squidex.Web.Tests.csproj index 411147f27..b0ad2ac0e 100644 --- a/backend/tests/Squidex.Web.Tests/Squidex.Web.Tests.csproj +++ b/backend/tests/Squidex.Web.Tests/Squidex.Web.Tests.csproj @@ -11,14 +11,14 @@ - - - - + + + + - + all runtime; build; native; contentfiles; analyzers