1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-01 08:02:49 -05:00

use policies property for orgs

This commit is contained in:
Kyle Spearrin
2020-01-15 15:00:54 -05:00
parent 58faf5266b
commit e8054df5b4
14 changed files with 310 additions and 6 deletions

View File

@ -30,6 +30,7 @@ namespace Bit.Core.Models.Api
Seats = organization.Seats;
MaxCollections = organization.MaxCollections;
MaxStorageGb = organization.MaxStorageGb;
UsePolicies = organization.UsePolicies;
UseGroups = organization.UseGroups;
UseDirectory = organization.UseDirectory;
UseEvents = organization.UseEvents;
@ -54,6 +55,7 @@ namespace Bit.Core.Models.Api
public short? Seats { get; set; }
public short? MaxCollections { get; set; }
public short? MaxStorageGb { get; set; }
public bool UsePolicies { get; set; }
public bool UseGroups { get; set; }
public bool UseDirectory { get; set; }
public bool UseEvents { get; set; }

View File

@ -19,7 +19,7 @@ namespace Bit.Core.Models.Business
public OrganizationLicense(Organization org, SubscriptionInfo subscriptionInfo, Guid installationId,
ILicensingService licenseService)
{
Version = 5;
Version = 5; // TODO: bump to version 6
LicenseKey = org.LicenseKey;
InstallationId = installationId;
Id = org.Id;
@ -31,6 +31,7 @@ namespace Bit.Core.Models.Business
PlanType = org.PlanType;
Seats = org.Seats;
MaxCollections = org.MaxCollections;
UsePolicies = org.UsePolicies;
UseGroups = org.UseGroups;
UseEvents = org.UseEvents;
UseDirectory = org.UseDirectory;
@ -98,6 +99,7 @@ namespace Bit.Core.Models.Business
public PlanType PlanType { get; set; }
public short? Seats { get; set; }
public short? MaxCollections { get; set; }
public bool UsePolicies { get; set; }
public bool UseGroups { get; set; }
public bool UseEvents { get; set; }
public bool UseDirectory { get; set; }
@ -120,7 +122,7 @@ namespace Bit.Core.Models.Business
public byte[] GetDataBytes(bool forHash = false)
{
string data = null;
if(Version >= 1 && Version <= 5)
if(Version >= 1 && Version <= 6)
{
var props = typeof(OrganizationLicense)
.GetProperties(BindingFlags.Public | BindingFlags.Instance)
@ -135,6 +137,8 @@ namespace Bit.Core.Models.Business
(Version >= 4 || !p.Name.Equals(nameof(Use2fa))) &&
// UseApi was added in Version 5
(Version >= 5 || !p.Name.Equals(nameof(UseApi))) &&
// UsePolicies was added in Version 6
(Version >= 6 || !p.Name.Equals(nameof(UsePolicies))) &&
(
!forHash ||
(
@ -171,7 +175,7 @@ namespace Bit.Core.Models.Business
return false;
}
if(Version >= 1 && Version <= 5)
if(Version >= 1 && Version <= 6)
{
return InstallationId == globalSettings.Installation.Id && SelfHost;
}
@ -188,7 +192,7 @@ namespace Bit.Core.Models.Business
return false;
}
if(Version >= 1 && Version <= 5)
if(Version >= 1 && Version <= 6)
{
var valid =
globalSettings.Installation.Id == InstallationId &&
@ -223,6 +227,11 @@ namespace Bit.Core.Models.Business
valid = organization.UseApi == UseApi;
}
if(valid && Version >= 6)
{
valid = organization.UsePolicies == UsePolicies;
}
return valid;
}
else

View File

@ -15,6 +15,7 @@ namespace Bit.Core.Models.StaticStore
public short? MaxAdditionalSeats { get; set; }
public bool CanBuyPremiumAccessAddon { get; set; }
public bool UseGroups { get; set; }
public bool UsePolicies { get; set; }
public bool UseDirectory { get; set; }
public bool UseEvents { get; set; }
public bool UseTotp { get; set; }

View File

@ -24,6 +24,7 @@ namespace Bit.Core.Models.Table
public PlanType PlanType { get; set; }
public short? Seats { get; set; }
public short? MaxCollections { get; set; }
public bool UsePolicies { get; set; }
public bool UseGroups { get; set; }
public bool UseDirectory { get; set; }
public bool UseEvents { get; set; }