mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 15:42:48 -05:00
[AC-358] Server changes for self host subscription page changes (#2826)
* [AC-358] Add constant for grace period length * [AC-358] Add SubscriptionExpiration to OrganizationLicense.cs and increment Current_License_File_Version * [AC-358] Update org subscription response model - Add new SelfHostSubscriptionExpiration field that does not include a grace period - Add optional License argument to constructor for self host responses - Use the License, if available, to populate the expiration/subscription expiration fields - Maintain backwards compatability by falling back to organization expiration date * [AC-358] Read organization license file for self hosted subscription response * [AC-358] Decrement current license file version and add comment documenting why * [AC-358] Clarify name for new expiration without grace period field
This commit is contained in:
@ -13,6 +13,12 @@ public static class Constants
|
||||
public const long FileSize501mb = 501L * 1024L * 1024L;
|
||||
public const string DatabaseFieldProtectorPurpose = "DatabaseFieldProtection";
|
||||
public const string DatabaseFieldProtectedPrefix = "P|";
|
||||
|
||||
/// <summary>
|
||||
/// Default number of days an organization has to apply an updated license to their self-hosted installation after
|
||||
/// their subscription has expired.
|
||||
/// </summary>
|
||||
public const int OrganizationSelfHostSubscriptionGracePeriodDays = 60;
|
||||
}
|
||||
|
||||
public static class TokenPurposes
|
||||
|
@ -78,7 +78,8 @@ public class OrganizationLicense : ILicense
|
||||
subscriptionInfo.Subscription.PeriodDuration > TimeSpan.FromDays(180))
|
||||
{
|
||||
Refresh = DateTime.UtcNow.AddDays(30);
|
||||
Expires = subscriptionInfo?.Subscription.PeriodEndDate.Value.AddDays(60);
|
||||
Expires = subscriptionInfo.Subscription.PeriodEndDate?.AddDays(Constants.OrganizationSelfHostSubscriptionGracePeriodDays);
|
||||
ExpirationWithoutGracePeriod = subscriptionInfo.Subscription.PeriodEndDate;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -123,6 +124,7 @@ public class OrganizationLicense : ILicense
|
||||
public DateTime Issued { get; set; }
|
||||
public DateTime? Refresh { get; set; }
|
||||
public DateTime? Expires { get; set; }
|
||||
public DateTime? ExpirationWithoutGracePeriod { get; set; }
|
||||
public bool Trial { get; set; }
|
||||
public LicenseType? LicenseType { get; set; }
|
||||
public string Hash { get; set; }
|
||||
@ -133,10 +135,12 @@ public class OrganizationLicense : ILicense
|
||||
/// <summary>
|
||||
/// Represents the current version of the license format. Should be updated whenever new fields are added.
|
||||
/// </summary>
|
||||
private const int CURRENT_LICENSE_FILE_VERSION = 10;
|
||||
/// <remarks>Intentionally set one version behind to allow self hosted users some time to update before
|
||||
/// getting out of date license errors</remarks>
|
||||
private const int CURRENT_LICENSE_FILE_VERSION = 11;
|
||||
private bool ValidLicenseVersion
|
||||
{
|
||||
get => Version is >= 1 and <= 11;
|
||||
get => Version is >= 1 and <= 12;
|
||||
}
|
||||
|
||||
public byte[] GetDataBytes(bool forHash = false)
|
||||
@ -170,6 +174,8 @@ public class OrganizationLicense : ILicense
|
||||
(Version >= 10 || !p.Name.Equals(nameof(UseScim))) &&
|
||||
// UseCustomPermissions was added in Version 11
|
||||
(Version >= 11 || !p.Name.Equals(nameof(UseCustomPermissions))) &&
|
||||
// ExpirationWithoutGracePeriod was added in Version 12
|
||||
(Version >= 12 || !p.Name.Equals(nameof(ExpirationWithoutGracePeriod))) &&
|
||||
(
|
||||
!forHash ||
|
||||
(
|
||||
|
Reference in New Issue
Block a user