mirror of
https://github.com/bitwarden/server
synced 2026-01-07 19:13:50 +00:00
[SM-460] Isolate SecretsManager files (#2616)
Move SecretsManager files to directories called SecretsManager and add CodeOwners
This commit is contained in:
57
src/Core/SecretsManager/Entities/AccessPolicy.cs
Normal file
57
src/Core/SecretsManager/Entities/AccessPolicy.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
#nullable enable
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Core.SecretsManager.Entities;
|
||||
|
||||
public abstract class BaseAccessPolicy
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
// Access
|
||||
public bool Read { get; set; }
|
||||
public bool Write { get; set; }
|
||||
|
||||
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
|
||||
public DateTime RevisionDate { get; set; } = DateTime.UtcNow;
|
||||
|
||||
public void SetNewId()
|
||||
{
|
||||
Id = CoreHelpers.GenerateComb();
|
||||
}
|
||||
}
|
||||
|
||||
public class UserProjectAccessPolicy : BaseAccessPolicy
|
||||
{
|
||||
public Guid? OrganizationUserId { get; set; }
|
||||
public Guid? GrantedProjectId { get; set; }
|
||||
public User? User { get; set; }
|
||||
}
|
||||
|
||||
public class UserServiceAccountAccessPolicy : BaseAccessPolicy
|
||||
{
|
||||
public Guid? OrganizationUserId { get; set; }
|
||||
public Guid? GrantedServiceAccountId { get; set; }
|
||||
public User? User { get; set; }
|
||||
}
|
||||
|
||||
public class GroupProjectAccessPolicy : BaseAccessPolicy
|
||||
{
|
||||
public Guid? GroupId { get; set; }
|
||||
public Guid? GrantedProjectId { get; set; }
|
||||
public Group? Group { get; set; }
|
||||
}
|
||||
|
||||
public class GroupServiceAccountAccessPolicy : BaseAccessPolicy
|
||||
{
|
||||
public Guid? GroupId { get; set; }
|
||||
public Guid? GrantedServiceAccountId { get; set; }
|
||||
public Group? Group { get; set; }
|
||||
}
|
||||
|
||||
public class ServiceAccountProjectAccessPolicy : BaseAccessPolicy
|
||||
{
|
||||
public Guid? ServiceAccountId { get; set; }
|
||||
public Guid? GrantedProjectId { get; set; }
|
||||
public ServiceAccount? ServiceAccount { get; set; }
|
||||
}
|
||||
34
src/Core/SecretsManager/Entities/ApiKey.cs
Normal file
34
src/Core/SecretsManager/Entities/ApiKey.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Core.SecretsManager.Entities;
|
||||
|
||||
public class ApiKey : ITableObject<Guid>
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid? ServiceAccountId { get; set; }
|
||||
[MaxLength(200)]
|
||||
public string Name { get; set; }
|
||||
[MaxLength(30)]
|
||||
public string ClientSecret { get; set; }
|
||||
[MaxLength(4000)]
|
||||
public string Scope { get; set; }
|
||||
[MaxLength(4000)]
|
||||
public string EncryptedPayload { get; set; }
|
||||
// Key for decrypting `EncryptedPayload`. Encrypted using the organization key.
|
||||
public string Key { get; set; }
|
||||
public DateTime? ExpireAt { get; set; }
|
||||
public DateTime CreationDate { get; internal set; } = DateTime.UtcNow;
|
||||
public DateTime RevisionDate { get; internal set; } = DateTime.UtcNow;
|
||||
|
||||
public void SetNewId()
|
||||
{
|
||||
Id = CoreHelpers.GenerateComb();
|
||||
}
|
||||
|
||||
public ICollection<string> GetScopes()
|
||||
{
|
||||
return CoreHelpers.LoadClassFromJsonData<List<string>>(Scope);
|
||||
}
|
||||
}
|
||||
30
src/Core/SecretsManager/Entities/Project.cs
Normal file
30
src/Core/SecretsManager/Entities/Project.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
#nullable enable
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Core.SecretsManager.Entities;
|
||||
|
||||
public class Project : ITableObject<Guid>
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public Guid OrganizationId { get; set; }
|
||||
|
||||
public string? Name { get; set; }
|
||||
|
||||
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
|
||||
|
||||
public DateTime RevisionDate { get; set; } = DateTime.UtcNow;
|
||||
|
||||
public DateTime? DeletedDate { get; set; }
|
||||
|
||||
public virtual ICollection<Secret>? Secrets { get; set; }
|
||||
|
||||
public void SetNewId()
|
||||
{
|
||||
if (Id == default(Guid))
|
||||
{
|
||||
Id = CoreHelpers.GenerateComb();
|
||||
}
|
||||
}
|
||||
}
|
||||
34
src/Core/SecretsManager/Entities/Secret.cs
Normal file
34
src/Core/SecretsManager/Entities/Secret.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
#nullable enable
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Core.SecretsManager.Entities;
|
||||
|
||||
public class Secret : ITableObject<Guid>
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public Guid OrganizationId { get; set; }
|
||||
|
||||
public string? Key { get; set; }
|
||||
|
||||
public string? Value { get; set; }
|
||||
|
||||
public string? Note { get; set; }
|
||||
|
||||
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
|
||||
|
||||
public DateTime RevisionDate { get; set; } = DateTime.UtcNow;
|
||||
|
||||
public DateTime? DeletedDate { get; set; }
|
||||
|
||||
public ICollection<Project>? Projects { get; set; }
|
||||
|
||||
public void SetNewId()
|
||||
{
|
||||
if (Id == default(Guid))
|
||||
{
|
||||
Id = CoreHelpers.GenerateComb();
|
||||
}
|
||||
}
|
||||
}
|
||||
27
src/Core/SecretsManager/Entities/ServiceAccount.cs
Normal file
27
src/Core/SecretsManager/Entities/ServiceAccount.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
#nullable enable
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Core.SecretsManager.Entities;
|
||||
|
||||
public class ServiceAccount : ITableObject<Guid>
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public Guid OrganizationId { get; set; }
|
||||
|
||||
public string? Name { get; set; }
|
||||
|
||||
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
|
||||
|
||||
public DateTime RevisionDate { get; set; } = DateTime.UtcNow;
|
||||
|
||||
public void SetNewId()
|
||||
{
|
||||
if (Id == default(Guid))
|
||||
{
|
||||
Id = CoreHelpers.GenerateComb();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user