From 707347ce3e454af32838612e45246f6d56461c5d Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 8 Feb 2024 16:36:15 -0500 Subject: [PATCH] [PM-3570] Adjust refresh token lifetimes (#3697) * adjust refresh token lifetimes * fix broken grant delete * Update ApiClient.cs --------- Co-authored-by: Matt Bishop --- .../IdentityServer/StaticClientStore.cs | 4 ++-- .../Auth/Repositories/GrantRepository.cs | 19 ++++++------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/Identity/IdentityServer/StaticClientStore.cs b/src/Identity/IdentityServer/StaticClientStore.cs index 811880dde232..d589ab219e66 100644 --- a/src/Identity/IdentityServer/StaticClientStore.cs +++ b/src/Identity/IdentityServer/StaticClientStore.cs @@ -10,8 +10,8 @@ public StaticClientStore(GlobalSettings globalSettings) { ApiClients = new List { - new ApiClient(globalSettings, BitwardenClient.Mobile, 90, 1), - new ApiClient(globalSettings, BitwardenClient.Web, 30, 1), + new ApiClient(globalSettings, BitwardenClient.Mobile, 60, 1), + new ApiClient(globalSettings, BitwardenClient.Web, 7, 1), new ApiClient(globalSettings, BitwardenClient.Browser, 30, 1), new ApiClient(globalSettings, BitwardenClient.Desktop, 30, 1), new ApiClient(globalSettings, BitwardenClient.Cli, 30, 1), diff --git a/src/Infrastructure.EntityFramework/Auth/Repositories/GrantRepository.cs b/src/Infrastructure.EntityFramework/Auth/Repositories/GrantRepository.cs index f22384afbc5d..09fd46835b42 100644 --- a/src/Infrastructure.EntityFramework/Auth/Repositories/GrantRepository.cs +++ b/src/Infrastructure.EntityFramework/Auth/Repositories/GrantRepository.cs @@ -19,11 +19,7 @@ public async Task DeleteByKeyAsync(string key) using (var scope = ServiceScopeFactory.CreateScope()) { var dbContext = GetDatabaseContext(scope); - var query = from g in dbContext.Grants - where g.Key == key - select g; - dbContext.Remove(query); - await dbContext.SaveChangesAsync(); + await dbContext.Grants.Where(g => g.Key == key).ExecuteDeleteAsync(); } } @@ -32,14 +28,11 @@ public async Task DeleteManyAsync(string subjectId, string sessionId, string cli using (var scope = ServiceScopeFactory.CreateScope()) { var dbContext = GetDatabaseContext(scope); - var query = from g in dbContext.Grants - where g.SubjectId == subjectId && - g.ClientId == clientId && - g.SessionId == sessionId && - g.Type == type - select g; - dbContext.Remove(query); - await dbContext.SaveChangesAsync(); + await dbContext.Grants.Where(g => + g.SubjectId == subjectId && + g.ClientId == clientId && + g.SessionId == sessionId && + g.Type == type).ExecuteDeleteAsync(); } }