File tree Expand file tree Collapse file tree
src/IdentityServer/Licensing/v2 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ public IEnumerable<LicenseFeature> UsedFeatures()
2828 {
2929 foreach ( LicenseFeature feature in Enum . GetValues < LicenseFeature > ( ) )
3030 {
31- if ( ( _usedFeatures & feature . ToFeatureMask ( ) ) != 0 )
31+ if ( ( _usedFeatures & ( ulong ) feature ) != 0 )
3232 {
3333 yield return feature ;
3434 }
@@ -52,8 +52,7 @@ public void UseFeature(LicenseFeature feature)
5252 }
5353 }
5454 }
55- // TODO - refactor the feature so that its value is already the feature mask
56- var featureMask = feature . ToFeatureMask ( ) ;
55+ var featureMask = ( ulong ) feature ;
5756 Interlocked . Or ( ref _usedFeatures , featureMask ) ;
5857 }
5958
Original file line number Diff line number Diff line change @@ -121,7 +121,7 @@ internal License(ClaimsPrincipal claims)
121121 /// <returns></returns>
122122 public bool IsEnabled ( LicenseFeature feature )
123123 {
124- return ! IsConfigured || ( AllowedFeatureMask & feature . ToFeatureMask ( ) ) != 0 ;
124+ return ! IsConfigured || ( AllowedFeatureMask & ( ulong ) feature ) != 0 ;
125125 }
126126
127127
@@ -136,7 +136,7 @@ private ulong AllowedFeatureMask
136136 foreach ( var featureClaim in Features )
137137 {
138138 var feature = ToFeatureEnum ( featureClaim ) ;
139- features |= feature . ToFeatureMask ( ) ;
139+ features |= ( ulong ) feature ;
140140 }
141141
142142 _allowedFeatureMask = features ;
@@ -202,7 +202,7 @@ private ulong FeatureMaskForFeatures(params LicenseFeature[] licenseFeatures)
202202 var result = 0UL ;
203203 foreach ( var feature in licenseFeatures )
204204 {
205- result |= feature . ToFeatureMask ( ) ;
205+ result |= ( ulong ) feature ;
206206 }
207207 return result ;
208208 }
Original file line number Diff line number Diff line change @@ -9,70 +9,65 @@ namespace Duende.IdentityServer.Licensing.v2;
99/// <summary>
1010/// The features of IdentityServer that can be enabled or disabled through the License.
1111/// </summary>
12- public enum LicenseFeature
12+ public enum LicenseFeature : ulong
1313{
1414 /// <summary>
1515 /// Automatic Key Management
1616 /// </summary>
1717 [ Description ( "key_management" ) ]
18- KeyManagement ,
18+ KeyManagement = 1 ,
1919
2020 /// <summary>
2121 /// Pushed Authorization Requests
2222 /// </summary>
2323 [ Description ( "par" ) ]
24- PAR ,
24+ PAR = 2 ,
2525
2626 /// <summary>
2727 /// Resource Isolation
2828 /// </summary>
2929 [ Description ( "resource_isolation" ) ]
30- ResourceIsolation ,
30+ ResourceIsolation = 4 ,
3131
3232 /// <summary>
3333 /// Dyanmic External Providers
3434 /// </summary>
3535 [ Description ( "dynamic_providers" ) ]
36- DynamicProviders ,
36+ DynamicProviders = 8 ,
3737
3838 /// <summary>
3939 /// Client Initiated Backchannel Authorization
4040 /// </summary>
4141 [ Description ( "ciba" ) ]
42- CIBA ,
42+ CIBA = 16 ,
4343
4444 /// <summary>
4545 /// Server-Side Sessions
4646 /// </summary>
4747 [ Description ( "server_side_sessions" ) ]
48- ServerSideSessions ,
48+ ServerSideSessions = 32 ,
4949
5050 /// <summary>
5151 /// Demonstrating Proof of Possesion
5252 /// </summary>
5353 [ Description ( "dpop" ) ]
54- DPoP ,
54+ DPoP = 64 ,
5555
5656 /// <summary>
5757 /// Configuration API
5858 /// </summary>
5959 [ Description ( "config_api" ) ]
60- DCR ,
60+ DCR = 128 ,
6161
6262 /// <summary>
6363 /// ISV (same as Redistribution)
6464 /// </summary>
6565 [ Description ( "isv" ) ]
66- ISV ,
66+ ISV = 256 ,
6767
6868 /// <summary>
6969 /// Dedistribution
7070 /// </summary>
7171 [ Description ( "redistribution" ) ]
72- Redistribution ,
72+ Redistribution = 512 ,
7373}
74-
75- internal static class LicenseFeatureExtensions
76- {
77- internal static ulong ToFeatureMask ( this LicenseFeature feature ) => 1UL << ( int ) feature ;
78- }
You can’t perform that action at this time.
0 commit comments