mirror of
https://github.com/bitwarden/server
synced 2025-12-06 00:03:34 +00:00
[PM-28249] Write PlanType claim as an integer (#6610)
* Write PlanType claim as an integer * Accept FamiliesAnnually2025 for FamiliesAnnually plan type
This commit is contained in:
@@ -26,7 +26,7 @@ public class OrganizationLicenseClaimsFactory : ILicenseClaimsFactory<Organizati
|
|||||||
new(nameof(OrganizationLicenseConstants.LicenseType), LicenseType.Organization.ToString()),
|
new(nameof(OrganizationLicenseConstants.LicenseType), LicenseType.Organization.ToString()),
|
||||||
new(nameof(OrganizationLicenseConstants.Id), entity.Id.ToString()),
|
new(nameof(OrganizationLicenseConstants.Id), entity.Id.ToString()),
|
||||||
new(nameof(OrganizationLicenseConstants.Enabled), entity.Enabled.ToString()),
|
new(nameof(OrganizationLicenseConstants.Enabled), entity.Enabled.ToString()),
|
||||||
new(nameof(OrganizationLicenseConstants.PlanType), entity.PlanType.ToString()),
|
new(nameof(OrganizationLicenseConstants.PlanType), ((int)entity.PlanType).ToString()),
|
||||||
new(nameof(OrganizationLicenseConstants.UsePolicies), entity.UsePolicies.ToString()),
|
new(nameof(OrganizationLicenseConstants.UsePolicies), entity.UsePolicies.ToString()),
|
||||||
new(nameof(OrganizationLicenseConstants.UseSso), entity.UseSso.ToString()),
|
new(nameof(OrganizationLicenseConstants.UseSso), entity.UseSso.ToString()),
|
||||||
new(nameof(OrganizationLicenseConstants.UseKeyConnector), entity.UseKeyConnector.ToString()),
|
new(nameof(OrganizationLicenseConstants.UseKeyConnector), entity.UseKeyConnector.ToString()),
|
||||||
|
|||||||
@@ -399,7 +399,6 @@ public class OrganizationLicense : ILicense
|
|||||||
var installationId = claimsPrincipal.GetValue<Guid>(nameof(InstallationId));
|
var installationId = claimsPrincipal.GetValue<Guid>(nameof(InstallationId));
|
||||||
var licenseKey = claimsPrincipal.GetValue<string>(nameof(LicenseKey));
|
var licenseKey = claimsPrincipal.GetValue<string>(nameof(LicenseKey));
|
||||||
var enabled = claimsPrincipal.GetValue<bool>(nameof(Enabled));
|
var enabled = claimsPrincipal.GetValue<bool>(nameof(Enabled));
|
||||||
var planType = claimsPrincipal.GetValue<PlanType>(nameof(PlanType));
|
|
||||||
var seats = claimsPrincipal.GetValue<int?>(nameof(Seats));
|
var seats = claimsPrincipal.GetValue<int?>(nameof(Seats));
|
||||||
var maxCollections = claimsPrincipal.GetValue<short?>(nameof(MaxCollections));
|
var maxCollections = claimsPrincipal.GetValue<short?>(nameof(MaxCollections));
|
||||||
var useGroups = claimsPrincipal.GetValue<bool>(nameof(UseGroups));
|
var useGroups = claimsPrincipal.GetValue<bool>(nameof(UseGroups));
|
||||||
@@ -425,12 +424,18 @@ public class OrganizationLicense : ILicense
|
|||||||
var useOrganizationDomains = claimsPrincipal.GetValue<bool>(nameof(UseOrganizationDomains));
|
var useOrganizationDomains = claimsPrincipal.GetValue<bool>(nameof(UseOrganizationDomains));
|
||||||
var useAutomaticUserConfirmation = claimsPrincipal.GetValue<bool>(nameof(UseAutomaticUserConfirmation));
|
var useAutomaticUserConfirmation = claimsPrincipal.GetValue<bool>(nameof(UseAutomaticUserConfirmation));
|
||||||
|
|
||||||
|
var claimedPlanType = claimsPrincipal.GetValue<PlanType>(nameof(PlanType));
|
||||||
|
|
||||||
|
var planTypesMatch = claimedPlanType == PlanType.FamiliesAnnually
|
||||||
|
? organization.PlanType is PlanType.FamiliesAnnually or PlanType.FamiliesAnnually2025
|
||||||
|
: organization.PlanType == claimedPlanType;
|
||||||
|
|
||||||
return issued <= DateTime.UtcNow &&
|
return issued <= DateTime.UtcNow &&
|
||||||
expires >= DateTime.UtcNow &&
|
expires >= DateTime.UtcNow &&
|
||||||
installationId == globalSettings.Installation.Id &&
|
installationId == globalSettings.Installation.Id &&
|
||||||
licenseKey == organization.LicenseKey &&
|
licenseKey == organization.LicenseKey &&
|
||||||
enabled == organization.Enabled &&
|
enabled == organization.Enabled &&
|
||||||
planType == organization.PlanType &&
|
planTypesMatch &&
|
||||||
seats == organization.Seats &&
|
seats == organization.Seats &&
|
||||||
maxCollections == organization.MaxCollections &&
|
maxCollections == organization.MaxCollections &&
|
||||||
useGroups == organization.UseGroups &&
|
useGroups == organization.UseGroups &&
|
||||||
|
|||||||
Reference in New Issue
Block a user