mirror of
https://github.com/bitwarden/server
synced 2026-01-06 18:43:36 +00:00
[SM-910] Add service account granted policies management endpoints (#3736)
* Add the ability to get multi projects access * Add access policy helper + tests * Add new data/request models * Add access policy operations to repo * Add authz handler for new operations * Add new controller endpoints * add updating service account revision
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
#nullable enable
|
||||
using Bit.Api.SecretsManager.Utilities;
|
||||
using Bit.Core.SecretsManager.Entities;
|
||||
using Bit.Core.SecretsManager.Models.Data;
|
||||
|
||||
namespace Bit.Api.SecretsManager.Models.Request;
|
||||
|
||||
public class ServiceAccountGrantedPoliciesRequestModel
|
||||
{
|
||||
public required IEnumerable<GrantedAccessPolicyRequest> ProjectGrantedPolicyRequests { get; set; }
|
||||
|
||||
public ServiceAccountGrantedPolicies ToGrantedPolicies(ServiceAccount serviceAccount)
|
||||
{
|
||||
var projectGrantedPolicies = ProjectGrantedPolicyRequests
|
||||
.Select(x => x.ToServiceAccountProjectAccessPolicy(serviceAccount.Id, serviceAccount.OrganizationId))
|
||||
.ToList();
|
||||
|
||||
AccessPolicyHelpers.CheckForDistinctAccessPolicies(projectGrantedPolicies);
|
||||
AccessPolicyHelpers.CheckAccessPoliciesHaveReadPermission(projectGrantedPolicies);
|
||||
|
||||
return new ServiceAccountGrantedPolicies
|
||||
{
|
||||
ServiceAccountId = serviceAccount.Id,
|
||||
OrganizationId = serviceAccount.OrganizationId,
|
||||
ProjectGrantedPolicies = projectGrantedPolicies
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user