mirror of
https://github.com/bitwarden/server
synced 2026-01-03 17:14:00 +00:00
[SM-670] Add permission context to project lists. (#2822)
* Attach permission context to project lists. * restrict service-account actions * Fix project permission details * Add getters and setters * dotnet format * Fix admin create unassigned secret (#2872)
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
using Bit.Core.SecretsManager.Entities;
|
||||
|
||||
namespace Bit.Api.SecretsManager.Models.Response;
|
||||
|
||||
public class ProjectPermissionDetailsResponseModel : ProjectResponseModel
|
||||
{
|
||||
private const string _objectName = "projectPermissionDetails";
|
||||
|
||||
public ProjectPermissionDetailsResponseModel(Project project, bool read, bool write, string obj = _objectName) : base(project, obj)
|
||||
{
|
||||
Read = read;
|
||||
Write = write;
|
||||
}
|
||||
|
||||
public ProjectPermissionDetailsResponseModel()
|
||||
{
|
||||
}
|
||||
|
||||
public bool Read { get; set; }
|
||||
|
||||
public bool Write { get; set; }
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using Bit.Core.Models.Api;
|
||||
using Bit.Core.SecretsManager.Entities;
|
||||
using Bit.Core.SecretsManager.Models.Data;
|
||||
|
||||
namespace Bit.Api.SecretsManager.Models.Response;
|
||||
|
||||
@@ -7,7 +8,7 @@ public class ProjectResponseModel : ResponseModel
|
||||
{
|
||||
private const string _objectName = "project";
|
||||
|
||||
public ProjectResponseModel(Project project, string obj = _objectName)
|
||||
public ProjectResponseModel(Project project, bool read, bool write, string obj = _objectName)
|
||||
: base(obj)
|
||||
{
|
||||
if (project == null)
|
||||
@@ -20,6 +21,25 @@ public class ProjectResponseModel : ResponseModel
|
||||
Name = project.Name;
|
||||
CreationDate = project.CreationDate;
|
||||
RevisionDate = project.RevisionDate;
|
||||
Read = read;
|
||||
Write = write;
|
||||
}
|
||||
|
||||
public ProjectResponseModel(ProjectPermissionDetails projectDetails, string obj = _objectName)
|
||||
: base(obj)
|
||||
{
|
||||
if (projectDetails == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(projectDetails));
|
||||
}
|
||||
|
||||
Id = projectDetails.Project.Id.ToString();
|
||||
OrganizationId = projectDetails.Project.OrganizationId.ToString();
|
||||
Name = projectDetails.Project.Name;
|
||||
CreationDate = projectDetails.Project.CreationDate;
|
||||
RevisionDate = projectDetails.Project.RevisionDate;
|
||||
Read = projectDetails.Read;
|
||||
Write = projectDetails.Write;
|
||||
}
|
||||
|
||||
public ProjectResponseModel() : base(_objectName)
|
||||
@@ -36,5 +56,7 @@ public class ProjectResponseModel : ResponseModel
|
||||
|
||||
public DateTime RevisionDate { get; set; }
|
||||
|
||||
public IEnumerable<Guid> Secrets { get; set; }
|
||||
public bool Read { get; set; }
|
||||
|
||||
public bool Write { get; set; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user