mirror of
https://github.com/bitwarden/server.git
synced 2025-02-16 01:51:21 +01:00
Added UseSso bool to Organization (#834)
* Added UseSso bool to org * Update fields in migration script * bump version & check enabled flag on ssoConfig
This commit is contained in:
parent
7bf559b4b6
commit
51fd87df0b
@ -30,6 +30,7 @@ namespace Bit.Admin.Models
|
|||||||
Seats = org.Seats;
|
Seats = org.Seats;
|
||||||
MaxCollections = org.MaxCollections;
|
MaxCollections = org.MaxCollections;
|
||||||
UsePolicies = org.UsePolicies;
|
UsePolicies = org.UsePolicies;
|
||||||
|
UseSso = org.UseSso;
|
||||||
UseGroups = org.UseGroups;
|
UseGroups = org.UseGroups;
|
||||||
UseDirectory = org.UseDirectory;
|
UseDirectory = org.UseDirectory;
|
||||||
UseEvents = org.UseEvents;
|
UseEvents = org.UseEvents;
|
||||||
@ -71,6 +72,8 @@ namespace Bit.Admin.Models
|
|||||||
public short? MaxCollections { get; set; }
|
public short? MaxCollections { get; set; }
|
||||||
[Display(Name = "Policies")]
|
[Display(Name = "Policies")]
|
||||||
public bool UsePolicies { get; set; }
|
public bool UsePolicies { get; set; }
|
||||||
|
[Display(Name = "SSO")]
|
||||||
|
public bool UseSso { get; set; }
|
||||||
[Display(Name = "Groups")]
|
[Display(Name = "Groups")]
|
||||||
public bool UseGroups { get; set; }
|
public bool UseGroups { get; set; }
|
||||||
[Display(Name = "Directory")]
|
[Display(Name = "Directory")]
|
||||||
@ -112,6 +115,7 @@ namespace Bit.Admin.Models
|
|||||||
existingOrganization.Seats = Seats;
|
existingOrganization.Seats = Seats;
|
||||||
existingOrganization.MaxCollections = MaxCollections;
|
existingOrganization.MaxCollections = MaxCollections;
|
||||||
existingOrganization.UsePolicies = UsePolicies;
|
existingOrganization.UsePolicies = UsePolicies;
|
||||||
|
existingOrganization.UseSso = UseSso;
|
||||||
existingOrganization.UseGroups = UseGroups;
|
existingOrganization.UseGroups = UseGroups;
|
||||||
existingOrganization.UseDirectory = UseDirectory;
|
existingOrganization.UseDirectory = UseDirectory;
|
||||||
existingOrganization.UseEvents = UseEvents;
|
existingOrganization.UseEvents = UseEvents;
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
document.getElementById('@(nameof(Model.MaxStorageGb))').value = '1';
|
document.getElementById('@(nameof(Model.MaxStorageGb))').value = '1';
|
||||||
// Features
|
// Features
|
||||||
document.getElementById('@(nameof(Model.UsePolicies))').checked = true;
|
document.getElementById('@(nameof(Model.UsePolicies))').checked = true;
|
||||||
|
document.getElementById('@(nameof(Model.UseSso))').checked = true;
|
||||||
document.getElementById('@(nameof(Model.UseGroups))').checked = true;
|
document.getElementById('@(nameof(Model.UseGroups))').checked = true;
|
||||||
document.getElementById('@(nameof(Model.UseDirectory))').checked = true;
|
document.getElementById('@(nameof(Model.UseDirectory))').checked = true;
|
||||||
document.getElementById('@(nameof(Model.UseEvents))').checked = true;
|
document.getElementById('@(nameof(Model.UseEvents))').checked = true;
|
||||||
@ -165,6 +166,10 @@
|
|||||||
<input type="checkbox" class="form-check-input" asp-for="UsePolicies">
|
<input type="checkbox" class="form-check-input" asp-for="UsePolicies">
|
||||||
<label class="form-check-label" asp-for="UsePolicies"></label>
|
<label class="form-check-label" asp-for="UsePolicies"></label>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-check">
|
||||||
|
<input type="checkbox" class="form-check-input" asp-for="UseSso">
|
||||||
|
<label class="form-check-label" asp-for="UseSso"></label>
|
||||||
|
</div>
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<input type="checkbox" class="form-check-input" asp-for="UseDirectory">
|
<input type="checkbox" class="form-check-input" asp-for="UseDirectory">
|
||||||
<label class="form-check-label" asp-for="UseDirectory"></label>
|
<label class="form-check-label" asp-for="UseDirectory"></label>
|
||||||
|
@ -17,6 +17,10 @@ namespace Bit.Core.Enums
|
|||||||
[Display(Name = "Enterprise (Annually)")]
|
[Display(Name = "Enterprise (Annually)")]
|
||||||
EnterpriseAnnually = 5,
|
EnterpriseAnnually = 5,
|
||||||
[Display(Name = "Custom")]
|
[Display(Name = "Custom")]
|
||||||
Custom = 6
|
Custom = 6,
|
||||||
|
[Display(Name = "PLACEHOLDER")]
|
||||||
|
SsoPlaceholderMonthly = 10,
|
||||||
|
[Display(Name = "PLACEHOLDER")]
|
||||||
|
SsoPlaceholderAnnually = 11,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ namespace Bit.Core.Models.Api
|
|||||||
MaxCollections = organization.MaxCollections;
|
MaxCollections = organization.MaxCollections;
|
||||||
MaxStorageGb = organization.MaxStorageGb;
|
MaxStorageGb = organization.MaxStorageGb;
|
||||||
UsePolicies = organization.UsePolicies;
|
UsePolicies = organization.UsePolicies;
|
||||||
|
UseSso = organization.UseSso;
|
||||||
UseGroups = organization.UseGroups;
|
UseGroups = organization.UseGroups;
|
||||||
UseDirectory = organization.UseDirectory;
|
UseDirectory = organization.UseDirectory;
|
||||||
UseEvents = organization.UseEvents;
|
UseEvents = organization.UseEvents;
|
||||||
@ -56,6 +57,7 @@ namespace Bit.Core.Models.Api
|
|||||||
public short? MaxCollections { get; set; }
|
public short? MaxCollections { get; set; }
|
||||||
public short? MaxStorageGb { get; set; }
|
public short? MaxStorageGb { get; set; }
|
||||||
public bool UsePolicies { get; set; }
|
public bool UsePolicies { get; set; }
|
||||||
|
public bool UseSso { get; set; }
|
||||||
public bool UseGroups { get; set; }
|
public bool UseGroups { get; set; }
|
||||||
public bool UseDirectory { get; set; }
|
public bool UseDirectory { get; set; }
|
||||||
public bool UseEvents { get; set; }
|
public bool UseEvents { get; set; }
|
||||||
|
@ -11,6 +11,7 @@ namespace Bit.Core.Models.Api
|
|||||||
Id = organization.OrganizationId.ToString();
|
Id = organization.OrganizationId.ToString();
|
||||||
Name = organization.Name;
|
Name = organization.Name;
|
||||||
UsePolicies = organization.UsePolicies;
|
UsePolicies = organization.UsePolicies;
|
||||||
|
UseSso = organization.UseSso;
|
||||||
UseGroups = organization.UseGroups;
|
UseGroups = organization.UseGroups;
|
||||||
UseDirectory = organization.UseDirectory;
|
UseDirectory = organization.UseDirectory;
|
||||||
UseEvents = organization.UseEvents;
|
UseEvents = organization.UseEvents;
|
||||||
@ -31,13 +32,14 @@ namespace Bit.Core.Models.Api
|
|||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public bool UsePolicies { get; set; }
|
public bool UsePolicies { get; set; }
|
||||||
|
public bool UseSso { get; set; }
|
||||||
public bool UseGroups { get; set; }
|
public bool UseGroups { get; set; }
|
||||||
public bool UseDirectory { get; set; }
|
public bool UseDirectory { get; set; }
|
||||||
public bool UseEvents { get; set; }
|
public bool UseEvents { get; set; }
|
||||||
public bool UseTotp { get; set; }
|
public bool UseTotp { get; set; }
|
||||||
public bool Use2fa { get; set; }
|
public bool Use2fa { get; set; }
|
||||||
public bool UseApi { get; set; }
|
public bool UseApi { get; set; }
|
||||||
public bool UseBusinessPortal => UsePolicies; // TODO add events if needed, add SSO when created
|
public bool UseBusinessPortal => UsePolicies || UseSso; // TODO add events if needed
|
||||||
public bool UsersGetPremium { get; set; }
|
public bool UsersGetPremium { get; set; }
|
||||||
public bool SelfHost { get; set; }
|
public bool SelfHost { get; set; }
|
||||||
public int Seats { get; set; }
|
public int Seats { get; set; }
|
||||||
|
@ -19,7 +19,7 @@ namespace Bit.Core.Models.Business
|
|||||||
public OrganizationLicense(Organization org, SubscriptionInfo subscriptionInfo, Guid installationId,
|
public OrganizationLicense(Organization org, SubscriptionInfo subscriptionInfo, Guid installationId,
|
||||||
ILicensingService licenseService)
|
ILicensingService licenseService)
|
||||||
{
|
{
|
||||||
Version = 5; // TODO: bump to version 6
|
Version = 6; // TODO: bump to version 7
|
||||||
LicenseKey = org.LicenseKey;
|
LicenseKey = org.LicenseKey;
|
||||||
InstallationId = installationId;
|
InstallationId = installationId;
|
||||||
Id = org.Id;
|
Id = org.Id;
|
||||||
@ -32,6 +32,7 @@ namespace Bit.Core.Models.Business
|
|||||||
Seats = org.Seats;
|
Seats = org.Seats;
|
||||||
MaxCollections = org.MaxCollections;
|
MaxCollections = org.MaxCollections;
|
||||||
UsePolicies = org.UsePolicies;
|
UsePolicies = org.UsePolicies;
|
||||||
|
UseSso = org.UseSso;
|
||||||
UseGroups = org.UseGroups;
|
UseGroups = org.UseGroups;
|
||||||
UseEvents = org.UseEvents;
|
UseEvents = org.UseEvents;
|
||||||
UseDirectory = org.UseDirectory;
|
UseDirectory = org.UseDirectory;
|
||||||
@ -100,6 +101,7 @@ namespace Bit.Core.Models.Business
|
|||||||
public short? Seats { get; set; }
|
public short? Seats { get; set; }
|
||||||
public short? MaxCollections { get; set; }
|
public short? MaxCollections { get; set; }
|
||||||
public bool UsePolicies { get; set; }
|
public bool UsePolicies { get; set; }
|
||||||
|
public bool UseSso { get; set; }
|
||||||
public bool UseGroups { get; set; }
|
public bool UseGroups { get; set; }
|
||||||
public bool UseEvents { get; set; }
|
public bool UseEvents { get; set; }
|
||||||
public bool UseDirectory { get; set; }
|
public bool UseDirectory { get; set; }
|
||||||
@ -122,7 +124,7 @@ namespace Bit.Core.Models.Business
|
|||||||
public byte[] GetDataBytes(bool forHash = false)
|
public byte[] GetDataBytes(bool forHash = false)
|
||||||
{
|
{
|
||||||
string data = null;
|
string data = null;
|
||||||
if (Version >= 1 && Version <= 6)
|
if (Version >= 1 && Version <= 7)
|
||||||
{
|
{
|
||||||
var props = typeof(OrganizationLicense)
|
var props = typeof(OrganizationLicense)
|
||||||
.GetProperties(BindingFlags.Public | BindingFlags.Instance)
|
.GetProperties(BindingFlags.Public | BindingFlags.Instance)
|
||||||
@ -139,6 +141,8 @@ namespace Bit.Core.Models.Business
|
|||||||
(Version >= 5 || !p.Name.Equals(nameof(UseApi))) &&
|
(Version >= 5 || !p.Name.Equals(nameof(UseApi))) &&
|
||||||
// UsePolicies was added in Version 6
|
// UsePolicies was added in Version 6
|
||||||
(Version >= 6 || !p.Name.Equals(nameof(UsePolicies))) &&
|
(Version >= 6 || !p.Name.Equals(nameof(UsePolicies))) &&
|
||||||
|
// UseSso was added in Version 7
|
||||||
|
(Version >= 7 || !p.Name.Equals(nameof(UseSso))) &&
|
||||||
(
|
(
|
||||||
!forHash ||
|
!forHash ||
|
||||||
(
|
(
|
||||||
@ -175,7 +179,7 @@ namespace Bit.Core.Models.Business
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Version >= 1 && Version <= 6)
|
if (Version >= 1 && Version <= 7)
|
||||||
{
|
{
|
||||||
return InstallationId == globalSettings.Installation.Id && SelfHost;
|
return InstallationId == globalSettings.Installation.Id && SelfHost;
|
||||||
}
|
}
|
||||||
@ -192,7 +196,7 @@ namespace Bit.Core.Models.Business
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Version >= 1 && Version <= 6)
|
if (Version >= 1 && Version <= 7)
|
||||||
{
|
{
|
||||||
var valid =
|
var valid =
|
||||||
globalSettings.Installation.Id == InstallationId &&
|
globalSettings.Installation.Id == InstallationId &&
|
||||||
@ -232,6 +236,11 @@ namespace Bit.Core.Models.Business
|
|||||||
valid = organization.UsePolicies == UsePolicies;
|
valid = organization.UsePolicies == UsePolicies;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (valid && Version >= 7)
|
||||||
|
{
|
||||||
|
valid = organization.UseSso == UseSso;
|
||||||
|
}
|
||||||
|
|
||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -8,6 +8,7 @@ namespace Bit.Core.Models.Data
|
|||||||
public Guid? UserId { get; set; }
|
public Guid? UserId { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public bool UsePolicies { get; set; }
|
public bool UsePolicies { get; set; }
|
||||||
|
public bool UseSso { get; set; }
|
||||||
public bool UseGroups { get; set; }
|
public bool UseGroups { get; set; }
|
||||||
public bool UseDirectory { get; set; }
|
public bool UseDirectory { get; set; }
|
||||||
public bool UseEvents { get; set; }
|
public bool UseEvents { get; set; }
|
||||||
|
@ -16,6 +16,7 @@ namespace Bit.Core.Models.StaticStore
|
|||||||
public bool CanBuyPremiumAccessAddon { get; set; }
|
public bool CanBuyPremiumAccessAddon { get; set; }
|
||||||
public bool UseGroups { get; set; }
|
public bool UseGroups { get; set; }
|
||||||
public bool UsePolicies { get; set; }
|
public bool UsePolicies { get; set; }
|
||||||
|
public bool UseSso { get; set; }
|
||||||
public bool UseDirectory { get; set; }
|
public bool UseDirectory { get; set; }
|
||||||
public bool UseEvents { get; set; }
|
public bool UseEvents { get; set; }
|
||||||
public bool UseTotp { get; set; }
|
public bool UseTotp { get; set; }
|
||||||
|
@ -26,6 +26,7 @@ namespace Bit.Core.Models.Table
|
|||||||
public short? Seats { get; set; }
|
public short? Seats { get; set; }
|
||||||
public short? MaxCollections { get; set; }
|
public short? MaxCollections { get; set; }
|
||||||
public bool UsePolicies { get; set; }
|
public bool UsePolicies { get; set; }
|
||||||
|
public bool UseSso { get; set; }
|
||||||
public bool UseGroups { get; set; }
|
public bool UseGroups { get; set; }
|
||||||
public bool UseDirectory { get; set; }
|
public bool UseDirectory { get; set; }
|
||||||
public bool UseEvents { get; set; }
|
public bool UseEvents { get; set; }
|
||||||
|
@ -34,6 +34,7 @@ namespace Bit.Core.Services
|
|||||||
private readonly IApplicationCacheService _applicationCacheService;
|
private readonly IApplicationCacheService _applicationCacheService;
|
||||||
private readonly IPaymentService _paymentService;
|
private readonly IPaymentService _paymentService;
|
||||||
private readonly IPolicyRepository _policyRepository;
|
private readonly IPolicyRepository _policyRepository;
|
||||||
|
private readonly ISsoConfigRepository _ssoConfigRepository;
|
||||||
private readonly IReferenceEventService _referenceEventService;
|
private readonly IReferenceEventService _referenceEventService;
|
||||||
private readonly GlobalSettings _globalSettings;
|
private readonly GlobalSettings _globalSettings;
|
||||||
|
|
||||||
@ -54,6 +55,7 @@ namespace Bit.Core.Services
|
|||||||
IApplicationCacheService applicationCacheService,
|
IApplicationCacheService applicationCacheService,
|
||||||
IPaymentService paymentService,
|
IPaymentService paymentService,
|
||||||
IPolicyRepository policyRepository,
|
IPolicyRepository policyRepository,
|
||||||
|
ISsoConfigRepository ssoConfigRepository,
|
||||||
IReferenceEventService referenceEventService,
|
IReferenceEventService referenceEventService,
|
||||||
GlobalSettings globalSettings)
|
GlobalSettings globalSettings)
|
||||||
{
|
{
|
||||||
@ -73,6 +75,7 @@ namespace Bit.Core.Services
|
|||||||
_applicationCacheService = applicationCacheService;
|
_applicationCacheService = applicationCacheService;
|
||||||
_paymentService = paymentService;
|
_paymentService = paymentService;
|
||||||
_policyRepository = policyRepository;
|
_policyRepository = policyRepository;
|
||||||
|
_ssoConfigRepository = ssoConfigRepository;
|
||||||
_referenceEventService = referenceEventService;
|
_referenceEventService = referenceEventService;
|
||||||
_globalSettings = globalSettings;
|
_globalSettings = globalSettings;
|
||||||
}
|
}
|
||||||
@ -217,6 +220,16 @@ namespace Bit.Core.Services
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!newPlan.UseSso && organization.UseSso)
|
||||||
|
{
|
||||||
|
var ssoConfig = await _ssoConfigRepository.GetByOrganizationIdAsync(organization.Id);
|
||||||
|
if (ssoConfig != null && ssoConfig.Enabled)
|
||||||
|
{
|
||||||
|
throw new BadRequestException($"Your new plan does not allow the SSO feature. " +
|
||||||
|
$"Disable your SSO configuration.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Check storage?
|
// TODO: Check storage?
|
||||||
|
|
||||||
string paymentIntentClientSecret = null;
|
string paymentIntentClientSecret = null;
|
||||||
@ -504,6 +517,7 @@ namespace Bit.Core.Services
|
|||||||
MaxStorageGb = !plan.MaxStorageGb.HasValue ?
|
MaxStorageGb = !plan.MaxStorageGb.HasValue ?
|
||||||
(short?)null : (short)(plan.MaxStorageGb.Value + signup.AdditionalStorageGb),
|
(short?)null : (short)(plan.MaxStorageGb.Value + signup.AdditionalStorageGb),
|
||||||
UsePolicies = plan.UsePolicies,
|
UsePolicies = plan.UsePolicies,
|
||||||
|
UseSso = plan.UseSso,
|
||||||
UseGroups = plan.UseGroups,
|
UseGroups = plan.UseGroups,
|
||||||
UseEvents = plan.UseEvents,
|
UseEvents = plan.UseEvents,
|
||||||
UseDirectory = plan.UseDirectory,
|
UseDirectory = plan.UseDirectory,
|
||||||
@ -586,6 +600,7 @@ namespace Bit.Core.Services
|
|||||||
MaxCollections = license.MaxCollections,
|
MaxCollections = license.MaxCollections,
|
||||||
MaxStorageGb = _globalSettings.SelfHosted ? 10240 : license.MaxStorageGb, // 10 TB
|
MaxStorageGb = _globalSettings.SelfHosted ? 10240 : license.MaxStorageGb, // 10 TB
|
||||||
UsePolicies = license.UsePolicies,
|
UsePolicies = license.UsePolicies,
|
||||||
|
UseSso = license.UseSso,
|
||||||
UseGroups = license.UseGroups,
|
UseGroups = license.UseGroups,
|
||||||
UseDirectory = license.UseDirectory,
|
UseDirectory = license.UseDirectory,
|
||||||
UseEvents = license.UseEvents,
|
UseEvents = license.UseEvents,
|
||||||
@ -748,6 +763,16 @@ namespace Bit.Core.Services
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!license.UseSso && organization.UseSso)
|
||||||
|
{
|
||||||
|
var ssoConfig = await _ssoConfigRepository.GetByOrganizationIdAsync(organization.Id);
|
||||||
|
if (ssoConfig != null && ssoConfig.Enabled)
|
||||||
|
{
|
||||||
|
throw new BadRequestException($"Your organization currently has a SSO configuration. " +
|
||||||
|
$"Your new license does not allow for the use of SSO. Disable your SSO configuration.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var dir = $"{_globalSettings.LicenseDirectory}/organization";
|
var dir = $"{_globalSettings.LicenseDirectory}/organization";
|
||||||
Directory.CreateDirectory(dir);
|
Directory.CreateDirectory(dir);
|
||||||
System.IO.File.WriteAllText($"{dir}/{organization.Id}.json",
|
System.IO.File.WriteAllText($"{dir}/{organization.Id}.json",
|
||||||
@ -766,6 +791,7 @@ namespace Bit.Core.Services
|
|||||||
organization.Use2fa = license.Use2fa;
|
organization.Use2fa = license.Use2fa;
|
||||||
organization.UseApi = license.UseApi;
|
organization.UseApi = license.UseApi;
|
||||||
organization.UsePolicies = license.UsePolicies;
|
organization.UsePolicies = license.UsePolicies;
|
||||||
|
organization.UseSso = license.UseSso;
|
||||||
organization.SelfHost = license.SelfHost;
|
organization.SelfHost = license.SelfHost;
|
||||||
organization.UsersGetPremium = license.UsersGetPremium;
|
organization.UsersGetPremium = license.UsersGetPremium;
|
||||||
organization.Plan = license.Plan;
|
organization.Plan = license.Plan;
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
@Seats SMALLINT,
|
@Seats SMALLINT,
|
||||||
@MaxCollections SMALLINT,
|
@MaxCollections SMALLINT,
|
||||||
@UsePolicies BIT,
|
@UsePolicies BIT,
|
||||||
|
@UseSso BIT,
|
||||||
@UseGroups BIT,
|
@UseGroups BIT,
|
||||||
@UseDirectory BIT,
|
@UseDirectory BIT,
|
||||||
@UseEvents BIT,
|
@UseEvents BIT,
|
||||||
@ -56,6 +57,7 @@ BEGIN
|
|||||||
[Seats],
|
[Seats],
|
||||||
[MaxCollections],
|
[MaxCollections],
|
||||||
[UsePolicies],
|
[UsePolicies],
|
||||||
|
[UseSso],
|
||||||
[UseGroups],
|
[UseGroups],
|
||||||
[UseDirectory],
|
[UseDirectory],
|
||||||
[UseEvents],
|
[UseEvents],
|
||||||
@ -95,6 +97,7 @@ BEGIN
|
|||||||
@Seats,
|
@Seats,
|
||||||
@MaxCollections,
|
@MaxCollections,
|
||||||
@UsePolicies,
|
@UsePolicies,
|
||||||
|
@UseSso,
|
||||||
@UseGroups,
|
@UseGroups,
|
||||||
@UseDirectory,
|
@UseDirectory,
|
||||||
@UseEvents,
|
@UseEvents,
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
@Seats SMALLINT,
|
@Seats SMALLINT,
|
||||||
@MaxCollections SMALLINT,
|
@MaxCollections SMALLINT,
|
||||||
@UsePolicies BIT,
|
@UsePolicies BIT,
|
||||||
|
@UseSso BIT,
|
||||||
@UseGroups BIT,
|
@UseGroups BIT,
|
||||||
@UseDirectory BIT,
|
@UseDirectory BIT,
|
||||||
@UseEvents BIT,
|
@UseEvents BIT,
|
||||||
@ -56,6 +57,7 @@ BEGIN
|
|||||||
[Seats] = @Seats,
|
[Seats] = @Seats,
|
||||||
[MaxCollections] = @MaxCollections,
|
[MaxCollections] = @MaxCollections,
|
||||||
[UsePolicies] = @UsePolicies,
|
[UsePolicies] = @UsePolicies,
|
||||||
|
[UseSso] = @UseSso,
|
||||||
[UseGroups] = @UseGroups,
|
[UseGroups] = @UseGroups,
|
||||||
[UseDirectory] = @UseDirectory,
|
[UseDirectory] = @UseDirectory,
|
||||||
[UseEvents] = @UseEvents,
|
[UseEvents] = @UseEvents,
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
[Seats] SMALLINT NULL,
|
[Seats] SMALLINT NULL,
|
||||||
[MaxCollections] SMALLINT NULL,
|
[MaxCollections] SMALLINT NULL,
|
||||||
[UsePolicies] BIT NOT NULL,
|
[UsePolicies] BIT NOT NULL,
|
||||||
|
[UseSso] BIT NOT NULL,
|
||||||
[UseGroups] BIT NOT NULL,
|
[UseGroups] BIT NOT NULL,
|
||||||
[UseDirectory] BIT NOT NULL,
|
[UseDirectory] BIT NOT NULL,
|
||||||
[UseEvents] BIT NOT NULL,
|
[UseEvents] BIT NOT NULL,
|
||||||
|
@ -6,6 +6,7 @@ SELECT
|
|||||||
O.[Name],
|
O.[Name],
|
||||||
O.[Enabled],
|
O.[Enabled],
|
||||||
O.[UsePolicies],
|
O.[UsePolicies],
|
||||||
|
O.[UseSso],
|
||||||
O.[UseGroups],
|
O.[UseGroups],
|
||||||
O.[UseDirectory],
|
O.[UseDirectory],
|
||||||
O.[UseEvents],
|
O.[UseEvents],
|
||||||
|
@ -32,13 +32,14 @@ namespace Bit.Core.Test.Services
|
|||||||
var appCacheService = Substitute.For<IApplicationCacheService>();
|
var appCacheService = Substitute.For<IApplicationCacheService>();
|
||||||
var paymentService = Substitute.For<IPaymentService>();
|
var paymentService = Substitute.For<IPaymentService>();
|
||||||
var policyRepo = Substitute.For<IPolicyRepository>();
|
var policyRepo = Substitute.For<IPolicyRepository>();
|
||||||
|
var ssoConfigRepo = Substitute.For<ISsoConfigRepository>();
|
||||||
var referenceEventService = Substitute.For<IReferenceEventService>();
|
var referenceEventService = Substitute.For<IReferenceEventService>();
|
||||||
var globalSettings = Substitute.For<GlobalSettings>();
|
var globalSettings = Substitute.For<GlobalSettings>();
|
||||||
|
|
||||||
var orgService = new OrganizationService(orgRepo, orgUserRepo, collectionRepo, userRepo,
|
var orgService = new OrganizationService(orgRepo, orgUserRepo, collectionRepo, userRepo,
|
||||||
groupRepo, dataProtector, mailService, pushNotService, pushRegService, deviceRepo,
|
groupRepo, dataProtector, mailService, pushNotService, pushRegService, deviceRepo,
|
||||||
licenseService, eventService, installationRepo, appCacheService, paymentService, policyRepo,
|
licenseService, eventService, installationRepo, appCacheService, paymentService, policyRepo,
|
||||||
referenceEventService, globalSettings);
|
ssoConfigRepo, referenceEventService, globalSettings);
|
||||||
|
|
||||||
var id = Guid.NewGuid();
|
var id = Guid.NewGuid();
|
||||||
var userId = Guid.NewGuid();
|
var userId = Guid.NewGuid();
|
||||||
@ -91,13 +92,14 @@ namespace Bit.Core.Test.Services
|
|||||||
var appCacheService = Substitute.For<IApplicationCacheService>();
|
var appCacheService = Substitute.For<IApplicationCacheService>();
|
||||||
var paymentService = Substitute.For<IPaymentService>();
|
var paymentService = Substitute.For<IPaymentService>();
|
||||||
var policyRepo = Substitute.For<IPolicyRepository>();
|
var policyRepo = Substitute.For<IPolicyRepository>();
|
||||||
|
var ssoConfigRepo = Substitute.For<ISsoConfigRepository>();
|
||||||
var referenceEventService = Substitute.For<IReferenceEventService>();
|
var referenceEventService = Substitute.For<IReferenceEventService>();
|
||||||
var globalSettings = Substitute.For<GlobalSettings>();
|
var globalSettings = Substitute.For<GlobalSettings>();
|
||||||
|
|
||||||
var orgService = new OrganizationService(orgRepo, orgUserRepo, collectionRepo, userRepo,
|
var orgService = new OrganizationService(orgRepo, orgUserRepo, collectionRepo, userRepo,
|
||||||
groupRepo, dataProtector, mailService, pushNotService, pushRegService, deviceRepo,
|
groupRepo, dataProtector, mailService, pushNotService, pushRegService, deviceRepo,
|
||||||
licenseService, eventService, installationRepo, appCacheService, paymentService, policyRepo,
|
licenseService, eventService, installationRepo, appCacheService, paymentService, policyRepo,
|
||||||
referenceEventService, globalSettings);
|
ssoConfigRepo, referenceEventService, globalSettings);
|
||||||
|
|
||||||
var id = Guid.NewGuid();
|
var id = Guid.NewGuid();
|
||||||
var userId = Guid.NewGuid();
|
var userId = Guid.NewGuid();
|
||||||
|
292
util/Migrator/DbScripts/2020-07-20_00_OrgSso.sql
Normal file
292
util/Migrator/DbScripts/2020-07-20_00_OrgSso.sql
Normal file
@ -0,0 +1,292 @@
|
|||||||
|
IF COL_LENGTH('[dbo].[Organization]', 'UseSso') IS NULL
|
||||||
|
BEGIN
|
||||||
|
ALTER TABLE
|
||||||
|
[dbo].[Organization]
|
||||||
|
ADD
|
||||||
|
[UseSso] BIT NULL
|
||||||
|
END
|
||||||
|
GO
|
||||||
|
|
||||||
|
UPDATE
|
||||||
|
[dbo].[Organization]
|
||||||
|
SET
|
||||||
|
[UseSso] = (CASE WHEN [PlanType] = 10 OR [PlanType] = 11 THEN 1 ELSE 0 END)
|
||||||
|
GO
|
||||||
|
|
||||||
|
ALTER TABLE
|
||||||
|
[dbo].[Organization]
|
||||||
|
ALTER COLUMN
|
||||||
|
[UseSso] BIT NOT NULL
|
||||||
|
GO
|
||||||
|
|
||||||
|
IF EXISTS(SELECT * FROM sys.views WHERE [Name] = 'OrganizationView')
|
||||||
|
BEGIN
|
||||||
|
DROP VIEW [dbo].[OrganizationView]
|
||||||
|
END
|
||||||
|
GO
|
||||||
|
|
||||||
|
CREATE VIEW [dbo].[OrganizationView]
|
||||||
|
AS
|
||||||
|
SELECT
|
||||||
|
*
|
||||||
|
FROM
|
||||||
|
[dbo].[Organization]
|
||||||
|
GO
|
||||||
|
|
||||||
|
IF EXISTS(SELECT * FROM sys.views WHERE [Name] = 'OrganizationUserOrganizationDetailsView')
|
||||||
|
BEGIN
|
||||||
|
DROP VIEW [dbo].[OrganizationUserOrganizationDetailsView]
|
||||||
|
END
|
||||||
|
GO
|
||||||
|
|
||||||
|
CREATE VIEW [dbo].[OrganizationUserOrganizationDetailsView]
|
||||||
|
AS
|
||||||
|
SELECT
|
||||||
|
OU.[UserId],
|
||||||
|
OU.[OrganizationId],
|
||||||
|
O.[Name],
|
||||||
|
O.[Enabled],
|
||||||
|
O.[UsePolicies],
|
||||||
|
O.[UseSso],
|
||||||
|
O.[UseGroups],
|
||||||
|
O.[UseDirectory],
|
||||||
|
O.[UseEvents],
|
||||||
|
O.[UseTotp],
|
||||||
|
O.[Use2fa],
|
||||||
|
O.[UseApi],
|
||||||
|
O.[SelfHost],
|
||||||
|
O.[UsersGetPremium],
|
||||||
|
O.[Seats],
|
||||||
|
O.[MaxCollections],
|
||||||
|
O.[MaxStorageGb],
|
||||||
|
OU.[Key],
|
||||||
|
OU.[Status],
|
||||||
|
OU.[Type]
|
||||||
|
FROM
|
||||||
|
[dbo].[OrganizationUser] OU
|
||||||
|
INNER JOIN
|
||||||
|
[dbo].[Organization] O ON O.[Id] = OU.[OrganizationId]
|
||||||
|
GO
|
||||||
|
|
||||||
|
IF OBJECT_ID('[dbo].[Organization_Create]') IS NOT NULL
|
||||||
|
BEGIN
|
||||||
|
DROP PROCEDURE [dbo].[Organization_Create]
|
||||||
|
END
|
||||||
|
GO
|
||||||
|
|
||||||
|
CREATE PROCEDURE [dbo].[Organization_Create]
|
||||||
|
@Id UNIQUEIDENTIFIER,
|
||||||
|
@Identifier NVARCHAR(50),
|
||||||
|
@Name NVARCHAR(50),
|
||||||
|
@BusinessName NVARCHAR(50),
|
||||||
|
@BusinessAddress1 NVARCHAR(50),
|
||||||
|
@BusinessAddress2 NVARCHAR(50),
|
||||||
|
@BusinessAddress3 NVARCHAR(50),
|
||||||
|
@BusinessCountry VARCHAR(2),
|
||||||
|
@BusinessTaxNumber NVARCHAR(30),
|
||||||
|
@BillingEmail NVARCHAR(50),
|
||||||
|
@Plan NVARCHAR(50),
|
||||||
|
@PlanType TINYINT,
|
||||||
|
@Seats SMALLINT,
|
||||||
|
@MaxCollections SMALLINT,
|
||||||
|
@UsePolicies BIT,
|
||||||
|
@UseSso BIT,
|
||||||
|
@UseGroups BIT,
|
||||||
|
@UseDirectory BIT,
|
||||||
|
@UseEvents BIT,
|
||||||
|
@UseTotp BIT,
|
||||||
|
@Use2fa BIT,
|
||||||
|
@UseApi BIT,
|
||||||
|
@SelfHost BIT,
|
||||||
|
@UsersGetPremium BIT,
|
||||||
|
@Storage BIGINT,
|
||||||
|
@MaxStorageGb SMALLINT,
|
||||||
|
@Gateway TINYINT,
|
||||||
|
@GatewayCustomerId VARCHAR(50),
|
||||||
|
@GatewaySubscriptionId VARCHAR(50),
|
||||||
|
@ReferenceData VARCHAR(MAX),
|
||||||
|
@Enabled BIT,
|
||||||
|
@LicenseKey VARCHAR(100),
|
||||||
|
@ApiKey VARCHAR(30),
|
||||||
|
@TwoFactorProviders NVARCHAR(MAX),
|
||||||
|
@ExpirationDate DATETIME2(7),
|
||||||
|
@CreationDate DATETIME2(7),
|
||||||
|
@RevisionDate DATETIME2(7)
|
||||||
|
AS
|
||||||
|
BEGIN
|
||||||
|
SET NOCOUNT ON
|
||||||
|
|
||||||
|
INSERT INTO [dbo].[Organization]
|
||||||
|
(
|
||||||
|
[Id],
|
||||||
|
[Identifier],
|
||||||
|
[Name],
|
||||||
|
[BusinessName],
|
||||||
|
[BusinessAddress1],
|
||||||
|
[BusinessAddress2],
|
||||||
|
[BusinessAddress3],
|
||||||
|
[BusinessCountry],
|
||||||
|
[BusinessTaxNumber],
|
||||||
|
[BillingEmail],
|
||||||
|
[Plan],
|
||||||
|
[PlanType],
|
||||||
|
[Seats],
|
||||||
|
[MaxCollections],
|
||||||
|
[UsePolicies],
|
||||||
|
[UseSso],
|
||||||
|
[UseGroups],
|
||||||
|
[UseDirectory],
|
||||||
|
[UseEvents],
|
||||||
|
[UseTotp],
|
||||||
|
[Use2fa],
|
||||||
|
[UseApi],
|
||||||
|
[SelfHost],
|
||||||
|
[UsersGetPremium],
|
||||||
|
[Storage],
|
||||||
|
[MaxStorageGb],
|
||||||
|
[Gateway],
|
||||||
|
[GatewayCustomerId],
|
||||||
|
[GatewaySubscriptionId],
|
||||||
|
[ReferenceData],
|
||||||
|
[Enabled],
|
||||||
|
[LicenseKey],
|
||||||
|
[ApiKey],
|
||||||
|
[TwoFactorProviders],
|
||||||
|
[ExpirationDate],
|
||||||
|
[CreationDate],
|
||||||
|
[RevisionDate]
|
||||||
|
)
|
||||||
|
VALUES
|
||||||
|
(
|
||||||
|
@Id,
|
||||||
|
@Identifier,
|
||||||
|
@Name,
|
||||||
|
@BusinessName,
|
||||||
|
@BusinessAddress1,
|
||||||
|
@BusinessAddress2,
|
||||||
|
@BusinessAddress3,
|
||||||
|
@BusinessCountry,
|
||||||
|
@BusinessTaxNumber,
|
||||||
|
@BillingEmail,
|
||||||
|
@Plan,
|
||||||
|
@PlanType,
|
||||||
|
@Seats,
|
||||||
|
@MaxCollections,
|
||||||
|
@UsePolicies,
|
||||||
|
@UseSso,
|
||||||
|
@UseGroups,
|
||||||
|
@UseDirectory,
|
||||||
|
@UseEvents,
|
||||||
|
@UseTotp,
|
||||||
|
@Use2fa,
|
||||||
|
@UseApi,
|
||||||
|
@SelfHost,
|
||||||
|
@UsersGetPremium,
|
||||||
|
@Storage,
|
||||||
|
@MaxStorageGb,
|
||||||
|
@Gateway,
|
||||||
|
@GatewayCustomerId,
|
||||||
|
@GatewaySubscriptionId,
|
||||||
|
@ReferenceData,
|
||||||
|
@Enabled,
|
||||||
|
@LicenseKey,
|
||||||
|
@ApiKey,
|
||||||
|
@TwoFactorProviders,
|
||||||
|
@ExpirationDate,
|
||||||
|
@CreationDate,
|
||||||
|
@RevisionDate
|
||||||
|
)
|
||||||
|
END
|
||||||
|
GO
|
||||||
|
|
||||||
|
IF OBJECT_ID('[dbo].[Organization_Update]') IS NOT NULL
|
||||||
|
BEGIN
|
||||||
|
DROP PROCEDURE [dbo].[Organization_Update]
|
||||||
|
END
|
||||||
|
GO
|
||||||
|
|
||||||
|
CREATE PROCEDURE [dbo].[Organization_Update]
|
||||||
|
@Id UNIQUEIDENTIFIER,
|
||||||
|
@Identifier NVARCHAR(50),
|
||||||
|
@Name NVARCHAR(50),
|
||||||
|
@BusinessName NVARCHAR(50),
|
||||||
|
@BusinessAddress1 NVARCHAR(50),
|
||||||
|
@BusinessAddress2 NVARCHAR(50),
|
||||||
|
@BusinessAddress3 NVARCHAR(50),
|
||||||
|
@BusinessCountry VARCHAR(2),
|
||||||
|
@BusinessTaxNumber NVARCHAR(30),
|
||||||
|
@BillingEmail NVARCHAR(50),
|
||||||
|
@Plan NVARCHAR(50),
|
||||||
|
@PlanType TINYINT,
|
||||||
|
@Seats SMALLINT,
|
||||||
|
@MaxCollections SMALLINT,
|
||||||
|
@UsePolicies BIT,
|
||||||
|
@UseSso BIT,
|
||||||
|
@UseGroups BIT,
|
||||||
|
@UseDirectory BIT,
|
||||||
|
@UseEvents BIT,
|
||||||
|
@UseTotp BIT,
|
||||||
|
@Use2fa BIT,
|
||||||
|
@UseApi BIT,
|
||||||
|
@SelfHost BIT,
|
||||||
|
@UsersGetPremium BIT,
|
||||||
|
@Storage BIGINT,
|
||||||
|
@MaxStorageGb SMALLINT,
|
||||||
|
@Gateway TINYINT,
|
||||||
|
@GatewayCustomerId VARCHAR(50),
|
||||||
|
@GatewaySubscriptionId VARCHAR(50),
|
||||||
|
@ReferenceData VARCHAR(MAX),
|
||||||
|
@Enabled BIT,
|
||||||
|
@LicenseKey VARCHAR(100),
|
||||||
|
@ApiKey VARCHAR(30),
|
||||||
|
@TwoFactorProviders NVARCHAR(MAX),
|
||||||
|
@ExpirationDate DATETIME2(7),
|
||||||
|
@CreationDate DATETIME2(7),
|
||||||
|
@RevisionDate DATETIME2(7)
|
||||||
|
AS
|
||||||
|
BEGIN
|
||||||
|
SET NOCOUNT ON
|
||||||
|
|
||||||
|
UPDATE
|
||||||
|
[dbo].[Organization]
|
||||||
|
SET
|
||||||
|
[Identifier] = @Identifier,
|
||||||
|
[Name] = @Name,
|
||||||
|
[BusinessName] = @BusinessName,
|
||||||
|
[BusinessAddress1] = @BusinessAddress1,
|
||||||
|
[BusinessAddress2] = @BusinessAddress2,
|
||||||
|
[BusinessAddress3] = @BusinessAddress3,
|
||||||
|
[BusinessCountry] = @BusinessCountry,
|
||||||
|
[BusinessTaxNumber] = @BusinessTaxNumber,
|
||||||
|
[BillingEmail] = @BillingEmail,
|
||||||
|
[Plan] = @Plan,
|
||||||
|
[PlanType] = @PlanType,
|
||||||
|
[Seats] = @Seats,
|
||||||
|
[MaxCollections] = @MaxCollections,
|
||||||
|
[UsePolicies] = @UsePolicies,
|
||||||
|
[UseSso] = @UseSso,
|
||||||
|
[UseGroups] = @UseGroups,
|
||||||
|
[UseDirectory] = @UseDirectory,
|
||||||
|
[UseEvents] = @UseEvents,
|
||||||
|
[UseTotp] = @UseTotp,
|
||||||
|
[Use2fa] = @Use2fa,
|
||||||
|
[UseApi] = @UseApi,
|
||||||
|
[SelfHost] = @SelfHost,
|
||||||
|
[UsersGetPremium] = @UsersGetPremium,
|
||||||
|
[Storage] = @Storage,
|
||||||
|
[MaxStorageGb] = @MaxStorageGb,
|
||||||
|
[Gateway] = @Gateway,
|
||||||
|
[GatewayCustomerId] = @GatewayCustomerId,
|
||||||
|
[GatewaySubscriptionId] = @GatewaySubscriptionId,
|
||||||
|
[ReferenceData] = @ReferenceData,
|
||||||
|
[Enabled] = @Enabled,
|
||||||
|
[LicenseKey] = @LicenseKey,
|
||||||
|
[ApiKey] = @ApiKey,
|
||||||
|
[TwoFactorProviders] = @TwoFactorProviders,
|
||||||
|
[ExpirationDate] = @ExpirationDate,
|
||||||
|
[CreationDate] = @CreationDate,
|
||||||
|
[RevisionDate] = @RevisionDate
|
||||||
|
WHERE
|
||||||
|
[Id] = @Id
|
||||||
|
END
|
||||||
|
GO
|
Loading…
Reference in New Issue
Block a user