1
0
mirror of https://github.com/bitwarden/server synced 2025-12-16 08:13:33 +00:00

[SM-707] Refactor authorization for Access Policy Commands (#2905)

* Extract authorization from access policy commands

* Use auto mapper to ignore unwanted properties

---------
This commit is contained in:
Thomas Avery
2023-07-13 11:46:01 -05:00
committed by GitHub
parent d6a45d4802
commit 1d9aeb37aa
19 changed files with 1732 additions and 1138 deletions

View File

@@ -1,5 +1,6 @@
using System.ComponentModel.DataAnnotations;
using Bit.Core.SecretsManager.Entities;
using Bit.Infrastructure.EntityFramework.SecretsManager.Models;
using ServiceAccountProjectAccessPolicy = Bit.Core.SecretsManager.Entities.ServiceAccountProjectAccessPolicy;
namespace Bit.Api.SecretsManager.Models.Request;
@@ -14,10 +15,11 @@ public class GrantedAccessPolicyRequest
[Required]
public bool Write { get; set; }
public ServiceAccountProjectAccessPolicy ToServiceAccountProjectAccessPolicy(Guid serviceAccountId) =>
public ServiceAccountProjectAccessPolicy ToServiceAccountProjectAccessPolicy(Guid serviceAccountId, Guid organizationId) =>
new()
{
ServiceAccountId = serviceAccountId,
ServiceAccount = new ServiceAccount() { Id = serviceAccountId, OrganizationId = organizationId },
GrantedProjectId = GrantedId,
Read = Read,
Write = Write,