@@ -22,16 +22,9 @@ public Task<List<Claim>> GenerateClaims(Organization entity, LicenseContext lice
22
22
var claims = new List < Claim >
23
23
{
24
24
new ( nameof ( OrganizationLicenseConstants . LicenseType ) , LicenseType . Organization . ToString ( ) ) ,
25
- new Claim ( nameof ( OrganizationLicenseConstants . LicenseKey ) , entity . LicenseKey ) ,
26
- new ( nameof ( OrganizationLicenseConstants . InstallationId ) , licenseContext . InstallationId . ToString ( ) ) ,
27
25
new ( nameof ( OrganizationLicenseConstants . Id ) , entity . Id . ToString ( ) ) ,
28
- new ( nameof ( OrganizationLicenseConstants . Name ) , entity . Name ) ,
29
- new ( nameof ( OrganizationLicenseConstants . BillingEmail ) , entity . BillingEmail ) ,
30
26
new ( nameof ( OrganizationLicenseConstants . Enabled ) , entity . Enabled . ToString ( ) ) ,
31
- new ( nameof ( OrganizationLicenseConstants . Plan ) , entity . Plan ) ,
32
27
new ( nameof ( OrganizationLicenseConstants . PlanType ) , entity . PlanType . ToString ( ) ) ,
33
- new ( nameof ( OrganizationLicenseConstants . Seats ) , entity . Seats . ToString ( ) ) ,
34
- new ( nameof ( OrganizationLicenseConstants . MaxCollections ) , entity . MaxCollections . ToString ( ) ) ,
35
28
new ( nameof ( OrganizationLicenseConstants . UsePolicies ) , entity . UsePolicies . ToString ( ) ) ,
36
29
new ( nameof ( OrganizationLicenseConstants . UseSso ) , entity . UseSso . ToString ( ) ) ,
37
30
new ( nameof ( OrganizationLicenseConstants . UseKeyConnector ) , entity . UseKeyConnector . ToString ( ) ) ,
@@ -43,32 +36,79 @@ public Task<List<Claim>> GenerateClaims(Organization entity, LicenseContext lice
43
36
new ( nameof ( OrganizationLicenseConstants . Use2fa ) , entity . Use2fa . ToString ( ) ) ,
44
37
new ( nameof ( OrganizationLicenseConstants . UseApi ) , entity . UseApi . ToString ( ) ) ,
45
38
new ( nameof ( OrganizationLicenseConstants . UseResetPassword ) , entity . UseResetPassword . ToString ( ) ) ,
46
- new ( nameof ( OrganizationLicenseConstants . MaxStorageGb ) , entity . MaxStorageGb . ToString ( ) ) ,
47
39
new ( nameof ( OrganizationLicenseConstants . SelfHost ) , entity . SelfHost . ToString ( ) ) ,
48
40
new ( nameof ( OrganizationLicenseConstants . UsersGetPremium ) , entity . UsersGetPremium . ToString ( ) ) ,
49
41
new ( nameof ( OrganizationLicenseConstants . UseCustomPermissions ) , entity . UseCustomPermissions . ToString ( ) ) ,
50
- new ( nameof ( OrganizationLicenseConstants . Issued ) , DateTime . UtcNow . ToString ( CultureInfo . InvariantCulture ) ) ,
51
42
new ( nameof ( OrganizationLicenseConstants . UsePasswordManager ) , entity . UsePasswordManager . ToString ( ) ) ,
52
43
new ( nameof ( OrganizationLicenseConstants . UseSecretsManager ) , entity . UseSecretsManager . ToString ( ) ) ,
53
- new ( nameof ( OrganizationLicenseConstants . SmSeats ) , entity . SmSeats . ToString ( ) ) ,
54
- new ( nameof ( OrganizationLicenseConstants . SmServiceAccounts ) , entity . SmServiceAccounts . ToString ( ) ) ,
55
44
// LimitCollectionCreationDeletion was split and removed from the
56
45
// license. Left here with an assignment from the new values for
57
46
// backwards compatibility.
58
47
new ( nameof ( OrganizationLicenseConstants . LimitCollectionCreationDeletion ) ,
59
48
( entity . LimitCollectionCreation || entity . LimitCollectionDeletion ) . ToString ( ) ) ,
60
49
new ( nameof ( OrganizationLicenseConstants . AllowAdminAccessToAllCollectionItems ) , entity . AllowAdminAccessToAllCollectionItems . ToString ( ) ) ,
50
+ new ( nameof ( OrganizationLicenseConstants . Issued ) , DateTime . UtcNow . ToString ( CultureInfo . InvariantCulture ) ) ,
61
51
new ( nameof ( OrganizationLicenseConstants . Expires ) , expires . ToString ( CultureInfo . InvariantCulture ) ) ,
62
52
new ( nameof ( OrganizationLicenseConstants . Refresh ) , refresh . ToString ( CultureInfo . InvariantCulture ) ) ,
63
53
new ( nameof ( OrganizationLicenseConstants . ExpirationWithoutGracePeriod ) , expirationWithoutGracePeriod . ToString ( CultureInfo . InvariantCulture ) ) ,
64
54
new ( nameof ( OrganizationLicenseConstants . Trial ) , trial . ToString ( ) ) ,
65
55
} ;
66
56
57
+ if ( entity . Name is not null )
58
+ {
59
+ claims . Add ( new ( nameof ( OrganizationLicenseConstants . Name ) , entity . Name ) ) ;
60
+ }
61
+
62
+ if ( entity . BillingEmail is not null )
63
+ {
64
+ claims . Add ( new ( nameof ( OrganizationLicenseConstants . BillingEmail ) , entity . BillingEmail ) ) ;
65
+ }
66
+
67
+ if ( entity . Plan is not null )
68
+ {
69
+ claims . Add ( new ( nameof ( OrganizationLicenseConstants . Plan ) , entity . Plan ) ) ;
70
+ }
71
+
67
72
if ( entity . BusinessName is not null )
68
73
{
69
74
claims . Add ( new Claim ( nameof ( OrganizationLicenseConstants . BusinessName ) , entity . BusinessName ) ) ;
70
75
}
71
76
77
+ if ( entity . LicenseKey is not null )
78
+ {
79
+ claims . Add ( new Claim ( nameof ( OrganizationLicenseConstants . LicenseKey ) , entity . LicenseKey ) ) ;
80
+ }
81
+
82
+ if ( licenseContext . InstallationId . HasValue )
83
+ {
84
+ claims . Add ( new Claim ( nameof ( OrganizationLicenseConstants . InstallationId ) , licenseContext . InstallationId . ToString ( ) ) ) ;
85
+ }
86
+
87
+ if ( entity . Seats . HasValue )
88
+ {
89
+ claims . Add ( new Claim ( nameof ( OrganizationLicenseConstants . Seats ) , entity . Seats . ToString ( ) ) ) ;
90
+ }
91
+
92
+ if ( entity . MaxCollections . HasValue )
93
+ {
94
+ claims . Add ( new Claim ( nameof ( OrganizationLicenseConstants . MaxCollections ) , entity . MaxCollections . ToString ( ) ) ) ;
95
+ }
96
+
97
+ if ( entity . MaxStorageGb . HasValue )
98
+ {
99
+ claims . Add ( new Claim ( nameof ( OrganizationLicenseConstants . MaxStorageGb ) , entity . MaxStorageGb . ToString ( ) ) ) ;
100
+ }
101
+
102
+ if ( entity . SmSeats . HasValue )
103
+ {
104
+ claims . Add ( new Claim ( nameof ( OrganizationLicenseConstants . SmSeats ) , entity . SmSeats . ToString ( ) ) ) ;
105
+ }
106
+
107
+ if ( entity . SmServiceAccounts . HasValue )
108
+ {
109
+ claims . Add ( new Claim ( nameof ( OrganizationLicenseConstants . SmServiceAccounts ) , entity . SmServiceAccounts . ToString ( ) ) ) ;
110
+ }
111
+
72
112
return Task . FromResult ( claims ) ;
73
113
}
74
114
0 commit comments