Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AC-1512] Feature: Secrets Manager Billing - round 2 #3119

Merged
merged 64 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
fd51797
[AC-1423] Add AddonProduct and BitwardenProduct properties to Billing…
shane-melton Jun 29, 2023
039e216
Merge remote-tracking branch 'origin/master' into feature/sm-billing
eliykat Jun 29, 2023
12e6696
Add SecretsManagerBilling feature flag to Constants
eliykat Jun 29, 2023
46b2260
[AC 1409] Secrets Manager Subscription Stripe Integration (#3019)
cyprain-okeke Jul 1, 2023
9062672
SM-802: Add SecretsManagerBetaColumn SQL migration and Org table update
coltonhurst Jul 3, 2023
66185f0
SM-802: Run EF Migrations for SecretsManagerBeta
coltonhurst Jul 3, 2023
c9745cd
SM-802: Update the two Org procs and View, and move data migration to…
coltonhurst Jul 3, 2023
f00f552
SM-802: Add missing comma to Organization_Create
coltonhurst Jul 3, 2023
6c0c9c6
[AC-1418] Add missing SecretsManagerPlan property to OrganizationResp…
shane-melton Jul 3, 2023
6a5d5a9
SM-802: Remove extra GO statement from data migration script
coltonhurst Jul 4, 2023
4a88894
Merge remote-tracking branch 'origin/master' into feature/sm-billing
eliykat Jul 4, 2023
692c7ff
[AC 1460] Update Stripe Configuration (#3070)
cyprain-okeke Jul 4, 2023
45b6954
SM-802: Add SecretsManagerBeta to OrganizationResponseModel
coltonhurst Jul 5, 2023
9cc1774
SM-802: Move SecretsManagerBeta from OrganizationResponseModel to Org…
coltonhurst Jul 7, 2023
2a441c1
SM-802: Remove OrganizationUserOrganizationDetailsView.sql changes
coltonhurst Jul 7, 2023
a1f8ca8
[AC 1410] Secrets Manager subscription adjustment back-end changes (#…
cyprain-okeke Jul 10, 2023
ce03d38
Merge branch 'master' into feature/sm-billing
eliykat Jul 10, 2023
2cc3fcd
SM-802: Remove SecretsManagerBetaColumn migration
coltonhurst Jul 10, 2023
88338a9
SM-802: Add SecretsManagerBetaColumn migration
coltonhurst Jul 10, 2023
052b61e
Merge branch 'master' into sm/SM-802
coltonhurst Jul 10, 2023
d5682ce
SM-802: Remove OrganizationUserOrganizationDetailsView update
coltonhurst Jul 10, 2023
a5efec3
[AC-1495] Extract UpgradePlanAsync into a command (#3081)
eliykat Jul 11, 2023
cab23cb
[AC-1503] Fix Stripe integration on organization upgrade (#3084)
eliykat Jul 11, 2023
3a6b17b
[AC-1504] Allow SM max autoscale limits to be disabled (#3085)
eliykat Jul 11, 2023
3ea14a2
[AC-1488] Changed SM Signup and Upgrade paths to set SmServiceAccount…
r-tome Jul 11, 2023
0ec3020
[AC-1510] Enable access to Secrets Manager to Organization owner for …
cyprain-okeke Jul 11, 2023
38ff569
Merge branch 'master' into feature/sm-billing
eliykat Jul 12, 2023
e1bede1
Revert changes to ReferenceEvent code (#3091)
eliykat Jul 12, 2023
b14c383
Revert ReferenceEventType change
eliykat Jul 13, 2023
aa5c200
Move NoopServiceAccountRepository to SM and update namespace
eliykat Jul 13, 2023
a9dcc32
Merge branch 'master' into feature/sm-billing
eliykat Jul 13, 2023
f714744
Merge branch 'master' into sm/SM-802
coltonhurst Jul 13, 2023
99b598a
Merge branch 'master' into feature/sm-billing
eliykat Jul 14, 2023
a79a523
Merge branch 'master' into feature/sm-billing
cturnbull-bitwarden Jul 14, 2023
0277a70
[AC-1462] Add secrets manager service accounts autoscaling commands (…
r-tome Jul 17, 2023
e3387c2
Add UsePasswordManager to sync data (#3114)
eliykat Jul 18, 2023
1b6898e
[AC-1522] Fix service account check on upgrading (#3111)
eliykat Jul 18, 2023
10f671a
Merge branch 'master' into feature/sm-billing
eliykat Jul 18, 2023
3659e7a
Merge branch 'feature/sm-billing' into feature/sm-billing-round-2
eliykat Jul 19, 2023
1087f66
Resolved the checkmarx issues
cyprain-okeke Jul 19, 2023
c72d29b
[AC-1521] Address checkmarx security feedback (#3124)
eliykat Jul 19, 2023
ec31bb6
Merge branch 'master' into sm/SM-802
coltonhurst Jul 20, 2023
2e7a480
Merge branch 'master' into feature/sm-billing
r-tome Jul 21, 2023
2c0ff09
Update date on migration script
eliykat Jul 24, 2023
4fcb9da
Remove unused constant
cyprain-okeke Jul 24, 2023
5b215cd
Merge branch 'feature/sm-billing' of https://github.com/bitwarden/ser…
cyprain-okeke Jul 24, 2023
fd4e306
Revert "Remove unused constant"
eliykat Jul 24, 2023
a2e2dd6
Merge branch 'feature/sm-billing' into feature/sm-billing-round-2
eliykat Jul 24, 2023
92514d1
Merge remote-tracking branch 'origin/master' into feature/sm-billing-…
eliykat Jul 25, 2023
7858d59
[AC-1458] Add Endpoint And Service Logic for secrets manager to exist…
cyprain-okeke Jul 25, 2023
13ee404
Merge remote-tracking branch 'origin/sm/SM-802' into feature/sm-billi…
eliykat Jul 25, 2023
2ded9d6
Merge remote-tracking branch 'origin/master' into feature/sm-billing-…
eliykat Jul 26, 2023
e805405
Merge remote-tracking branch 'origin/master' into feature/sm-billing-…
eliykat Jul 27, 2023
2dd0013
Remove duplicate migrations from incorrectly resolved merge
eliykat Jul 27, 2023
d35de15
[AC-1468] Modified CountNewServiceAccountSlotsRequiredQuery to return…
r-tome Jul 27, 2023
fb569a9
[Ac 1563] Unable to load billing and subscription related pages for n…
cyprain-okeke Jul 31, 2023
f69bf1a
[SM-809] Add service account slot limit check (#3093)
Thomas-Avery Jul 31, 2023
aa9d752
Merge branch 'master' into feature/sm-billing-round-2
eliykat Jul 31, 2023
88b81e3
[AC-1461] Secrets manager seat autoscaling (#3121)
eliykat Jul 31, 2023
d905bbb
Move bitwarden_license include reference into conditional block
eliykat Jul 31, 2023
59bfecd
Merge branch 'master' into feature/sm-billing-round-2
eliykat Aug 2, 2023
a128454
[AC 1526]Show current SM seat and service account usage in Bitwarden …
cyprain-okeke Aug 2, 2023
b7ebd7e
Merge branch 'master' into feature/sm-billing-round-2
eliykat Aug 3, 2023
5b0a701
Merge branch 'master' into feature/sm-billing-round-2
r-tome Aug 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using Bit.Core.Exceptions;
using Bit.Core.Repositories;
using Bit.Core.SecretsManager.Queries.ServiceAccounts.Interfaces;
using Bit.Core.SecretsManager.Repositories;

namespace Bit.Commercial.Core.SecretsManager.Queries.ServiceAccounts;

public class CountNewServiceAccountSlotsRequiredQuery : ICountNewServiceAccountSlotsRequiredQuery
{
private readonly IOrganizationRepository _organizationRepository;
private readonly IServiceAccountRepository _serviceAccountRepository;

public CountNewServiceAccountSlotsRequiredQuery(
IOrganizationRepository organizationRepository,
IServiceAccountRepository serviceAccountRepository)
{
_organizationRepository = organizationRepository;
_serviceAccountRepository = serviceAccountRepository;
}

public async Task<int> CountNewServiceAccountSlotsRequiredAsync(Guid organizationId, int serviceAccountsToAdd)
{
var organization = await _organizationRepository.GetByIdAsync(organizationId);
if (organization == null || !organization.UseSecretsManager)
{
throw new NotFoundException();
}

if (!organization.SmServiceAccounts.HasValue || serviceAccountsToAdd == 0 || organization.SecretsManagerBeta)
{
return 0;
}

var serviceAccountCount = await _serviceAccountRepository.GetServiceAccountCountByOrganizationIdAsync(organizationId);
var availableServiceAccountSlots = organization.SmServiceAccounts.Value - serviceAccountCount;

if (availableServiceAccountSlots >= serviceAccountsToAdd)
{
return 0;
}

return serviceAccountsToAdd - availableServiceAccountSlots;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public static void AddSecretsManagerServices(this IServiceCollection services)
services.AddScoped<ICreateServiceAccountCommand, CreateServiceAccountCommand>();
services.AddScoped<IUpdateServiceAccountCommand, UpdateServiceAccountCommand>();
services.AddScoped<IDeleteServiceAccountsCommand, DeleteServiceAccountsCommand>();
services.AddScoped<ICountNewServiceAccountSlotsRequiredQuery, CountNewServiceAccountSlotsRequiredQuery>();
services.AddScoped<IRevokeAccessTokensCommand, RevokeAccessTokensCommand>();
services.AddScoped<ICreateAccessTokenCommand, CreateAccessTokenCommand>();
services.AddScoped<ICreateAccessPoliciesCommand, CreateAccessPoliciesCommand>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ public async Task<IEnumerable<ProjectPermissionDetails>> GetManyByOrganizationId
return await projects.ToListAsync();
}

public async Task<int> GetProjectCountByOrganizationIdAsync(Guid organizationId)
{
using (var scope = ServiceScopeFactory.CreateScope())
{
var dbContext = GetDatabaseContext(scope);
return await dbContext.Project
.CountAsync(ou => ou.OrganizationId == organizationId);
}
}

public async Task<IEnumerable<Core.SecretsManager.Entities.Project>> GetManyByOrganizationIdWriteAccessAsync(
Guid organizationId, Guid userId, AccessClientType accessType)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ public async Task<IEnumerable<SecretPermissionDetails>> GetManyByOrganizationIdA
return await secrets.ToListAsync();
}

public async Task<int> GetSecretsCountByOrganizationIdAsync(Guid organizationId)
{
using (var scope = ServiceScopeFactory.CreateScope())
{
var dbContext = GetDatabaseContext(scope);
return await dbContext.Secret
.CountAsync(ou => ou.OrganizationId == organizationId && ou.DeletedDate == null);
}
}

public async Task<IEnumerable<Core.SecretsManager.Entities.Secret>> GetManyByOrganizationIdInTrashByIdsAsync(Guid organizationId, IEnumerable<Guid> ids)
{
using (var scope = ServiceScopeFactory.CreateScope())
Expand Down
6 changes: 6 additions & 0 deletions bitwarden_license/src/Scim/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.Globalization;
using Bit.Core.Context;
using Bit.Core.SecretsManager.Repositories;
using Bit.Core.SecretsManager.Repositories.Noop;
using Bit.Core.Settings;
using Bit.Core.Utilities;
using Bit.Scim.Context;
Expand Down Expand Up @@ -69,6 +71,10 @@ public void ConfigureServices(IServiceCollection services)

services.TryAddSingleton<IHttpContextAccessor, HttpContextAccessor>();

// TODO: Remove when OrganizationUser methods are moved out of OrganizationService, this noop dependency should
// TODO: no longer be required - see PM-1880
services.AddScoped<IServiceAccountRepository, NoopServiceAccountRepository>();

// Mvc
services.AddMvc(config =>
{
Expand Down
6 changes: 6 additions & 0 deletions bitwarden_license/src/Sso/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Bit.Core;
using Bit.Core.Context;
using Bit.Core.SecretsManager.Repositories;
using Bit.Core.SecretsManager.Repositories.Noop;
using Bit.Core.Settings;
using Bit.Core.Utilities;
using Bit.SharedWeb.Utilities;
Expand Down Expand Up @@ -78,6 +80,10 @@ public void ConfigureServices(IServiceCollection services)
services.AddBaseServices(globalSettings);
services.AddDefaultServices(globalSettings);
services.AddCoreLocalizationServices();

// TODO: Remove when OrganizationUser methods are moved out of OrganizationService, this noop dependency should
// TODO: no longer be required - see PM-1880
services.AddScoped<IServiceAccountRepository, NoopServiceAccountRepository>();
}

public void Configure(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
using Bit.Commercial.Core.SecretsManager.Queries.ServiceAccounts;
using Bit.Core.Entities;
using Bit.Core.Exceptions;
using Bit.Core.Repositories;
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.SecretsManager.Queries.ServiceAccounts;

[SutProviderCustomize]
public class CountNewServiceAccountSlotsRequiredQueryTests
{
[Theory]
[BitAutoData(2, 5, 2, 0)]
[BitAutoData(0, 5, 2, 0)]
[BitAutoData(6, 5, 2, 3)]
[BitAutoData(2, 5, 10, 7)]
public async Task CountNewServiceAccountSlotsRequiredAsync_ReturnsCorrectCount(
int serviceAccountsToAdd,
int organizationSmServiceAccounts,
int currentServiceAccounts,
int expectedNewServiceAccountsRequired,
Organization organization,
SutProvider<CountNewServiceAccountSlotsRequiredQuery> sutProvider)
{
organization.UseSecretsManager = true;
organization.SmServiceAccounts = organizationSmServiceAccounts;
organization.SecretsManagerBeta = false;

sutProvider.GetDependency<IOrganizationRepository>()
.GetByIdAsync(organization.Id)
.Returns(organization);

sutProvider.GetDependency<IServiceAccountRepository>()
.GetServiceAccountCountByOrganizationIdAsync(organization.Id)
.Returns(currentServiceAccounts);

var result = await sutProvider.Sut.CountNewServiceAccountSlotsRequiredAsync(organization.Id, serviceAccountsToAdd);

Assert.Equal(expectedNewServiceAccountsRequired, result);

if (serviceAccountsToAdd > 0)
{
await sutProvider.GetDependency<IServiceAccountRepository>().Received(1)
.GetServiceAccountCountByOrganizationIdAsync(organization.Id);
}
}

[Theory]
[BitAutoData(0)]
[BitAutoData(5)]
public async Task CountNewServiceAccountSlotsRequiredAsync_WithNullSmServiceAccounts_ReturnsZero(
int currentServiceAccounts,
int serviceAccountsToAdd,
Organization organization,
SutProvider<CountNewServiceAccountSlotsRequiredQuery> sutProvider)
{
const int expectedRequiredServiceAccountsToScale = 0;

organization.UseSecretsManager = true;
organization.SmServiceAccounts = null;
organization.SecretsManagerBeta = false;

sutProvider.GetDependency<IOrganizationRepository>()
.GetByIdAsync(organization.Id)
.Returns(organization);

sutProvider.GetDependency<IServiceAccountRepository>()
.GetServiceAccountCountByOrganizationIdAsync(organization.Id)
.Returns(currentServiceAccounts);

var result = await sutProvider.Sut.CountNewServiceAccountSlotsRequiredAsync(organization.Id, serviceAccountsToAdd);

Assert.Equal(expectedRequiredServiceAccountsToScale, result);

await sutProvider.GetDependency<IServiceAccountRepository>().DidNotReceiveWithAnyArgs()
.GetServiceAccountCountByOrganizationIdAsync(default);
}

[Theory, BitAutoData]
public async Task CountNewServiceAccountSlotsRequiredAsync_WithSecretsManagerBeta_ReturnsZero(
int serviceAccountsToAdd,
Organization organization,
SutProvider<CountNewServiceAccountSlotsRequiredQuery> sutProvider)
{
organization.UseSecretsManager = true;
organization.SecretsManagerBeta = true;

sutProvider.GetDependency<IOrganizationRepository>()
.GetByIdAsync(organization.Id)
.Returns(organization);

var result = await sutProvider.Sut.CountNewServiceAccountSlotsRequiredAsync(organization.Id, serviceAccountsToAdd);

Assert.Equal(0, result);

await sutProvider.GetDependency<IServiceAccountRepository>().DidNotReceiveWithAnyArgs()
.GetServiceAccountCountByOrganizationIdAsync(default);
}

[Theory, BitAutoData]
public async Task CountNewServiceAccountSlotsRequiredAsync_WithNonExistentOrganizationId_ThrowsNotFound(
Guid organizationId, int serviceAccountsToAdd,
SutProvider<CountNewServiceAccountSlotsRequiredQuery> sutProvider)
{
await Assert.ThrowsAsync<NotFoundException>(async () => await sutProvider.Sut.CountNewServiceAccountSlotsRequiredAsync(organizationId, serviceAccountsToAdd));
}

[Theory, BitAutoData]
public async Task CountNewServiceAccountSlotsRequiredAsync_WithOrganizationUseSecretsManagerFalse_ThrowsNotFound(
Organization organization, int serviceAccountsToAdd,
SutProvider<CountNewServiceAccountSlotsRequiredQuery> sutProvider)
{
organization.UseSecretsManager = false;

sutProvider.GetDependency<IOrganizationRepository>()
.GetByIdAsync(organization.Id)
.Returns(organization);

await Assert.ThrowsAsync<NotFoundException>(async () => await sutProvider.Sut.CountNewServiceAccountSlotsRequiredAsync(organization.Id, serviceAccountsToAdd));
}
}
3 changes: 2 additions & 1 deletion src/Admin/Admin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<UserSecretsId>bitwarden-Admin</UserSecretsId>
</PropertyGroup>

<PropertyGroup Condition=" '$(RunConfiguration)' == 'Admin' " />
<PropertyGroup Condition=" '$(RunConfiguration)' == 'Admin-SelfHost' " />
<ItemGroup>
Expand All @@ -19,6 +19,7 @@
<When Condition="!$(DefineConstants.Contains('OSS'))">
<ItemGroup>
<ProjectReference Include="..\..\bitwarden_license\src\Commercial.Core\Commercial.Core.csproj" />
<ProjectReference Include="..\..\bitwarden_license\src\Commercial.Infrastructure.EntityFramework\Commercial.Infrastructure.EntityFramework.csproj" />
</ItemGroup>
</When>
</Choose>
Expand Down
29 changes: 26 additions & 3 deletions src/Admin/Controllers/OrganizationsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Bit.Core.Models.OrganizationConnectionConfigs;
using Bit.Core.OrganizationFeatures.OrganizationSponsorships.FamiliesForEnterprise.Interfaces;
using Bit.Core.Repositories;
using Bit.Core.SecretsManager.Repositories;
using Bit.Core.Services;
using Bit.Core.Settings;
using Bit.Core.Tools.Enums;
Expand Down Expand Up @@ -42,6 +43,9 @@ public class OrganizationsController : Controller
private readonly ILogger<OrganizationsController> _logger;
private readonly IAccessControlService _accessControlService;
private readonly ICurrentContext _currentContext;
private readonly ISecretRepository _secretRepository;
private readonly IProjectRepository _projectRepository;
private readonly IServiceAccountRepository _serviceAccountRepository;

public OrganizationsController(
IOrganizationService organizationService,
Expand All @@ -62,7 +66,10 @@ public OrganizationsController(
IProviderRepository providerRepository,
ILogger<OrganizationsController> logger,
IAccessControlService accessControlService,
ICurrentContext currentContext)
ICurrentContext currentContext,
ISecretRepository secretRepository,
IProjectRepository projectRepository,
IServiceAccountRepository serviceAccountRepository)
{
_organizationService = organizationService;
_organizationRepository = organizationRepository;
Expand All @@ -83,6 +90,9 @@ public OrganizationsController(
_logger = logger;
_accessControlService = accessControlService;
_currentContext = currentContext;
_secretRepository = secretRepository;
_projectRepository = projectRepository;
_serviceAccountRepository = serviceAccountRepository;
}

[RequirePermission(Permission.Org_List_View)]
Expand Down Expand Up @@ -137,7 +147,14 @@ public async Task<IActionResult> View(Guid id)
}
var users = await _organizationUserRepository.GetManyDetailsByOrganizationAsync(id);
var billingSyncConnection = _globalSettings.EnableCloudCommunication ? await _organizationConnectionRepository.GetByOrganizationIdTypeAsync(id, OrganizationConnectionType.CloudBillingSync) : null;
return View(new OrganizationViewModel(organization, provider, billingSyncConnection, users, ciphers, collections, groups, policies));
var secrets = organization.UseSecretsManager ? await _secretRepository.GetSecretsCountByOrganizationIdAsync(id) : -1;
var projects = organization.UseSecretsManager ? await _projectRepository.GetProjectCountByOrganizationIdAsync(id) : -1;
var serviceAccounts = organization.UseSecretsManager ? await _serviceAccountRepository.GetServiceAccountCountByOrganizationIdAsync(id) : -1;
var smSeats = organization.UseSecretsManager
? await _organizationUserRepository.GetOccupiedSmSeatCountByOrganizationIdAsync(organization.Id)
: -1;
return View(new OrganizationViewModel(organization, provider, billingSyncConnection, users, ciphers, collections, groups, policies,
secrets, projects, serviceAccounts, smSeats));
}

[SelfHosted(NotSelfHostedOnly = true)]
Expand Down Expand Up @@ -165,8 +182,14 @@ public async Task<IActionResult> Edit(Guid id)
var users = await _organizationUserRepository.GetManyDetailsByOrganizationAsync(id);
var billingInfo = await _paymentService.GetBillingAsync(organization);
var billingSyncConnection = _globalSettings.EnableCloudCommunication ? await _organizationConnectionRepository.GetByOrganizationIdTypeAsync(id, OrganizationConnectionType.CloudBillingSync) : null;
var secrets = organization.UseSecretsManager ? await _secretRepository.GetSecretsCountByOrganizationIdAsync(id) : -1;
var projects = organization.UseSecretsManager ? await _projectRepository.GetProjectCountByOrganizationIdAsync(id) : -1;
var serviceAccounts = organization.UseSecretsManager ? await _serviceAccountRepository.GetServiceAccountCountByOrganizationIdAsync(id) : -1;
var smSeats = organization.UseSecretsManager
? await _organizationUserRepository.GetOccupiedSmSeatCountByOrganizationIdAsync(organization.Id)
: -1;
return View(new OrganizationEditModel(organization, provider, users, ciphers, collections, groups, policies,
billingInfo, billingSyncConnection, _globalSettings));
billingInfo, billingSyncConnection, _globalSettings, secrets, projects, serviceAccounts, smSeats));
}

[HttpPost]
Expand Down
5 changes: 3 additions & 2 deletions src/Admin/Models/OrganizationEditModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ public OrganizationEditModel(Provider provider)
public OrganizationEditModel(Organization org, Provider provider, IEnumerable<OrganizationUserUserDetails> orgUsers,
IEnumerable<Cipher> ciphers, IEnumerable<Collection> collections, IEnumerable<Group> groups,
IEnumerable<Policy> policies, BillingInfo billingInfo, IEnumerable<OrganizationConnection> connections,
GlobalSettings globalSettings)
: base(org, provider, connections, orgUsers, ciphers, collections, groups, policies)
GlobalSettings globalSettings, int secrets, int projects, int serviceAccounts, int smSeats)
: base(org, provider, connections, orgUsers, ciphers, collections, groups, policies, secrets, projects,
serviceAccounts, smSeats)
{
BillingInfo = billingInfo;
BraintreeMerchantId = globalSettings.Braintree.MerchantId;
Expand Down
13 changes: 12 additions & 1 deletion src/Admin/Models/OrganizationViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ public OrganizationViewModel() { }

public OrganizationViewModel(Organization org, Provider provider, IEnumerable<OrganizationConnection> connections,
IEnumerable<OrganizationUserUserDetails> orgUsers, IEnumerable<Cipher> ciphers, IEnumerable<Collection> collections,
IEnumerable<Group> groups, IEnumerable<Policy> policies)
IEnumerable<Group> groups, IEnumerable<Policy> policies, int secretsCount, int projectCount, int serviceAccountsCount,
int smSeatsCount)

{
Organization = org;
Provider = provider;
Expand All @@ -37,6 +39,10 @@ public OrganizationViewModel(Organization org, Provider provider, IEnumerable<Or
orgUsers
.Where(u => u.Type == OrganizationUserType.Admin && u.Status == organizationUserStatus)
.Select(u => u.Email));
Secrets = secretsCount;
Projects = projectCount;
ServiceAccounts = serviceAccountsCount;
SmSeats = smSeatsCount;
}

public Organization Organization { get; set; }
Expand All @@ -53,4 +59,9 @@ public OrganizationViewModel(Organization org, Provider provider, IEnumerable<Or
public int GroupCount { get; set; }
public int PolicyCount { get; set; }
public bool HasPublicPrivateKeys { get; set; }
public int Secrets { get; set; }
public int Projects { get; set; }
public int ServiceAccounts { get; set; }
public int SmSeats { get; set; }
public bool UseSecretsManager => Organization.UseSecretsManager;
}
2 changes: 2 additions & 0 deletions src/Admin/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#if !OSS
using Bit.Commercial.Core.Utilities;
using Bit.Commercial.Infrastructure.EntityFramework.SecretsManager;
#endif

namespace Bit.Admin;
Expand Down Expand Up @@ -91,6 +92,7 @@ public void ConfigureServices(IServiceCollection services)
services.AddOosServices();
#else
services.AddCommercialCoreServices();
services.AddSecretsManagerEfRepositories();
#endif

// Mvc
Expand Down
Loading
Loading