mirror of
https://github.com/bitwarden/server.git
synced 2025-07-01 08:02:49 -05:00
implement useapi and apikey
This commit is contained in:
@ -35,6 +35,7 @@ namespace Bit.Core.Models.Api
|
||||
UseEvents = organization.UseEvents;
|
||||
UseTotp = organization.UseTotp;
|
||||
Use2fa = organization.Use2fa;
|
||||
UseApi = organization.UseApi;
|
||||
UsersGetPremium = organization.UsersGetPremium;
|
||||
SelfHost = organization.SelfHost;
|
||||
}
|
||||
@ -58,6 +59,7 @@ namespace Bit.Core.Models.Api
|
||||
public bool UseEvents { get; set; }
|
||||
public bool UseTotp { get; set; }
|
||||
public bool Use2fa { get; set; }
|
||||
public bool UseApi { get; set; }
|
||||
public bool UsersGetPremium { get; set; }
|
||||
public bool SelfHost { get; set; }
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ namespace Bit.Core.Models.Api
|
||||
UseEvents = organization.UseEvents;
|
||||
UseTotp = organization.UseTotp;
|
||||
Use2fa = organization.Use2fa;
|
||||
UseApi = organization.UseApi;
|
||||
UsersGetPremium = organization.UsersGetPremium;
|
||||
SelfHost = organization.SelfHost;
|
||||
Seats = organization.Seats;
|
||||
@ -33,6 +34,7 @@ namespace Bit.Core.Models.Api
|
||||
public bool UseEvents { get; set; }
|
||||
public bool UseTotp { get; set; }
|
||||
public bool Use2fa { get; set; }
|
||||
public bool UseApi { get; set; }
|
||||
public bool UsersGetPremium { get; set; }
|
||||
public bool SelfHost { get; set; }
|
||||
public int Seats { get; set; }
|
||||
|
@ -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
|
||||
|
@ -12,6 +12,7 @@ namespace Bit.Core.Models.Data
|
||||
public bool UseEvents { get; set; }
|
||||
public bool UseTotp { get; set; }
|
||||
public bool Use2fa { get; set; }
|
||||
public bool UseApi{ get; set; }
|
||||
public bool SelfHost { get; set; }
|
||||
public bool UsersGetPremium { get; set; }
|
||||
public int Seats { get; set; }
|
||||
|
@ -19,6 +19,7 @@ namespace Bit.Core.Models.StaticStore
|
||||
public bool UseEvents { get; set; }
|
||||
public bool UseTotp { get; set; }
|
||||
public bool Use2fa { get; set; }
|
||||
public bool UseApi { get; set; }
|
||||
public short? MaxStorageGb { get; set; }
|
||||
public decimal BasePrice { get; set; }
|
||||
public decimal SeatPrice { get; set; }
|
||||
|
@ -1,8 +1,6 @@
|
||||
using System;
|
||||
using Bit.Core.Utilities;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Services;
|
||||
using Bit.Core.Exceptions;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using System.Linq;
|
||||
@ -31,6 +29,7 @@ namespace Bit.Core.Models.Table
|
||||
public bool UseEvents { get; set; }
|
||||
public bool UseTotp { get; set; }
|
||||
public bool Use2fa { get; set; }
|
||||
public bool UseApi { get; set; }
|
||||
public bool SelfHost { get; set; }
|
||||
public bool UsersGetPremium { get; set; }
|
||||
public long? Storage { get; set; }
|
||||
@ -40,6 +39,7 @@ namespace Bit.Core.Models.Table
|
||||
public string GatewaySubscriptionId { get; set; }
|
||||
public bool Enabled { get; set; } = true;
|
||||
public string LicenseKey { get; set; }
|
||||
public string ApiKey { get; set; }
|
||||
public string TwoFactorProviders { get; set; }
|
||||
public DateTime? ExpirationDate { get; set; }
|
||||
public DateTime CreationDate { get; internal set; } = DateTime.UtcNow;
|
||||
|
Reference in New Issue
Block a user