mirror of
https://github.com/bitwarden/server.git
synced 2025-07-03 09:02:48 -05:00
implement useapi and apikey
This commit is contained in:
@ -19,7 +19,7 @@ namespace Bit.Core.Models.Business
|
||||
public OrganizationLicense(Organization org, SubscriptionInfo subscriptionInfo, Guid installationId,
|
||||
ILicensingService licenseService)
|
||||
{
|
||||
Version = 4;
|
||||
Version = 4; // TODO: Version 5 bump
|
||||
LicenseKey = org.LicenseKey;
|
||||
InstallationId = installationId;
|
||||
Id = org.Id;
|
||||
@ -36,6 +36,7 @@ namespace Bit.Core.Models.Business
|
||||
UseDirectory = org.UseDirectory;
|
||||
UseTotp = org.UseTotp;
|
||||
Use2fa = org.Use2fa;
|
||||
UseApi = org.UseApi;
|
||||
MaxStorageGb = org.MaxStorageGb;
|
||||
SelfHost = org.SelfHost;
|
||||
UsersGetPremium = org.UsersGetPremium;
|
||||
@ -102,6 +103,7 @@ namespace Bit.Core.Models.Business
|
||||
public bool UseDirectory { get; set; }
|
||||
public bool UseTotp { get; set; }
|
||||
public bool Use2fa { get; set; }
|
||||
public bool UseApi { get; set; }
|
||||
public short? MaxStorageGb { get; set; }
|
||||
public bool SelfHost { get; set; }
|
||||
public bool UsersGetPremium { get; set; }
|
||||
@ -118,7 +120,7 @@ namespace Bit.Core.Models.Business
|
||||
public byte[] GetDataBytes(bool forHash = false)
|
||||
{
|
||||
string data = null;
|
||||
if(Version >= 1 && Version <= 4)
|
||||
if(Version >= 1 && Version <= 5)
|
||||
{
|
||||
var props = typeof(OrganizationLicense)
|
||||
.GetProperties(BindingFlags.Public | BindingFlags.Instance)
|
||||
@ -131,6 +133,8 @@ namespace Bit.Core.Models.Business
|
||||
(Version >= 3 || !p.Name.Equals(nameof(UseEvents))) &&
|
||||
// Use2fa was added in Version 4
|
||||
(Version >= 4 || !p.Name.Equals(nameof(Use2fa))) &&
|
||||
// UseApi was added in Version 5
|
||||
(Version >= 5 || !p.Name.Equals(nameof(UseApi))) &&
|
||||
(
|
||||
!forHash ||
|
||||
(
|
||||
@ -167,7 +171,7 @@ namespace Bit.Core.Models.Business
|
||||
return false;
|
||||
}
|
||||
|
||||
if(Version >= 1 && Version <= 4)
|
||||
if(Version >= 1 && Version <= 5)
|
||||
{
|
||||
return InstallationId == globalSettings.Installation.Id && SelfHost;
|
||||
}
|
||||
@ -184,7 +188,7 @@ namespace Bit.Core.Models.Business
|
||||
return false;
|
||||
}
|
||||
|
||||
if(Version >= 1 && Version <= 4)
|
||||
if(Version >= 1 && Version <= 5)
|
||||
{
|
||||
var valid =
|
||||
globalSettings.Installation.Id == InstallationId &&
|
||||
@ -214,6 +218,11 @@ namespace Bit.Core.Models.Business
|
||||
valid = organization.Use2fa == Use2fa;
|
||||
}
|
||||
|
||||
if(valid && Version >= 5)
|
||||
{
|
||||
valid = organization.UseApi == UseApi;
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
else
|
||||
|
Reference in New Issue
Block a user