1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-21 12:05:42 +01:00

[SM-460] Isolate SecretsManager files (#2616)

Move SecretsManager files to directories called SecretsManager and add CodeOwners
This commit is contained in:
Oscar Hinton 2023-01-24 19:57:28 +01:00 committed by GitHub
parent 4041d7f009
commit 59f5285c88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
122 changed files with 449 additions and 419 deletions

5
.github/CODEOWNERS vendored Normal file
View File

@ -0,0 +1,5 @@
# Please sort lines alphabetically, this will ensure we don't accidentally add duplicates.
#
# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
**/SecretsManager @bitwarden/pod-sm-dev

View File

@ -1,9 +1,9 @@
using Bit.Core.Entities;
using Bit.Core.Exceptions;
using Bit.Core.Repositories;
using Bit.Core.SecretManagerFeatures.AccessPolicies.Interfaces;
using Bit.Core.Exceptions;
using Bit.Core.SecretsManager.Commands.AccessPolicies.Interfaces;
using Bit.Core.SecretsManager.Entities;
using Bit.Core.SecretsManager.Repositories;
namespace Bit.Commercial.Core.SecretManagerFeatures.AccessPolicies;
namespace Bit.Commercial.Core.SecretsManager.Commands.AccessPolicies;
public class CreateAccessPoliciesCommand : ICreateAccessPoliciesCommand
{

View File

@ -1,8 +1,8 @@
using Bit.Core.Exceptions;
using Bit.Core.Repositories;
using Bit.Core.SecretManagerFeatures.AccessPolicies.Interfaces;
using Bit.Core.SecretsManager.Commands.AccessPolicies.Interfaces;
using Bit.Core.SecretsManager.Repositories;
namespace Bit.Commercial.Core.SecretManagerFeatures.AccessPolicies;
namespace Bit.Commercial.Core.SecretsManager.Commands.AccessPolicies;
public class DeleteAccessPolicyCommand : IDeleteAccessPolicyCommand
{

View File

@ -1,9 +1,9 @@
using Bit.Core.Entities;
using Bit.Core.Exceptions;
using Bit.Core.Repositories;
using Bit.Core.SecretManagerFeatures.AccessPolicies.Interfaces;
using Bit.Core.Exceptions;
using Bit.Core.SecretsManager.Commands.AccessPolicies.Interfaces;
using Bit.Core.SecretsManager.Entities;
using Bit.Core.SecretsManager.Repositories;
namespace Bit.Commercial.Core.SecretManagerFeatures.AccessPolicies;
namespace Bit.Commercial.Core.SecretsManager.Commands.AccessPolicies;
public class UpdateAccessPolicyCommand : IUpdateAccessPolicyCommand
{

View File

@ -1,12 +1,12 @@
using Bit.Core.Context;
using Bit.Core.Entities;
using Bit.Core.Enums;
using Bit.Core.Exceptions;
using Bit.Core.Repositories;
using Bit.Core.SecretManagerFeatures.AccessTokens.Interfaces;
using Bit.Core.SecretsManager.Commands.AccessTokens.Interfaces;
using Bit.Core.SecretsManager.Entities;
using Bit.Core.SecretsManager.Repositories;
using Bit.Core.Utilities;
namespace Bit.Commercial.Core.SecretManagerFeatures.AccessTokens;
namespace Bit.Commercial.Core.SecretsManager.Commands.AccessTokens;
public class CreateAccessTokenCommand : ICreateAccessTokenCommand
{

View File

@ -1,8 +1,8 @@
using Bit.Core.Entities;
using Bit.Core.Repositories;
using Bit.Core.SecretManagerFeatures.Projects.Interfaces;
using Bit.Core.SecretsManager.Commands.Projects.Interfaces;
using Bit.Core.SecretsManager.Entities;
using Bit.Core.SecretsManager.Repositories;
namespace Bit.Commercial.Core.SecretManagerFeatures.Projects;
namespace Bit.Commercial.Core.SecretsManager.Commands.Projects;
public class CreateProjectCommand : ICreateProjectCommand
{

View File

@ -1,11 +1,11 @@
using Bit.Core.Context;
using Bit.Core.Entities;
using Bit.Core.Enums;
using Bit.Core.Exceptions;
using Bit.Core.Repositories;
using Bit.Core.SecretManagerFeatures.Projects.Interfaces;
using Bit.Core.SecretsManager.Commands.Projects.Interfaces;
using Bit.Core.SecretsManager.Entities;
using Bit.Core.SecretsManager.Repositories;
namespace Bit.Commercial.Core.SecretManagerFeatures.Projects;
namespace Bit.Commercial.Core.SecretsManager.Commands.Projects;
public class DeleteProjectCommand : IDeleteProjectCommand
{

View File

@ -1,11 +1,11 @@
using Bit.Core.Context;
using Bit.Core.Entities;
using Bit.Core.Enums;
using Bit.Core.Exceptions;
using Bit.Core.Repositories;
using Bit.Core.SecretManagerFeatures.Projects.Interfaces;
using Bit.Core.SecretsManager.Commands.Projects.Interfaces;
using Bit.Core.SecretsManager.Entities;
using Bit.Core.SecretsManager.Repositories;
namespace Bit.Commercial.Core.SecretManagerFeatures.Projects;
namespace Bit.Commercial.Core.SecretsManager.Commands.Projects;
public class UpdateProjectCommand : IUpdateProjectCommand
{

View File

@ -1,8 +1,8 @@
using Bit.Core.Entities;
using Bit.Core.Repositories;
using Bit.Core.SecretManagerFeatures.Secrets.Interfaces;
using Bit.Core.SecretsManager.Commands.Secrets.Interfaces;
using Bit.Core.SecretsManager.Entities;
using Bit.Core.SecretsManager.Repositories;
namespace Bit.Commercial.Core.SecretManagerFeatures.Secrets;
namespace Bit.Commercial.Core.SecretsManager.Commands.Secrets;
public class CreateSecretCommand : ICreateSecretCommand
{

View File

@ -1,9 +1,9 @@
using Bit.Core.Entities;
using Bit.Core.Exceptions;
using Bit.Core.Repositories;
using Bit.Core.SecretManagerFeatures.Secrets.Interfaces;
using Bit.Core.Exceptions;
using Bit.Core.SecretsManager.Commands.Secrets.Interfaces;
using Bit.Core.SecretsManager.Entities;
using Bit.Core.SecretsManager.Repositories;
namespace Bit.Commercial.Core.SecretManagerFeatures.Secrets;
namespace Bit.Commercial.Core.SecretsManager.Commands.Secrets;
public class DeleteSecretCommand : IDeleteSecretCommand
{

View File

@ -1,9 +1,9 @@
using Bit.Core.Entities;
using Bit.Core.Exceptions;
using Bit.Core.Repositories;
using Bit.Core.SecretManagerFeatures.Secrets.Interfaces;
using Bit.Core.Exceptions;
using Bit.Core.SecretsManager.Commands.Secrets.Interfaces;
using Bit.Core.SecretsManager.Entities;
using Bit.Core.SecretsManager.Repositories;
namespace Bit.Commercial.Core.SecretManagerFeatures.Secrets;
namespace Bit.Commercial.Core.SecretsManager.Commands.Secrets;
public class UpdateSecretCommand : IUpdateSecretCommand
{

View File

@ -1,8 +1,8 @@
using Bit.Core.Entities;
using Bit.Core.Repositories;
using Bit.Core.SecretManagerFeatures.ServiceAccounts.Interfaces;
using Bit.Core.SecretsManager.Commands.ServiceAccounts.Interfaces;
using Bit.Core.SecretsManager.Entities;
using Bit.Core.SecretsManager.Repositories;
namespace Bit.Commercial.Core.SecretManagerFeatures.ServiceAccounts;
namespace Bit.Commercial.Core.SecretsManager.Commands.ServiceAccounts;
public class CreateServiceAccountCommand : ICreateServiceAccountCommand
{

View File

@ -1,11 +1,11 @@
using Bit.Core.Context;
using Bit.Core.Entities;
using Bit.Core.Enums;
using Bit.Core.Exceptions;
using Bit.Core.Repositories;
using Bit.Core.SecretManagerFeatures.ServiceAccounts.Interfaces;
using Bit.Core.SecretsManager.Commands.ServiceAccounts.Interfaces;
using Bit.Core.SecretsManager.Entities;
using Bit.Core.SecretsManager.Repositories;
namespace Bit.Commercial.Core.SecretManagerFeatures.ServiceAccounts;
namespace Bit.Commercial.Core.SecretsManager.Commands.ServiceAccounts;
public class UpdateServiceAccountCommand : IUpdateServiceAccountCommand
{

View File

@ -1,20 +1,20 @@
using Bit.Commercial.Core.SecretManagerFeatures.AccessPolicies;
using Bit.Commercial.Core.SecretManagerFeatures.AccessTokens;
using Bit.Commercial.Core.SecretManagerFeatures.Projects;
using Bit.Commercial.Core.SecretManagerFeatures.Secrets;
using Bit.Commercial.Core.SecretManagerFeatures.ServiceAccounts;
using Bit.Core.SecretManagerFeatures.AccessPolicies.Interfaces;
using Bit.Core.SecretManagerFeatures.AccessTokens.Interfaces;
using Bit.Core.SecretManagerFeatures.Projects.Interfaces;
using Bit.Core.SecretManagerFeatures.Secrets.Interfaces;
using Bit.Core.SecretManagerFeatures.ServiceAccounts.Interfaces;
using Bit.Commercial.Core.SecretsManager.Commands.AccessPolicies;
using Bit.Commercial.Core.SecretsManager.Commands.AccessTokens;
using Bit.Commercial.Core.SecretsManager.Commands.Projects;
using Bit.Commercial.Core.SecretsManager.Commands.Secrets;
using Bit.Commercial.Core.SecretsManager.Commands.ServiceAccounts;
using Bit.Core.SecretsManager.Commands.AccessPolicies.Interfaces;
using Bit.Core.SecretsManager.Commands.AccessTokens.Interfaces;
using Bit.Core.SecretsManager.Commands.Projects.Interfaces;
using Bit.Core.SecretsManager.Commands.Secrets.Interfaces;
using Bit.Core.SecretsManager.Commands.ServiceAccounts.Interfaces;
using Microsoft.Extensions.DependencyInjection;
namespace Bit.Commercial.Core.SecretManagerFeatures;
namespace Bit.Commercial.Core.SecretsManager;
public static class SecretManagerCollectionExtensions
public static class SecretsManagerCollectionExtensions
{
public static void AddSecretManagerServices(this IServiceCollection services)
public static void AddSecretsManagerServices(this IServiceCollection services)
{
services.AddScoped<ICreateSecretCommand, CreateSecretCommand>();
services.AddScoped<IUpdateSecretCommand, UpdateSecretCommand>();

View File

@ -0,0 +1,11 @@
using Microsoft.Extensions.DependencyInjection;
namespace Bit.Commercial.Core.SecretsManager;
public static class SecretsManagerServiceCollectionExtensions
{
public static void AddCommercialSecretsManagerServices(this IServiceCollection services)
{
services.AddSecretsManagerServices();
}
}

View File

@ -1,5 +1,4 @@
using Bit.Commercial.Core.SecretManagerFeatures;
using Bit.Commercial.Core.Services;
using Bit.Commercial.Core.Services;
using Bit.Core.Services;
using Microsoft.Extensions.DependencyInjection;
@ -11,9 +10,4 @@ public static class ServiceCollectionExtensions
{
services.AddScoped<IProviderService, ProviderService>();
}
public static void AddCommercialSecretsManagerServices(this IServiceCollection services)
{
services.AddSecretManagerServices();
}
}

View File

@ -1,11 +1,11 @@
using AutoMapper;
using Bit.Core.Repositories;
using Bit.Infrastructure.EntityFramework.Models;
using Bit.Core.SecretsManager.Repositories;
using Bit.Infrastructure.EntityFramework.Repositories;
using Bit.Infrastructure.EntityFramework.SecretsManager.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace Bit.Commercial.Infrastructure.EntityFramework.Repositories;
namespace Bit.Commercial.Infrastructure.EntityFramework.SecretsManager.Repositories;
public class AccessPolicyRepository : BaseEntityFrameworkRepository, IAccessPolicyRepository
{
@ -14,7 +14,7 @@ public class AccessPolicyRepository : BaseEntityFrameworkRepository, IAccessPoli
{
}
public async Task<List<Core.Entities.BaseAccessPolicy>> CreateManyAsync(List<Core.Entities.BaseAccessPolicy> baseAccessPolicies)
public async Task<List<Core.SecretsManager.Entities.BaseAccessPolicy>> CreateManyAsync(List<Core.SecretsManager.Entities.BaseAccessPolicy> baseAccessPolicies)
{
using (var scope = ServiceScopeFactory.CreateScope())
{
@ -24,33 +24,33 @@ public class AccessPolicyRepository : BaseEntityFrameworkRepository, IAccessPoli
baseAccessPolicy.SetNewId();
switch (baseAccessPolicy)
{
case Core.Entities.UserProjectAccessPolicy accessPolicy:
case Core.SecretsManager.Entities.UserProjectAccessPolicy accessPolicy:
{
var entity =
Mapper.Map<UserProjectAccessPolicy>(accessPolicy);
await dbContext.AddAsync(entity);
break;
}
case Core.Entities.UserServiceAccountAccessPolicy accessPolicy:
case Core.SecretsManager.Entities.UserServiceAccountAccessPolicy accessPolicy:
{
var entity =
Mapper.Map<UserServiceAccountAccessPolicy>(accessPolicy);
await dbContext.AddAsync(entity);
break;
}
case Core.Entities.GroupProjectAccessPolicy accessPolicy:
case Core.SecretsManager.Entities.GroupProjectAccessPolicy accessPolicy:
{
var entity = Mapper.Map<GroupProjectAccessPolicy>(accessPolicy);
await dbContext.AddAsync(entity);
break;
}
case Core.Entities.GroupServiceAccountAccessPolicy accessPolicy:
case Core.SecretsManager.Entities.GroupServiceAccountAccessPolicy accessPolicy:
{
var entity = Mapper.Map<GroupServiceAccountAccessPolicy>(accessPolicy);
await dbContext.AddAsync(entity);
break;
}
case Core.Entities.ServiceAccountProjectAccessPolicy accessPolicy:
case Core.SecretsManager.Entities.ServiceAccountProjectAccessPolicy accessPolicy:
{
var entity = Mapper.Map<ServiceAccountProjectAccessPolicy>(accessPolicy);
await dbContext.AddAsync(entity);
@ -64,14 +64,14 @@ public class AccessPolicyRepository : BaseEntityFrameworkRepository, IAccessPoli
}
}
public async Task<bool> AccessPolicyExists(Core.Entities.BaseAccessPolicy baseAccessPolicy)
public async Task<bool> AccessPolicyExists(Core.SecretsManager.Entities.BaseAccessPolicy baseAccessPolicy)
{
using (var scope = ServiceScopeFactory.CreateScope())
{
var dbContext = GetDatabaseContext(scope);
switch (baseAccessPolicy)
{
case Core.Entities.UserProjectAccessPolicy accessPolicy:
case Core.SecretsManager.Entities.UserProjectAccessPolicy accessPolicy:
{
var policy = await dbContext.UserProjectAccessPolicy
.Where(c => c.OrganizationUserId == accessPolicy.OrganizationUserId &&
@ -79,7 +79,7 @@ public class AccessPolicyRepository : BaseEntityFrameworkRepository, IAccessPoli
.FirstOrDefaultAsync();
return policy != null;
}
case Core.Entities.GroupProjectAccessPolicy accessPolicy:
case Core.SecretsManager.Entities.GroupProjectAccessPolicy accessPolicy:
{
var policy = await dbContext.GroupProjectAccessPolicy
.Where(c => c.GroupId == accessPolicy.GroupId &&
@ -87,7 +87,7 @@ public class AccessPolicyRepository : BaseEntityFrameworkRepository, IAccessPoli
.FirstOrDefaultAsync();
return policy != null;
}
case Core.Entities.ServiceAccountProjectAccessPolicy accessPolicy:
case Core.SecretsManager.Entities.ServiceAccountProjectAccessPolicy accessPolicy:
{
var policy = await dbContext.ServiceAccountProjectAccessPolicy
.Where(c => c.ServiceAccountId == accessPolicy.ServiceAccountId &&
@ -101,7 +101,7 @@ public class AccessPolicyRepository : BaseEntityFrameworkRepository, IAccessPoli
}
}
public async Task<Core.Entities.BaseAccessPolicy?> GetByIdAsync(Guid id)
public async Task<Core.SecretsManager.Entities.BaseAccessPolicy?> GetByIdAsync(Guid id)
{
using (var scope = ServiceScopeFactory.CreateScope())
{
@ -121,7 +121,7 @@ public class AccessPolicyRepository : BaseEntityFrameworkRepository, IAccessPoli
}
}
public async Task ReplaceAsync(Core.Entities.BaseAccessPolicy baseAccessPolicy)
public async Task ReplaceAsync(Core.SecretsManager.Entities.BaseAccessPolicy baseAccessPolicy)
{
using (var scope = ServiceScopeFactory.CreateScope())
{
@ -138,7 +138,7 @@ public class AccessPolicyRepository : BaseEntityFrameworkRepository, IAccessPoli
}
}
public async Task<IEnumerable<Core.Entities.BaseAccessPolicy>?> GetManyByProjectId(Guid id)
public async Task<IEnumerable<Core.SecretsManager.Entities.BaseAccessPolicy>?> GetManyByProjectId(Guid id)
{
using (var scope = ServiceScopeFactory.CreateScope())
{
@ -171,13 +171,13 @@ public class AccessPolicyRepository : BaseEntityFrameworkRepository, IAccessPoli
}
}
private Core.Entities.BaseAccessPolicy MapToCore(BaseAccessPolicy baseAccessPolicyEntity)
private Core.SecretsManager.Entities.BaseAccessPolicy MapToCore(BaseAccessPolicy baseAccessPolicyEntity)
{
return baseAccessPolicyEntity switch
{
UserProjectAccessPolicy ap => Mapper.Map<Core.Entities.UserProjectAccessPolicy>(ap),
GroupProjectAccessPolicy ap => Mapper.Map<Core.Entities.GroupProjectAccessPolicy>(ap),
ServiceAccountProjectAccessPolicy ap => Mapper.Map<Core.Entities.ServiceAccountProjectAccessPolicy>(ap),
UserProjectAccessPolicy ap => Mapper.Map<Core.SecretsManager.Entities.UserProjectAccessPolicy>(ap),
GroupProjectAccessPolicy ap => Mapper.Map<Core.SecretsManager.Entities.GroupProjectAccessPolicy>(ap),
ServiceAccountProjectAccessPolicy ap => Mapper.Map<Core.SecretsManager.Entities.ServiceAccountProjectAccessPolicy>(ap),
_ => throw new ArgumentException("Unsupported access policy type")
};
}

View File

@ -1,21 +1,21 @@
using System.Linq.Expressions;
using AutoMapper;
using Bit.Core.Enums;
using Bit.Core.Repositories;
using Bit.Infrastructure.EntityFramework.Models;
using Bit.Core.SecretsManager.Repositories;
using Bit.Infrastructure.EntityFramework.Repositories;
using Bit.Infrastructure.EntityFramework.SecretsManager.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace Bit.Commercial.Infrastructure.EntityFramework.Repositories;
namespace Bit.Commercial.Infrastructure.EntityFramework.SecretsManager.Repositories;
public class ProjectRepository : Repository<Core.Entities.Project, Project, Guid>, IProjectRepository
public class ProjectRepository : Repository<Core.SecretsManager.Entities.Project, Project, Guid>, IProjectRepository
{
public ProjectRepository(IServiceScopeFactory serviceScopeFactory, IMapper mapper)
: base(serviceScopeFactory, mapper, db => db.Project)
{ }
public override async Task<Core.Entities.Project> GetByIdAsync(Guid id)
public override async Task<Core.SecretsManager.Entities.Project> GetByIdAsync(Guid id)
{
using (var scope = ServiceScopeFactory.CreateScope())
{
@ -23,11 +23,11 @@ public class ProjectRepository : Repository<Core.Entities.Project, Project, Guid
var project = await dbContext.Project
.Where(c => c.Id == id && c.DeletedDate == null)
.FirstOrDefaultAsync();
return Mapper.Map<Core.Entities.Project>(project);
return Mapper.Map<Core.SecretsManager.Entities.Project>(project);
}
}
public async Task<IEnumerable<Core.Entities.Project>> GetManyByOrganizationIdAsync(Guid organizationId, Guid userId, AccessClientType accessType)
public async Task<IEnumerable<Core.SecretsManager.Entities.Project>> GetManyByOrganizationIdAsync(Guid organizationId, Guid userId, AccessClientType accessType)
{
using var scope = ServiceScopeFactory.CreateScope();
var dbContext = GetDatabaseContext(scope);
@ -42,7 +42,7 @@ public class ProjectRepository : Repository<Core.Entities.Project, Project, Guid
};
var projects = await query.OrderBy(p => p.RevisionDate).ToListAsync();
return Mapper.Map<List<Core.Entities.Project>>(projects);
return Mapper.Map<List<Core.SecretsManager.Entities.Project>>(projects);
}
private static Expression<Func<Project, bool>> UserHasReadAccessToProject(Guid userId) => p =>
@ -70,7 +70,7 @@ public class ProjectRepository : Repository<Core.Entities.Project, Project, Guid
}
}
public async Task<IEnumerable<Core.Entities.Project>> GetManyByIds(IEnumerable<Guid> ids)
public async Task<IEnumerable<Core.SecretsManager.Entities.Project>> GetManyByIds(IEnumerable<Guid> ids)
{
using (var scope = ServiceScopeFactory.CreateScope())
{
@ -78,7 +78,7 @@ public class ProjectRepository : Repository<Core.Entities.Project, Project, Guid
var projects = await dbContext.Project
.Where(c => ids.Contains(c.Id) && c.DeletedDate == null)
.ToListAsync();
return Mapper.Map<List<Core.Entities.Project>>(projects);
return Mapper.Map<List<Core.SecretsManager.Entities.Project>>(projects);
}
}

View File

@ -1,20 +1,20 @@
using AutoMapper;
using Bit.Core.Repositories;
using Bit.Core.SecretsManager.Repositories;
using Bit.Infrastructure.EntityFramework;
using Bit.Infrastructure.EntityFramework.Models;
using Bit.Infrastructure.EntityFramework.Repositories;
using Bit.Infrastructure.EntityFramework.SecretsManager.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace Bit.Commercial.Infrastructure.EntityFramework.Repositories;
namespace Bit.Commercial.Infrastructure.EntityFramework.SecretsManager.Repositories;
public class SecretRepository : Repository<Core.Entities.Secret, Secret, Guid>, ISecretRepository
public class SecretRepository : Repository<Core.SecretsManager.Entities.Secret, Secret, Guid>, ISecretRepository
{
public SecretRepository(IServiceScopeFactory serviceScopeFactory, IMapper mapper)
: base(serviceScopeFactory, mapper, db => db.Secret)
{ }
public override async Task<Core.Entities.Secret> GetByIdAsync(Guid id)
public override async Task<Core.SecretsManager.Entities.Secret> GetByIdAsync(Guid id)
{
using (var scope = ServiceScopeFactory.CreateScope())
{
@ -23,11 +23,11 @@ public class SecretRepository : Repository<Core.Entities.Secret, Secret, Guid>,
.Include("Projects")
.Where(c => c.Id == id && c.DeletedDate == null)
.FirstOrDefaultAsync();
return Mapper.Map<Core.Entities.Secret>(secret);
return Mapper.Map<Core.SecretsManager.Entities.Secret>(secret);
}
}
public async Task<IEnumerable<Core.Entities.Secret>> GetManyByIds(IEnumerable<Guid> ids)
public async Task<IEnumerable<Core.SecretsManager.Entities.Secret>> GetManyByIds(IEnumerable<Guid> ids)
{
using (var scope = ServiceScopeFactory.CreateScope())
{
@ -35,11 +35,11 @@ public class SecretRepository : Repository<Core.Entities.Secret, Secret, Guid>,
var secrets = await dbContext.Secret
.Where(c => ids.Contains(c.Id) && c.DeletedDate == null)
.ToListAsync();
return Mapper.Map<List<Core.Entities.Secret>>(secrets);
return Mapper.Map<List<Core.SecretsManager.Entities.Secret>>(secrets);
}
}
public async Task<IEnumerable<Core.Entities.Secret>> GetManyByOrganizationIdAsync(Guid organizationId)
public async Task<IEnumerable<Core.SecretsManager.Entities.Secret>> GetManyByOrganizationIdAsync(Guid organizationId)
{
using (var scope = ServiceScopeFactory.CreateScope())
{
@ -50,11 +50,11 @@ public class SecretRepository : Repository<Core.Entities.Secret, Secret, Guid>,
.OrderBy(c => c.RevisionDate)
.ToListAsync();
return Mapper.Map<List<Core.Entities.Secret>>(secrets);
return Mapper.Map<List<Core.SecretsManager.Entities.Secret>>(secrets);
}
}
public async Task<IEnumerable<Core.Entities.Secret>> GetManyByProjectIdAsync(Guid projectId)
public async Task<IEnumerable<Core.SecretsManager.Entities.Secret>> GetManyByProjectIdAsync(Guid projectId)
{
using (var scope = ServiceScopeFactory.CreateScope())
{
@ -63,11 +63,11 @@ public class SecretRepository : Repository<Core.Entities.Secret, Secret, Guid>,
.Where(s => s.Projects.Any(p => p.Id == projectId) && s.DeletedDate == null).Include("Projects")
.OrderBy(s => s.RevisionDate).ToListAsync();
return Mapper.Map<List<Core.Entities.Secret>>(secrets);
return Mapper.Map<List<Core.SecretsManager.Entities.Secret>>(secrets);
}
}
public override async Task<Core.Entities.Secret> CreateAsync(Core.Entities.Secret secret)
public override async Task<Core.SecretsManager.Entities.Secret> CreateAsync(Core.SecretsManager.Entities.Secret secret)
{
using (var scope = ServiceScopeFactory.CreateScope())
{
@ -90,7 +90,7 @@ public class SecretRepository : Repository<Core.Entities.Secret, Secret, Guid>,
}
}
public async Task<Core.Entities.Secret> UpdateAsync(Core.Entities.Secret secret)
public async Task<Core.SecretsManager.Entities.Secret> UpdateAsync(Core.SecretsManager.Entities.Secret secret)
{
using (var scope = ServiceScopeFactory.CreateScope())

View File

@ -1,21 +1,21 @@
using System.Linq.Expressions;
using AutoMapper;
using Bit.Core.Enums;
using Bit.Core.Repositories;
using Bit.Infrastructure.EntityFramework.Models;
using Bit.Core.SecretsManager.Repositories;
using Bit.Infrastructure.EntityFramework.Repositories;
using Bit.Infrastructure.EntityFramework.SecretsManager.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace Bit.Commercial.Infrastructure.EntityFramework.Repositories;
namespace Bit.Commercial.Infrastructure.EntityFramework.SecretsManager.Repositories;
public class ServiceAccountRepository : Repository<Core.Entities.ServiceAccount, ServiceAccount, Guid>, IServiceAccountRepository
public class ServiceAccountRepository : Repository<Core.SecretsManager.Entities.ServiceAccount, ServiceAccount, Guid>, IServiceAccountRepository
{
public ServiceAccountRepository(IServiceScopeFactory serviceScopeFactory, IMapper mapper)
: base(serviceScopeFactory, mapper, db => db.ServiceAccount)
{ }
public async Task<IEnumerable<Core.Entities.ServiceAccount>> GetManyByOrganizationIdAsync(Guid organizationId, Guid userId, AccessClientType accessType)
public async Task<IEnumerable<Core.SecretsManager.Entities.ServiceAccount>> GetManyByOrganizationIdAsync(Guid organizationId, Guid userId, AccessClientType accessType)
{
using var scope = ServiceScopeFactory.CreateScope();
var dbContext = GetDatabaseContext(scope);
@ -29,7 +29,7 @@ public class ServiceAccountRepository : Repository<Core.Entities.ServiceAccount,
};
var serviceAccounts = await query.OrderBy(c => c.RevisionDate).ToListAsync();
return Mapper.Map<List<Core.Entities.ServiceAccount>>(serviceAccounts);
return Mapper.Map<List<Core.SecretsManager.Entities.ServiceAccount>>(serviceAccounts);
}
public async Task<bool> UserHasReadAccessToServiceAccount(Guid id, Guid userId)

View File

@ -1,12 +1,12 @@
using Bit.Commercial.Infrastructure.EntityFramework.Repositories;
using Bit.Core.Repositories;
using Bit.Commercial.Infrastructure.EntityFramework.SecretsManager.Repositories;
using Bit.Core.SecretsManager.Repositories;
using Microsoft.Extensions.DependencyInjection;
namespace Bit.Commercial.Infrastructure.EntityFramework;
namespace Bit.Commercial.Infrastructure.EntityFramework.SecretsManager;
public static class CommercialEFServiceCollectionExtensions
public static class SecretsManagerEfServiceCollectionExtensions
{
public static void AddCommercialEFRepositories(this IServiceCollection services)
public static void AddSecretsManagerEfRepositories(this IServiceCollection services)
{
services.AddSingleton<IAccessPolicyRepository, AccessPolicyRepository>();
services.AddSingleton<ISecretRepository, SecretRepository>();

View File

@ -1,14 +1,14 @@
using Bit.Commercial.Core.SecretManagerFeatures.AccessPolicies;
using Bit.Core.Entities;
using Bit.Commercial.Core.SecretsManager.Commands.AccessPolicies;
using Bit.Core.Exceptions;
using Bit.Core.Repositories;
using Bit.Core.SecretsManager.Entities;
using Bit.Core.SecretsManager.Repositories;
using Bit.Test.Common.AutoFixture;
using Bit.Test.Common.AutoFixture.Attributes;
using Bit.Test.Common.Helpers;
using NSubstitute;
using Xunit;
namespace Bit.Commercial.Core.Test.SecretManagerFeatures.AccessPolicies;
namespace Bit.Commercial.Core.Test.SecretsManager.AccessPolicies;
[SutProviderCustomize]
public class CreateAccessPoliciesCommandTests

View File

@ -1,14 +1,14 @@
using Bit.Commercial.Core.SecretManagerFeatures.AccessPolicies;
using Bit.Core.Entities;
using Bit.Commercial.Core.SecretsManager.Commands.AccessPolicies;
using Bit.Core.Exceptions;
using Bit.Core.Repositories;
using Bit.Core.SecretsManager.Entities;
using Bit.Core.SecretsManager.Repositories;
using Bit.Test.Common.AutoFixture;
using Bit.Test.Common.AutoFixture.Attributes;
using NSubstitute;
using NSubstitute.ReturnsExtensions;
using Xunit;
namespace Bit.Commercial.Core.Test.SecretManagerFeatures.AccessPolicies;
namespace Bit.Commercial.Core.Test.SecretsManager.AccessPolicies;
[SutProviderCustomize]
public class DeleteAccessPolicyCommandTests

View File

@ -1,14 +1,14 @@
using Bit.Commercial.Core.SecretManagerFeatures.AccessPolicies;
using Bit.Core.Entities;
using Bit.Commercial.Core.SecretsManager.Commands.AccessPolicies;
using Bit.Core.Exceptions;
using Bit.Core.Repositories;
using Bit.Core.SecretsManager.Entities;
using Bit.Core.SecretsManager.Repositories;
using Bit.Test.Common.AutoFixture;
using Bit.Test.Common.AutoFixture.Attributes;
using Bit.Test.Common.Helpers;
using NSubstitute;
using Xunit;
namespace Bit.Commercial.Core.Test.SecretManagerFeatures.AccessPolicies;
namespace Bit.Commercial.Core.Test.SecretsManager.AccessPolicies;
[SutProviderCustomize]
public class UpdateAccessPolicyCommandTests

View File

@ -1,15 +1,15 @@
using Bit.Commercial.Core.SecretManagerFeatures.AccessTokens;
using Bit.Commercial.Core.SecretsManager.Commands.AccessTokens;
using Bit.Core.Context;
using Bit.Core.Entities;
using Bit.Core.Exceptions;
using Bit.Core.Repositories;
using Bit.Core.SecretsManager.Entities;
using Bit.Core.SecretsManager.Repositories;
using Bit.Test.Common.AutoFixture;
using Bit.Test.Common.AutoFixture.Attributes;
using Bit.Test.Common.Helpers;
using NSubstitute;
using Xunit;
namespace Bit.Commercial.Core.Test.SecretManagerFeatures.AccessTokens;
namespace Bit.Commercial.Core.Test.SecretsManager.AccessTokens;
[SutProviderCustomize]
public class CreateServiceAccountCommandTests

View File

@ -1,15 +1,15 @@
using Bit.Commercial.Core.SecretManagerFeatures.Projects;
using Bit.Commercial.Core.SecretsManager.Commands.Projects;
using Bit.Core.Context;
using Bit.Core.Entities;
using Bit.Core.Exceptions;
using Bit.Core.Identity;
using Bit.Core.Repositories;
using Bit.Core.SecretsManager.Entities;
using Bit.Core.SecretsManager.Repositories;
using Bit.Test.Common.AutoFixture;
using Bit.Test.Common.AutoFixture.Attributes;
using NSubstitute;
using Xunit;
namespace Bit.Commercial.Core.Test.SecretManagerFeatures.Projects;
namespace Bit.Commercial.Core.Test.SecretsManager.Projects;
[SutProviderCustomize]
public class DeleteProjectCommandTests

View File

@ -1,9 +1,9 @@
using Bit.Commercial.Core.SecretManagerFeatures.Projects;
using Bit.Commercial.Core.SecretsManager.Commands.Projects;
using Bit.Core.Context;
using Bit.Core.Entities;
using Bit.Core.Exceptions;
using Bit.Core.Repositories;
using Bit.Core.Test.AutoFixture.ProjectsFixture;
using Bit.Core.SecretsManager.Entities;
using Bit.Core.SecretsManager.Repositories;
using Bit.Core.Test.SecretsManager.AutoFixture.ProjectsFixture;
using Bit.Test.Common.AutoFixture;
using Bit.Test.Common.AutoFixture.Attributes;
using Bit.Test.Common.Helpers;
@ -11,7 +11,7 @@ using NSubstitute;
using NSubstitute.ReturnsExtensions;
using Xunit;
namespace Bit.Commercial.Core.Test.SecretManagerFeatures.Projects;
namespace Bit.Commercial.Core.Test.SecretsManager.Projects;
[SutProviderCustomize]
[ProjectCustomize]

View File

@ -1,13 +1,13 @@
using Bit.Commercial.Core.SecretManagerFeatures.Secrets;
using Bit.Core.Entities;
using Bit.Core.Repositories;
using Bit.Core.Test.AutoFixture.SecretsFixture;
using Bit.Commercial.Core.SecretsManager.Commands.Secrets;
using Bit.Core.SecretsManager.Entities;
using Bit.Core.SecretsManager.Repositories;
using Bit.Core.Test.SecretsManager.AutoFixture.SecretsFixture;
using Bit.Test.Common.AutoFixture;
using Bit.Test.Common.AutoFixture.Attributes;
using NSubstitute;
using Xunit;
namespace Bit.Commercial.Core.Test.SecretManagerFeatures.Secrets;
namespace Bit.Commercial.Core.Test.SecretsManager.Secrets;
[SutProviderCustomize]
[SecretCustomize]

View File

@ -1,13 +1,13 @@
using Bit.Commercial.Core.SecretManagerFeatures.Secrets;
using Bit.Core.Entities;
using Bit.Commercial.Core.SecretsManager.Commands.Secrets;
using Bit.Core.Exceptions;
using Bit.Core.Repositories;
using Bit.Core.SecretsManager.Entities;
using Bit.Core.SecretsManager.Repositories;
using Bit.Test.Common.AutoFixture;
using Bit.Test.Common.AutoFixture.Attributes;
using NSubstitute;
using Xunit;
namespace Bit.Commercial.Core.Test.SecretManagerFeatures.Secrets;
namespace Bit.Commercial.Core.Test.SecretsManager.Secrets;
[SutProviderCustomize]
public class DeleteSecretCommandTests

View File

@ -1,15 +1,15 @@
using Bit.Commercial.Core.SecretManagerFeatures.Secrets;
using Bit.Core.Entities;
using Bit.Commercial.Core.SecretsManager.Commands.Secrets;
using Bit.Core.Exceptions;
using Bit.Core.Repositories;
using Bit.Core.Test.AutoFixture.SecretsFixture;
using Bit.Core.SecretsManager.Entities;
using Bit.Core.SecretsManager.Repositories;
using Bit.Core.Test.SecretsManager.AutoFixture.SecretsFixture;
using Bit.Test.Common.AutoFixture;
using Bit.Test.Common.AutoFixture.Attributes;
using Bit.Test.Common.Helpers;
using NSubstitute;
using Xunit;
namespace Bit.Commercial.Core.Test.SecretManagerFeatures.Secrets;
namespace Bit.Commercial.Core.Test.SecretsManager.Secrets;
[SutProviderCustomize]
[SecretCustomize]

View File

@ -1,13 +1,13 @@
using Bit.Commercial.Core.SecretManagerFeatures.ServiceAccounts;
using Bit.Core.Entities;
using Bit.Core.Repositories;
using Bit.Commercial.Core.SecretsManager.Commands.ServiceAccounts;
using Bit.Core.SecretsManager.Entities;
using Bit.Core.SecretsManager.Repositories;
using Bit.Test.Common.AutoFixture;
using Bit.Test.Common.AutoFixture.Attributes;
using Bit.Test.Common.Helpers;
using NSubstitute;
using Xunit;
namespace Bit.Commercial.Core.Test.SecretManagerFeatures.ServiceAccounts;
namespace Bit.Commercial.Core.Test.SecretsManager.ServiceAccounts;
[SutProviderCustomize]
public class CreateServiceAccountCommandTests

View File

@ -1,15 +1,15 @@
using Bit.Commercial.Core.SecretManagerFeatures.ServiceAccounts;
using Bit.Commercial.Core.SecretsManager.Commands.ServiceAccounts;
using Bit.Core.Context;
using Bit.Core.Entities;
using Bit.Core.Exceptions;
using Bit.Core.Repositories;
using Bit.Core.SecretsManager.Entities;
using Bit.Core.SecretsManager.Repositories;
using Bit.Test.Common.AutoFixture;
using Bit.Test.Common.AutoFixture.Attributes;
using Bit.Test.Common.Helpers;
using NSubstitute;
using Xunit;
namespace Bit.Commercial.Core.Test.SecretManagerFeatures.ServiceAccounts;
namespace Bit.Commercial.Core.Test.SecretsManager.ServiceAccounts;
[SutProviderCustomize]
public class UpdateServiceAccountCommandTests

View File

@ -1,12 +1,11 @@
using Bit.Api.SecretManagerFeatures.Models.Request;
using Bit.Api.SecretManagerFeatures.Models.Response;
using Bit.Api.Utilities;
using Bit.Core.Entities;
using Bit.Core.Repositories;
using Bit.Core.SecretManagerFeatures.AccessPolicies.Interfaces;
using Bit.Api.SecretsManager.Models.Request;
using Bit.Api.SecretsManager.Models.Response;
using Bit.Core.SecretsManager.Commands.AccessPolicies.Interfaces;
using Bit.Core.SecretsManager.Entities;
using Bit.Core.SecretsManager.Repositories;
using Microsoft.AspNetCore.Mvc;
namespace Bit.Api.Controllers;
namespace Bit.Api.SecretsManager.Controllers;
[SecretsManager]
[Route("access-policies")]

View File

@ -1,16 +1,15 @@
using Bit.Api.Models.Response;
using Bit.Api.SecretManagerFeatures.Models.Request;
using Bit.Api.SecretManagerFeatures.Models.Response;
using Bit.Api.Utilities;
using Bit.Api.SecretsManager.Models.Request;
using Bit.Api.SecretsManager.Models.Response;
using Bit.Core.Context;
using Bit.Core.Enums;
using Bit.Core.Exceptions;
using Bit.Core.Repositories;
using Bit.Core.SecretManagerFeatures.Projects.Interfaces;
using Bit.Core.SecretsManager.Commands.Projects.Interfaces;
using Bit.Core.SecretsManager.Repositories;
using Bit.Core.Services;
using Microsoft.AspNetCore.Mvc;
namespace Bit.Api.Controllers;
namespace Bit.Api.SecretsManager.Controllers;
[SecretsManager]
public class ProjectsController : Controller

View File

@ -1,14 +1,13 @@
using Bit.Api.Models.Response;
using Bit.Api.SecretManagerFeatures.Models.Request;
using Bit.Api.SecretManagerFeatures.Models.Response;
using Bit.Api.Utilities;
using Bit.Api.SecretsManager.Models.Request;
using Bit.Api.SecretsManager.Models.Response;
using Bit.Core.Exceptions;
using Bit.Core.Repositories;
using Bit.Core.SecretManagerFeatures.Secrets.Interfaces;
using Bit.Core.SecretsManager.Commands.Secrets.Interfaces;
using Bit.Core.SecretsManager.Repositories;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Bit.Api.Controllers;
namespace Bit.Api.SecretsManager.Controllers;
[SecretsManager]
[Authorize("secrets")]

View File

@ -1,18 +1,16 @@
using Bit.Api.Models.Response;
using Bit.Api.Models.Response.SecretsManager;
using Bit.Api.SecretManagerFeatures.Models.Request;
using Bit.Api.SecretManagerFeatures.Models.Response;
using Bit.Api.Utilities;
using Bit.Api.SecretsManager.Models.Request;
using Bit.Api.SecretsManager.Models.Response;
using Bit.Core.Context;
using Bit.Core.Enums;
using Bit.Core.Exceptions;
using Bit.Core.Repositories;
using Bit.Core.SecretManagerFeatures.AccessTokens.Interfaces;
using Bit.Core.SecretManagerFeatures.ServiceAccounts.Interfaces;
using Bit.Core.SecretsManager.Commands.AccessTokens.Interfaces;
using Bit.Core.SecretsManager.Commands.ServiceAccounts.Interfaces;
using Bit.Core.SecretsManager.Repositories;
using Bit.Core.Services;
using Microsoft.AspNetCore.Mvc;
namespace Bit.Api.Controllers;
namespace Bit.Api.SecretsManager.Controllers;
[SecretsManager]
[Route("service-accounts")]

View File

@ -1,9 +1,9 @@
#nullable enable
using System.ComponentModel.DataAnnotations;
using Bit.Core.Entities;
using Bit.Core.Exceptions;
using Bit.Core.SecretsManager.Entities;
namespace Bit.Api.SecretManagerFeatures.Models.Request;
namespace Bit.Api.SecretsManager.Models.Request;
public class AccessPoliciesCreateRequest
{

View File

@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations;
namespace Bit.Api.SecretManagerFeatures.Models.Request;
namespace Bit.Api.SecretsManager.Models.Request;
public class AccessPolicyUpdateRequest
{

View File

@ -1,8 +1,8 @@
using System.ComponentModel.DataAnnotations;
using Bit.Core.Entities;
using Bit.Core.SecretsManager.Entities;
using Bit.Core.Utilities;
namespace Bit.Api.SecretManagerFeatures.Models.Request;
namespace Bit.Api.SecretsManager.Models.Request;
public class AccessTokenCreateRequestModel
{

View File

@ -1,8 +1,8 @@
using System.ComponentModel.DataAnnotations;
using Bit.Core.Entities;
using Bit.Core.SecretsManager.Entities;
using Bit.Core.Utilities;
namespace Bit.Api.SecretManagerFeatures.Models.Request;
namespace Bit.Api.SecretsManager.Models.Request;
public class ProjectCreateRequestModel
{

View File

@ -1,8 +1,8 @@
using System.ComponentModel.DataAnnotations;
using Bit.Core.Entities;
using Bit.Core.SecretsManager.Entities;
using Bit.Core.Utilities;
namespace Bit.Api.SecretManagerFeatures.Models.Request;
namespace Bit.Api.SecretsManager.Models.Request;
public class ProjectUpdateRequestModel
{

View File

@ -1,8 +1,8 @@
using System.ComponentModel.DataAnnotations;
using Bit.Core.Entities;
using Bit.Core.SecretsManager.Entities;
using Bit.Core.Utilities;
namespace Bit.Api.SecretManagerFeatures.Models.Request;
namespace Bit.Api.SecretsManager.Models.Request;
public class SecretCreateRequestModel
{

View File

@ -1,8 +1,8 @@
using System.ComponentModel.DataAnnotations;
using Bit.Core.Entities;
using Bit.Core.SecretsManager.Entities;
using Bit.Core.Utilities;
namespace Bit.Api.SecretManagerFeatures.Models.Request;
namespace Bit.Api.SecretsManager.Models.Request;
public class SecretUpdateRequestModel
{

View File

@ -1,8 +1,8 @@
using System.ComponentModel.DataAnnotations;
using Bit.Core.Entities;
using Bit.Core.SecretsManager.Entities;
using Bit.Core.Utilities;
namespace Bit.Api.SecretManagerFeatures.Models.Request;
namespace Bit.Api.SecretsManager.Models.Request;
public class ServiceAccountUpdateRequestModel
{

View File

@ -1,8 +1,8 @@
using System.ComponentModel.DataAnnotations;
using Bit.Core.Entities;
using Bit.Core.SecretsManager.Entities;
using Bit.Core.Utilities;
namespace Bit.Api.SecretManagerFeatures.Models.Request;
namespace Bit.Api.SecretsManager.Models.Request;
public class ServiceAccountCreateRequestModel
{

View File

@ -1,8 +1,8 @@
#nullable enable
using Bit.Core.Entities;
using Bit.Core.Models.Api;
using Bit.Core.SecretsManager.Entities;
namespace Bit.Api.SecretManagerFeatures.Models.Response;
namespace Bit.Api.SecretsManager.Models.Response;
public abstract class BaseAccessPolicyResponseModel : ResponseModel
{

View File

@ -1,8 +1,8 @@
#nullable enable
using Bit.Core.Entities;
using Bit.Core.Models.Api;
using Bit.Core.SecretsManager.Entities;
namespace Bit.Api.SecretManagerFeatures.Models.Response;
namespace Bit.Api.SecretsManager.Models.Response;
public class AccessTokenCreationResponseModel : ResponseModel
{

View File

@ -1,7 +1,7 @@
using Bit.Core.Entities;
using Bit.Core.Models.Api;
using Bit.Core.Models.Api;
using Bit.Core.SecretsManager.Entities;
namespace Bit.Api.Models.Response.SecretsManager;
namespace Bit.Api.SecretsManager.Models.Response;
public class AccessTokenResponseModel : ResponseModel
{

View File

@ -1,7 +1,7 @@
#nullable enable
using Bit.Core.Models.Api;
namespace Bit.Api.SecretManagerFeatures.Models.Response;
namespace Bit.Api.SecretsManager.Models.Response;
public class BulkDeleteResponseModel : ResponseModel
{

View File

@ -1,7 +1,7 @@
using Bit.Core.Entities;
using Bit.Core.Models.Api;
using Bit.Core.Models.Api;
using Bit.Core.SecretsManager.Entities;
namespace Bit.Api.SecretManagerFeatures.Models.Response;
namespace Bit.Api.SecretsManager.Models.Response;
public class ProjectAccessPoliciesResponseModel : ResponseModel
{

View File

@ -1,7 +1,7 @@
using Bit.Core.Entities;
using Bit.Core.Models.Api;
using Bit.Core.Models.Api;
using Bit.Core.SecretsManager.Entities;
namespace Bit.Api.SecretManagerFeatures.Models.Response;
namespace Bit.Api.SecretsManager.Models.Response;
public class ProjectResponseModel : ResponseModel
{

View File

@ -1,7 +1,7 @@
using Bit.Core.Entities;
using Bit.Core.Models.Api;
using Bit.Core.Models.Api;
using Bit.Core.SecretsManager.Entities;
namespace Bit.Api.SecretManagerFeatures.Models.Response;
namespace Bit.Api.SecretsManager.Models.Response;
public class SecretResponseModel : ResponseModel
{

View File

@ -1,7 +1,7 @@
using Bit.Core.Entities;
using Bit.Core.Models.Api;
using Bit.Core.Models.Api;
using Bit.Core.SecretsManager.Entities;
namespace Bit.Api.SecretManagerFeatures.Models.Response;
namespace Bit.Api.SecretsManager.Models.Response;
public class SecretWithProjectsListResponseModel : ResponseModel
{

View File

@ -1,7 +1,7 @@
using Bit.Core.Entities;
using Bit.Core.Models.Api;
using Bit.Core.Models.Api;
using Bit.Core.SecretsManager.Entities;
namespace Bit.Api.SecretManagerFeatures.Models.Response;
namespace Bit.Api.SecretsManager.Models.Response;
public class ServiceAccountResponseModel : ResponseModel
{

View File

@ -1,7 +1,7 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
namespace Bit.Api.Utilities;
namespace Bit.Api.SecretsManager;
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
public class SecretsManagerAttribute : Attribute, IResourceFilter

View File

@ -15,8 +15,9 @@ using Bit.SharedWeb.Utilities;
using Microsoft.Extensions.DependencyInjection.Extensions;
#if !OSS
using Bit.Commercial.Core.SecretsManager;
using Bit.Commercial.Core.Utilities;
using Bit.Commercial.Infrastructure.EntityFramework;
using Bit.Commercial.Infrastructure.EntityFramework.SecretsManager;
#endif
namespace Bit.Api;
@ -137,7 +138,7 @@ public class Startup
#else
services.AddCommercialCoreServices();
services.AddCommercialSecretsManagerServices();
services.AddCommercialEFRepositories();
services.AddSecretsManagerEfRepositories();
#endif
// MVC

View File

@ -1,8 +0,0 @@
using Bit.Core.Entities;
namespace Bit.Core.SecretManagerFeatures.AccessTokens.Interfaces;
public interface ICreateAccessTokenCommand
{
Task<ApiKey> CreateAsync(ApiKey apiKey, Guid userId);
}

View File

@ -1,8 +0,0 @@
using Bit.Core.Entities;
namespace Bit.Core.SecretManagerFeatures.Projects.Interfaces;
public interface ICreateProjectCommand
{
Task<Project> CreateAsync(Project project);
}

View File

@ -1,8 +0,0 @@
using Bit.Core.Entities;
namespace Bit.Core.SecretManagerFeatures.Secrets.Interfaces;
public interface ICreateSecretCommand
{
Task<Secret> CreateAsync(Secret secret);
}

View File

@ -1,8 +0,0 @@
using Bit.Core.Entities;
namespace Bit.Core.SecretManagerFeatures.Secrets.Interfaces;
public interface IUpdateSecretCommand
{
Task<Secret> UpdateAsync(Secret secret);
}

View File

@ -1,6 +1,6 @@
using Bit.Core.Entities;
using Bit.Core.SecretsManager.Entities;
namespace Bit.Core.SecretManagerFeatures.AccessPolicies.Interfaces;
namespace Bit.Core.SecretsManager.Commands.AccessPolicies.Interfaces;
public interface ICreateAccessPoliciesCommand
{

View File

@ -1,4 +1,4 @@
namespace Bit.Core.SecretManagerFeatures.AccessPolicies.Interfaces;
namespace Bit.Core.SecretsManager.Commands.AccessPolicies.Interfaces;
public interface IDeleteAccessPolicyCommand
{

View File

@ -1,6 +1,6 @@
using Bit.Core.Entities;
using Bit.Core.SecretsManager.Entities;
namespace Bit.Core.SecretManagerFeatures.AccessPolicies.Interfaces;
namespace Bit.Core.SecretsManager.Commands.AccessPolicies.Interfaces;
public interface IUpdateAccessPolicyCommand
{

View File

@ -0,0 +1,8 @@
using Bit.Core.SecretsManager.Entities;
namespace Bit.Core.SecretsManager.Commands.AccessTokens.Interfaces;
public interface ICreateAccessTokenCommand
{
Task<ApiKey> CreateAsync(ApiKey apiKey, Guid userId);
}

View File

@ -0,0 +1,8 @@
using Bit.Core.SecretsManager.Entities;
namespace Bit.Core.SecretsManager.Commands.Projects.Interfaces;
public interface ICreateProjectCommand
{
Task<Project> CreateAsync(Project project);
}

View File

@ -1,6 +1,6 @@
using Bit.Core.Entities;
using Bit.Core.SecretsManager.Entities;
namespace Bit.Core.SecretManagerFeatures.Projects.Interfaces;
namespace Bit.Core.SecretsManager.Commands.Projects.Interfaces;
public interface IDeleteProjectCommand
{

View File

@ -1,6 +1,6 @@
using Bit.Core.Entities;
using Bit.Core.SecretsManager.Entities;
namespace Bit.Core.SecretManagerFeatures.Projects.Interfaces;
namespace Bit.Core.SecretsManager.Commands.Projects.Interfaces;
public interface IUpdateProjectCommand
{

View File

@ -0,0 +1,8 @@
using Bit.Core.SecretsManager.Entities;
namespace Bit.Core.SecretsManager.Commands.Secrets.Interfaces;
public interface ICreateSecretCommand
{
Task<Secret> CreateAsync(Secret secret);
}

View File

@ -1,6 +1,6 @@
using Bit.Core.Entities;
using Bit.Core.SecretsManager.Entities;
namespace Bit.Core.SecretManagerFeatures.Secrets.Interfaces;
namespace Bit.Core.SecretsManager.Commands.Secrets.Interfaces;
public interface IDeleteSecretCommand
{

View File

@ -0,0 +1,8 @@
using Bit.Core.SecretsManager.Entities;
namespace Bit.Core.SecretsManager.Commands.Secrets.Interfaces;
public interface IUpdateSecretCommand
{
Task<Secret> UpdateAsync(Secret secret);
}

View File

@ -1,6 +1,6 @@
using Bit.Core.Entities;
using Bit.Core.SecretsManager.Entities;
namespace Bit.Core.SecretManagerFeatures.ServiceAccounts.Interfaces;
namespace Bit.Core.SecretsManager.Commands.ServiceAccounts.Interfaces;
public interface ICreateServiceAccountCommand
{

View File

@ -1,6 +1,6 @@
using Bit.Core.Entities;
using Bit.Core.SecretsManager.Entities;
namespace Bit.Core.SecretManagerFeatures.ServiceAccounts.Interfaces;
namespace Bit.Core.SecretsManager.Commands.ServiceAccounts.Interfaces;
public interface IUpdateServiceAccountCommand
{

View File

@ -1,7 +1,8 @@
#nullable enable
using Bit.Core.Entities;
using Bit.Core.Utilities;
namespace Bit.Core.Entities;
namespace Bit.Core.SecretsManager.Entities;
public abstract class BaseAccessPolicy
{

View File

@ -1,7 +1,8 @@
using System.ComponentModel.DataAnnotations;
using Bit.Core.Entities;
using Bit.Core.Utilities;
namespace Bit.Core.Entities;
namespace Bit.Core.SecretsManager.Entities;
public class ApiKey : ITableObject<Guid>
{

View File

@ -1,7 +1,8 @@
#nullable enable
using Bit.Core.Entities;
using Bit.Core.Utilities;
namespace Bit.Core.Entities;
namespace Bit.Core.SecretsManager.Entities;
public class Project : ITableObject<Guid>
{

View File

@ -1,7 +1,8 @@
#nullable enable
using Bit.Core.Entities;
using Bit.Core.Utilities;
namespace Bit.Core.Entities;
namespace Bit.Core.SecretsManager.Entities;
public class Secret : ITableObject<Guid>
{

View File

@ -1,7 +1,8 @@
#nullable enable
using Bit.Core.Entities;
using Bit.Core.Utilities;
namespace Bit.Core.Entities;
namespace Bit.Core.SecretsManager.Entities;
public class ServiceAccount : ITableObject<Guid>
{

View File

@ -1,6 +1,6 @@
using Bit.Core.Entities;
using Bit.Core.SecretsManager.Entities;
namespace Bit.Core.Models.Data;
namespace Bit.Core.SecretsManager.Models.Data;
public class ApiKeyDetails : ApiKey
{

View File

@ -1,7 +1,7 @@
#nullable enable
using Bit.Core.Entities;
using Bit.Core.SecretsManager.Entities;
namespace Bit.Core.Repositories;
namespace Bit.Core.SecretsManager.Repositories;
public interface IAccessPolicyRepository
{

View File

@ -1,7 +1,8 @@
using Bit.Core.Entities;
using Bit.Core.Models.Data;
using Bit.Core.Repositories;
using Bit.Core.SecretsManager.Entities;
using Bit.Core.SecretsManager.Models.Data;
namespace Bit.Core.Repositories;
namespace Bit.Core.SecretsManager.Repositories;
public interface IApiKeyRepository : IRepository<ApiKey, Guid>
{

View File

@ -1,7 +1,7 @@
using Bit.Core.Entities;
using Bit.Core.Enums;
using Bit.Core.Enums;
using Bit.Core.SecretsManager.Entities;
namespace Bit.Core.Repositories;
namespace Bit.Core.SecretsManager.Repositories;
public interface IProjectRepository
{

View File

@ -1,6 +1,6 @@
using Bit.Core.Entities;
using Bit.Core.SecretsManager.Entities;
namespace Bit.Core.Repositories;
namespace Bit.Core.SecretsManager.Repositories;
public interface ISecretRepository
{

View File

@ -1,7 +1,7 @@
using Bit.Core.Entities;
using Bit.Core.Enums;
using Bit.Core.Enums;
using Bit.Core.SecretsManager.Entities;
namespace Bit.Core.Repositories;
namespace Bit.Core.SecretsManager.Repositories;
public interface IServiceAccountRepository
{

View File

@ -4,8 +4,9 @@ using Bit.Core.Context;
using Bit.Core.Enums;
using Bit.Core.Identity;
using Bit.Core.IdentityServer;
using Bit.Core.Models.Data;
using Bit.Core.Repositories;
using Bit.Core.SecretsManager.Models.Data;
using Bit.Core.SecretsManager.Repositories;
using Bit.Core.Services;
using Bit.Core.Settings;
using Bit.Core.Utilities;

View File

@ -1,5 +1,7 @@
using Bit.Core.Repositories;
using Bit.Core.SecretsManager.Repositories;
using Bit.Infrastructure.Dapper.Repositories;
using Bit.Infrastructure.Dapper.SecretsManager.Repositories;
using Microsoft.Extensions.DependencyInjection;
namespace Bit.Infrastructure.Dapper;

View File

@ -1,12 +1,13 @@
using System.Data;
using Bit.Core.Entities;
using Bit.Core.Models.Data;
using Bit.Core.Repositories;
using Bit.Core.SecretsManager.Entities;
using Bit.Core.SecretsManager.Models.Data;
using Bit.Core.SecretsManager.Repositories;
using Bit.Core.Settings;
using Bit.Infrastructure.Dapper.Repositories;
using Dapper;
using Microsoft.Data.SqlClient;
namespace Bit.Infrastructure.Dapper.Repositories;
namespace Bit.Infrastructure.Dapper.SecretsManager.Repositories;
public class ApiKeyRepository : Repository<ApiKey, Guid>, IApiKeyRepository
{

View File

@ -1,6 +1,8 @@
using Bit.Core.Enums;
using Bit.Core.Repositories;
using Bit.Core.SecretsManager.Repositories;
using Bit.Infrastructure.EntityFramework.Repositories;
using Bit.Infrastructure.EntityFramework.SecretsManager.Repositories;
using LinqToDB.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;

View File

@ -1,16 +0,0 @@
using AutoMapper;
namespace Bit.Infrastructure.EntityFramework.Models;
public class ApiKey : Core.Entities.ApiKey
{
public virtual ServiceAccount ServiceAccount { get; set; }
}
public class ApiKeyMapperProfile : Profile
{
public ApiKeyMapperProfile()
{
CreateMap<Core.Entities.ApiKey, ApiKey>().ReverseMap();
}
}

View File

@ -1,6 +1,7 @@
using Bit.Core;
using Bit.Infrastructure.EntityFramework.Converters;
using Bit.Infrastructure.EntityFramework.Models;
using Bit.Infrastructure.EntityFramework.SecretsManager.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;

View File

@ -1,8 +1,8 @@
using Bit.Infrastructure.EntityFramework.Models;
using Bit.Infrastructure.EntityFramework.SecretsManager.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Bit.Infrastructure.EntityFramework.Configurations;
namespace Bit.Infrastructure.EntityFramework.SecretsManager.Configurations;
public class AccessPolicyEntityTypeConfiguration : IEntityTypeConfiguration<AccessPolicy>
{

View File

@ -1,8 +1,8 @@
using Bit.Infrastructure.EntityFramework.Models;
using Bit.Infrastructure.EntityFramework.SecretsManager.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Bit.Infrastructure.EntityFramework.Configurations;
namespace Bit.Infrastructure.EntityFramework.SecretsManager.Configurations;
public class ApiKeyEntityTypeConfiguration : IEntityTypeConfiguration<ApiKey>
{

View File

@ -1,8 +1,8 @@
using Bit.Infrastructure.EntityFramework.Models;
using Bit.Infrastructure.EntityFramework.SecretsManager.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Bit.Infrastructure.EntityFramework.Configurations;
namespace Bit.Infrastructure.EntityFramework.SecretsManager.Configurations;
public class ProjectEntityTypeConfiguration : IEntityTypeConfiguration<Project>
{

View File

@ -1,8 +1,8 @@
using Bit.Infrastructure.EntityFramework.Models;
using Bit.Infrastructure.EntityFramework.SecretsManager.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Bit.Infrastructure.EntityFramework.Configurations;
namespace Bit.Infrastructure.EntityFramework.SecretsManager.Configurations;
public class SecretEntityTypeConfiguration : IEntityTypeConfiguration<Secret>
{

View File

@ -1,7 +1,9 @@
using Bit.Infrastructure.EntityFramework.Models;
using Bit.Infrastructure.EntityFramework.SecretsManager.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Bit.Infrastructure.EntityFramework.SecretsManager.Configurations;
public class ServiceAccountEntityTypeConfiguration : IEntityTypeConfiguration<ServiceAccount>
{
public void Configure(EntityTypeBuilder<ServiceAccount> builder)

View File

@ -1,8 +1,9 @@
using AutoMapper;
using Bit.Infrastructure.EntityFramework.Models;
namespace Bit.Infrastructure.EntityFramework.Models;
namespace Bit.Infrastructure.EntityFramework.SecretsManager.Models;
public class BaseAccessPolicy : Core.Entities.BaseAccessPolicy
public class BaseAccessPolicy : Core.SecretsManager.Entities.BaseAccessPolicy
{
public string Discriminator { get; set; }
}
@ -11,13 +12,13 @@ public class AccessPolicyMapperProfile : Profile
{
public AccessPolicyMapperProfile()
{
CreateMap<Core.Entities.UserProjectAccessPolicy, UserProjectAccessPolicy>().ReverseMap()
CreateMap<Core.SecretsManager.Entities.UserProjectAccessPolicy, UserProjectAccessPolicy>().ReverseMap()
.ForMember(dst => dst.User, opt => opt.MapFrom(src => src.OrganizationUser.User));
CreateMap<Core.Entities.UserServiceAccountAccessPolicy, UserServiceAccountAccessPolicy>().ReverseMap()
CreateMap<Core.SecretsManager.Entities.UserServiceAccountAccessPolicy, UserServiceAccountAccessPolicy>().ReverseMap()
.ForMember(dst => dst.User, opt => opt.MapFrom(src => src.OrganizationUser.User));
CreateMap<Core.Entities.GroupProjectAccessPolicy, GroupProjectAccessPolicy>().ReverseMap();
CreateMap<Core.Entities.GroupServiceAccountAccessPolicy, GroupServiceAccountAccessPolicy>().ReverseMap();
CreateMap<Core.Entities.ServiceAccountProjectAccessPolicy, ServiceAccountProjectAccessPolicy>().ReverseMap();
CreateMap<Core.SecretsManager.Entities.GroupProjectAccessPolicy, GroupProjectAccessPolicy>().ReverseMap();
CreateMap<Core.SecretsManager.Entities.GroupServiceAccountAccessPolicy, GroupServiceAccountAccessPolicy>().ReverseMap();
CreateMap<Core.SecretsManager.Entities.ServiceAccountProjectAccessPolicy, ServiceAccountProjectAccessPolicy>().ReverseMap();
}
}

View File

@ -0,0 +1,16 @@
using AutoMapper;
namespace Bit.Infrastructure.EntityFramework.SecretsManager.Models;
public class ApiKey : Core.SecretsManager.Entities.ApiKey
{
public virtual ServiceAccount ServiceAccount { get; set; }
}
public class ApiKeyMapperProfile : Profile
{
public ApiKeyMapperProfile()
{
CreateMap<Core.SecretsManager.Entities.ApiKey, ApiKey>().ReverseMap();
}
}

View File

@ -1,8 +1,9 @@
using AutoMapper;
using Bit.Infrastructure.EntityFramework.Models;
namespace Bit.Infrastructure.EntityFramework.Models;
namespace Bit.Infrastructure.EntityFramework.SecretsManager.Models;
public class Project : Core.Entities.Project
public class Project : Core.SecretsManager.Entities.Project
{
public virtual new ICollection<Secret> Secrets { get; set; }
public virtual Organization Organization { get; set; }
@ -15,7 +16,7 @@ public class ProjectMapperProfile : Profile
{
public ProjectMapperProfile()
{
CreateMap<Core.Entities.Project, Project>()
CreateMap<Core.SecretsManager.Entities.Project, Project>()
.PreserveReferences()
.ReverseMap();
}

View File

@ -1,8 +1,9 @@
using AutoMapper;
using Bit.Infrastructure.EntityFramework.Models;
namespace Bit.Infrastructure.EntityFramework.Models;
namespace Bit.Infrastructure.EntityFramework.SecretsManager.Models;
public class Secret : Core.Entities.Secret
public class Secret : Core.SecretsManager.Entities.Secret
{
public virtual new ICollection<Project> Projects { get; set; }
public virtual Organization Organization { get; set; }
@ -12,7 +13,7 @@ public class SecretMapperProfile : Profile
{
public SecretMapperProfile()
{
CreateMap<Core.Entities.Secret, Secret>()
CreateMap<Core.SecretsManager.Entities.Secret, Secret>()
.PreserveReferences()
.ReverseMap();
}

View File

@ -1,8 +1,9 @@
using AutoMapper;
using Bit.Infrastructure.EntityFramework.Models;
namespace Bit.Infrastructure.EntityFramework.Models;
namespace Bit.Infrastructure.EntityFramework.SecretsManager.Models;
public class ServiceAccount : Core.Entities.ServiceAccount
public class ServiceAccount : Core.SecretsManager.Entities.ServiceAccount
{
public virtual Organization Organization { get; set; }
public virtual ICollection<GroupServiceAccountAccessPolicy> GroupAccessPolicies { get; set; }
@ -13,6 +14,6 @@ public class ServiceAccountMapperProfile : Profile
{
public ServiceAccountMapperProfile()
{
CreateMap<Core.Entities.ServiceAccount, ServiceAccount>().ReverseMap();
CreateMap<Core.SecretsManager.Entities.ServiceAccount, ServiceAccount>().ReverseMap();
}
}

View File

@ -1,13 +1,14 @@
using AutoMapper;
using Bit.Core.Models.Data;
using Bit.Core.Repositories;
using Bit.Infrastructure.EntityFramework.Models;
using Bit.Core.SecretsManager.Models.Data;
using Bit.Core.SecretsManager.Repositories;
using Bit.Infrastructure.EntityFramework.Repositories;
using Bit.Infrastructure.EntityFramework.SecretsManager.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace Bit.Infrastructure.EntityFramework.Repositories;
namespace Bit.Infrastructure.EntityFramework.SecretsManager.Repositories;
public class ApiKeyRepository : Repository<Core.Entities.ApiKey, ApiKey, Guid>, IApiKeyRepository
public class ApiKeyRepository : Repository<Core.SecretsManager.Entities.ApiKey, ApiKey, Guid>, IApiKeyRepository
{
public ApiKeyRepository(IServiceScopeFactory serviceScopeFactory, IMapper mapper)
: base(serviceScopeFactory, mapper, (DatabaseContext context) => context.ApiKeys)
@ -27,12 +28,12 @@ public class ApiKeyRepository : Repository<Core.Entities.ApiKey, ApiKey, Guid>,
return Mapper.Map<ServiceAccountApiKeyDetails>(entity);
}
public async Task<ICollection<Core.Entities.ApiKey>> GetManyByServiceAccountIdAsync(Guid id)
public async Task<ICollection<Core.SecretsManager.Entities.ApiKey>> GetManyByServiceAccountIdAsync(Guid id)
{
using var scope = ServiceScopeFactory.CreateScope();
var dbContext = GetDatabaseContext(scope);
var apiKeys = await GetDbSet(dbContext).Where(e => e.ServiceAccountId == id).ToListAsync();
return Mapper.Map<List<Core.Entities.ApiKey>>(apiKeys);
return Mapper.Map<List<Core.SecretsManager.Entities.ApiKey>>(apiKeys);
}
}

Some files were not shown because too many files have changed in this diff Show More