mirror of
https://github.com/bitwarden/server
synced 2025-12-10 05:13:48 +00:00
Return grantor policy info in TakeoverResponse
This commit is contained in:
@@ -136,8 +136,8 @@ namespace Bit.Api.Controllers
|
|||||||
public async Task<EmergencyAccessTakeoverResponseModel> Takeover(string id)
|
public async Task<EmergencyAccessTakeoverResponseModel> Takeover(string id)
|
||||||
{
|
{
|
||||||
var user = await _userService.GetUserByPrincipalAsync(User);
|
var user = await _userService.GetUserByPrincipalAsync(User);
|
||||||
var (result, grantor) = await _emergencyAccessService.TakeoverAsync(new Guid(id), user);
|
var (result, grantor, policy) = await _emergencyAccessService.TakeoverAsync(new Guid(id), user);
|
||||||
return new EmergencyAccessTakeoverResponseModel(result, grantor);
|
return new EmergencyAccessTakeoverResponseModel(result, grantor, policy);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("{id}/password")]
|
[HttpPost("{id}/password")]
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ namespace Bit.Core.Models.Api.Response
|
|||||||
|
|
||||||
public class EmergencyAccessTakeoverResponseModel : ResponseModel
|
public class EmergencyAccessTakeoverResponseModel : ResponseModel
|
||||||
{
|
{
|
||||||
public EmergencyAccessTakeoverResponseModel(EmergencyAccess emergencyAccess, User grantor, string obj = "emergencyAccessTakeover") : base(obj)
|
public EmergencyAccessTakeoverResponseModel(EmergencyAccess emergencyAccess, User grantor, ICollection<Policy> policy, string obj = "emergencyAccessTakeover") : base(obj)
|
||||||
{
|
{
|
||||||
if (emergencyAccess == null)
|
if (emergencyAccess == null)
|
||||||
{
|
{
|
||||||
@@ -94,11 +94,13 @@ namespace Bit.Core.Models.Api.Response
|
|||||||
KeyEncrypted = emergencyAccess.KeyEncrypted;
|
KeyEncrypted = emergencyAccess.KeyEncrypted;
|
||||||
Kdf = grantor.Kdf;
|
Kdf = grantor.Kdf;
|
||||||
KdfIterations = grantor.KdfIterations;
|
KdfIterations = grantor.KdfIterations;
|
||||||
|
Policy = policy.Select<Policy, PolicyResponseModel>(policy => new PolicyResponseModel(policy));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int KdfIterations { get; private set; }
|
public int KdfIterations { get; private set; }
|
||||||
public KdfType Kdf { get; private set; }
|
public KdfType Kdf { get; private set; }
|
||||||
public string KeyEncrypted { get; private set; }
|
public string KeyEncrypted { get; private set; }
|
||||||
|
public IEnumerable<PolicyResponseModel> Policy { get; private set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class EmergencyAccessViewResponseModel : ResponseModel
|
public class EmergencyAccessViewResponseModel : ResponseModel
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Bit.Core.Enums;
|
using Bit.Core.Enums;
|
||||||
using Bit.Core.Models.Api.Response;
|
using Bit.Core.Models.Api.Response;
|
||||||
@@ -19,7 +20,7 @@ namespace Bit.Core.Services
|
|||||||
Task InitiateAsync(Guid id, User initiatingUser);
|
Task InitiateAsync(Guid id, User initiatingUser);
|
||||||
Task ApproveAsync(Guid id, User approvingUser);
|
Task ApproveAsync(Guid id, User approvingUser);
|
||||||
Task RejectAsync(Guid id, User rejectingUser);
|
Task RejectAsync(Guid id, User rejectingUser);
|
||||||
Task<(EmergencyAccess, User)> TakeoverAsync(Guid id, User initiatingUser);
|
Task<(EmergencyAccess, User, ICollection<Policy>)> TakeoverAsync(Guid id, User initiatingUser);
|
||||||
Task PasswordAsync(Guid id, User user, string newMasterPasswordHash, string key);
|
Task PasswordAsync(Guid id, User user, string newMasterPasswordHash, string key);
|
||||||
Task SendNotificationsAsync();
|
Task SendNotificationsAsync();
|
||||||
Task HandleTimedOutRequestsAsync();
|
Task HandleTimedOutRequestsAsync();
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ namespace Bit.Core.Services
|
|||||||
private readonly IOrganizationUserRepository _organizationUserRepository;
|
private readonly IOrganizationUserRepository _organizationUserRepository;
|
||||||
private readonly IUserRepository _userRepository;
|
private readonly IUserRepository _userRepository;
|
||||||
private readonly ICipherRepository _cipherRepository;
|
private readonly ICipherRepository _cipherRepository;
|
||||||
|
private readonly IPolicyRepository _policyRepository;
|
||||||
private readonly IMailService _mailService;
|
private readonly IMailService _mailService;
|
||||||
private readonly IUserService _userService;
|
private readonly IUserService _userService;
|
||||||
private readonly IDataProtector _dataProtector;
|
private readonly IDataProtector _dataProtector;
|
||||||
@@ -32,6 +33,7 @@ namespace Bit.Core.Services
|
|||||||
IOrganizationUserRepository organizationUserRepository,
|
IOrganizationUserRepository organizationUserRepository,
|
||||||
IUserRepository userRepository,
|
IUserRepository userRepository,
|
||||||
ICipherRepository cipherRepository,
|
ICipherRepository cipherRepository,
|
||||||
|
IPolicyRepository policyRepository,
|
||||||
IMailService mailService,
|
IMailService mailService,
|
||||||
IUserService userService,
|
IUserService userService,
|
||||||
IPasswordHasher<User> passwordHasher,
|
IPasswordHasher<User> passwordHasher,
|
||||||
@@ -43,6 +45,7 @@ namespace Bit.Core.Services
|
|||||||
_organizationUserRepository = organizationUserRepository;
|
_organizationUserRepository = organizationUserRepository;
|
||||||
_userRepository = userRepository;
|
_userRepository = userRepository;
|
||||||
_cipherRepository = cipherRepository;
|
_cipherRepository = cipherRepository;
|
||||||
|
_policyRepository = policyRepository;
|
||||||
_mailService = mailService;
|
_mailService = mailService;
|
||||||
_userService = userService;
|
_userService = userService;
|
||||||
_passwordHasher = passwordHasher;
|
_passwordHasher = passwordHasher;
|
||||||
@@ -235,7 +238,7 @@ namespace Bit.Core.Services
|
|||||||
await _mailService.SendEmergencyAccessRecoveryRejected(emergencyAccess, NameOrEmail(rejectingUser), grantee.Email);
|
await _mailService.SendEmergencyAccessRecoveryRejected(emergencyAccess, NameOrEmail(rejectingUser), grantee.Email);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<(EmergencyAccess, User)> TakeoverAsync(Guid id, User requestingUser)
|
public async Task<(EmergencyAccess, User, ICollection<Policy>)> TakeoverAsync(Guid id, User requestingUser)
|
||||||
{
|
{
|
||||||
var emergencyAccess = await _emergencyAccessRepository.GetByIdAsync(id);
|
var emergencyAccess = await _emergencyAccessRepository.GetByIdAsync(id);
|
||||||
|
|
||||||
@@ -246,8 +249,9 @@ namespace Bit.Core.Services
|
|||||||
}
|
}
|
||||||
|
|
||||||
var grantor = await _userRepository.GetByIdAsync(emergencyAccess.GrantorId);
|
var grantor = await _userRepository.GetByIdAsync(emergencyAccess.GrantorId);
|
||||||
|
var policy = await _policyRepository.GetManyByUserIdAsync(grantor.Id);
|
||||||
|
|
||||||
return (emergencyAccess, grantor);
|
return (emergencyAccess, grantor, policy);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task PasswordAsync(Guid id, User requestingUser, string newMasterPasswordHash, string key)
|
public async Task PasswordAsync(Guid id, User requestingUser, string newMasterPasswordHash, string key)
|
||||||
|
|||||||
Reference in New Issue
Block a user