1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-20 10:58:07 -05:00
This commit is contained in:
Bernd Schoolmann 2025-06-05 15:37:39 +02:00
parent 442cc2e9cf
commit 25a812e762
No known key found for this signature in database

View File

@ -1,4 +1,5 @@
using Bit.Api.Models.Response; using Bit.Api.KeyManagement.Queries;
using Bit.Api.Models.Response;
using Bit.Api.Vault.Models.Response; using Bit.Api.Vault.Models.Response;
using Bit.Core; using Bit.Core;
using Bit.Core.AdminConsole.Entities; using Bit.Core.AdminConsole.Entities;
@ -9,8 +10,6 @@ using Bit.Core.Context;
using Bit.Core.Entities; using Bit.Core.Entities;
using Bit.Core.Enums; using Bit.Core.Enums;
using Bit.Core.Exceptions; using Bit.Core.Exceptions;
using Bit.Core.KeyManagement.Models.Data;
using Bit.Core.KeyManagement.Repositories;
using Bit.Core.Models.Data; using Bit.Core.Models.Data;
using Bit.Core.Repositories; using Bit.Core.Repositories;
using Bit.Core.Services; using Bit.Core.Services;
@ -42,7 +41,7 @@ public class SyncController : Controller
private readonly IFeatureService _featureService; private readonly IFeatureService _featureService;
private readonly IApplicationCacheService _applicationCacheService; private readonly IApplicationCacheService _applicationCacheService;
private readonly ITwoFactorIsEnabledQuery _twoFactorIsEnabledQuery; private readonly ITwoFactorIsEnabledQuery _twoFactorIsEnabledQuery;
private readonly IUserSignatureKeyPairRepository _userSignatureKeyPairRepository; private readonly IUserAccountKeysQuery _userAccountKeysQuery;
public SyncController( public SyncController(
IUserService userService, IUserService userService,
@ -59,7 +58,7 @@ public class SyncController : Controller
IFeatureService featureService, IFeatureService featureService,
IApplicationCacheService applicationCacheService, IApplicationCacheService applicationCacheService,
ITwoFactorIsEnabledQuery twoFactorIsEnabledQuery, ITwoFactorIsEnabledQuery twoFactorIsEnabledQuery,
IUserSignatureKeyPairRepository userSignatureKeyPairRepository) IUserAccountKeysQuery userAccountKeysQuery)
{ {
_userService = userService; _userService = userService;
_folderRepository = folderRepository; _folderRepository = folderRepository;
@ -75,7 +74,7 @@ public class SyncController : Controller
_featureService = featureService; _featureService = featureService;
_applicationCacheService = applicationCacheService; _applicationCacheService = applicationCacheService;
_twoFactorIsEnabledQuery = twoFactorIsEnabledQuery; _twoFactorIsEnabledQuery = twoFactorIsEnabledQuery;
_userSignatureKeyPairRepository = userSignatureKeyPairRepository; _userAccountKeysQuery = userAccountKeysQuery;
} }
[HttpGet("")] [HttpGet("")]
@ -118,13 +117,7 @@ public class SyncController : Controller
var organizationIdsClaimingActiveUser = organizationClaimingActiveUser.Select(o => o.Id); var organizationIdsClaimingActiveUser = organizationClaimingActiveUser.Select(o => o.Id);
var organizationAbilities = await _applicationCacheService.GetOrganizationAbilitiesAsync(); var organizationAbilities = await _applicationCacheService.GetOrganizationAbilitiesAsync();
var signingKeys = await _userSignatureKeyPairRepository.GetByUserIdAsync(user.Id); var accountKeys = new PrivateKeysResponseModel(await _userAccountKeysQuery.Run(user));
var userAccountKeysData = new UserAccountKeysData
{
PublicKeyEncryptionKeyPairData = user.GetPublicKeyEncryptionKeyPair(),
SignatureKeyPairData = signingKeys,
};
var accountKeys = new PrivateKeysResponseModel(userAccountKeysData);
var response = new SyncResponseModel(_globalSettings, user, accountKeys, userTwoFactorEnabled, userHasPremiumFromOrganization, organizationAbilities, var response = new SyncResponseModel(_globalSettings, user, accountKeys, userTwoFactorEnabled, userHasPremiumFromOrganization, organizationAbilities,
organizationIdsClaimingActiveUser, organizationUserDetails, providerUserDetails, providerUserOrganizationDetails, organizationIdsClaimingActiveUser, organizationUserDetails, providerUserDetails, providerUserOrganizationDetails,