1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-25 12:45:18 +01:00

Add support for managing organizations through providers using the business portal (#1521)

This commit is contained in:
Oscar Hinton 2021-08-23 14:32:29 +02:00 committed by GitHub
parent f055df4e82
commit bc003c4449
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 1 deletions

View File

@ -6,6 +6,7 @@ using Microsoft.Extensions.DependencyInjection;
using Bit.Core.Repositories;
using System.Linq;
using System.Collections.Generic;
using Bit.Core.Enums;
using Bit.Core.Models.Data;
using Bit.Core.Utilities;
@ -70,6 +71,47 @@ namespace Bit.Portal
Type = ou.Type
}).ToList();
// Add all provider orgs.
var providerOrgs = await GetProviderOrganizations();
Organizations.AddRange(providerOrgs.Select(po => new CurrentContentOrganization
{
Id = po.OrganizationId,
Type = OrganizationUserType.Owner,
}));
// Yes this is ugly, but the business portal is deprecated.
OrganizationsDetails.AddRange(providerOrgs.Select(pu => new OrganizationUserOrganizationDetails
{
OrganizationId = pu.OrganizationId,
UserId = pu.UserId,
Name = pu.Name,
UsePolicies = pu.UsePolicies,
UseSso = pu.UseSso,
UseGroups = pu.UseGroups,
UseDirectory = pu.UseDirectory,
UseEvents = pu.UseEvents,
UseTotp = pu.UseTotp,
Use2fa = pu.Use2fa,
UseApi = pu.UseApi,
UseResetPassword = pu.UseResetPassword,
SelfHost = pu.SelfHost,
UsersGetPremium = pu.UsersGetPremium,
Seats = pu.Seats,
MaxCollections = pu.MaxCollections,
MaxStorageGb = pu.MaxStorageGb,
Key = pu.Key,
Status = OrganizationUserStatusType.Confirmed,
Type = OrganizationUserType.Owner,
Enabled = pu.Enabled,
SsoExternalId = null,
Identifier = pu.Identifier,
Permissions = null,
ResetPasswordKey = null,
PublicKey = pu.PublicKey,
PrivateKey = pu.PrivateKey,
ProviderId = pu.ProviderId,
ProviderName = pu.ProviderName,
}));
if (SelectedOrganizationId == null && HttpContext.Request.Cookies.ContainsKey("SelectedOrganization") &&
Guid.TryParse(HttpContext.Request.Cookies["SelectedOrganization"], out var selectedOrgId))
{

View File

@ -441,7 +441,7 @@ namespace Bit.Core.Context
};
}
private async Task<IEnumerable<ProviderUserOrganizationDetails>> GetProviderOrganizations()
protected async Task<IEnumerable<ProviderUserOrganizationDetails>> GetProviderOrganizations()
{
if (_providerUserOrganizations == null)
{