Skip to content

Commit 89bc837

Browse files
authored
Merge pull request #21737 from abpframework/21734
Add comments for extension methods of `IAuthorizationService/IFeatureChecker`.
2 parents eda0b93 + e395ee3 commit 89bc837

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

framework/src/Volo.Abp.Authorization/Microsoft/AspNetCore/Authorization/AbpAuthorizationServiceExtensions.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ public static async Task<bool> IsGrantedAsync(this IAuthorizationService authori
108108
return (await authorizationService.AuthorizeAsync(resource, policyName)).Succeeded;
109109
}
110110

111+
/// <summary>
112+
/// Checks if CurrentPrincipal meets a specific authorization policy, throwing an <see cref="AbpAuthorizationException"/> if not.
113+
/// </summary>
114+
/// <param name="authorizationService">The <see cref="IAuthorizationService"/> providing authorization.</param>
115+
/// <param name="policyName">The name of the policy to evaluate.</param>
111116
public static async Task CheckAsync(this IAuthorizationService authorizationService, string policyName)
112117
{
113118
if (!await authorizationService.IsGrantedAsync(policyName))
@@ -117,6 +122,12 @@ public static async Task CheckAsync(this IAuthorizationService authorizationServ
117122
}
118123
}
119124

125+
/// <summary>
126+
/// Checks if CurrentPrincipal meets a specific requirement for the specified resource, throwing an <see cref="AbpAuthorizationException"/> if not.
127+
/// </summary>
128+
/// <param name="authorizationService">The <see cref="IAuthorizationService"/> providing authorization.</param>
129+
/// <param name="resource">The resource to evaluate the policy against.</param>
130+
/// <param name="requirement">The requirement to evaluate the policy against.</param>
120131
public static async Task CheckAsync(this IAuthorizationService authorizationService, object resource, IAuthorizationRequirement requirement)
121132
{
122133
if (!await authorizationService.IsGrantedAsync(resource, requirement))
@@ -126,6 +137,12 @@ public static async Task CheckAsync(this IAuthorizationService authorizationServ
126137
}
127138
}
128139

140+
/// <summary>
141+
/// Checks if CurrentPrincipal meets a specific authorization policy against the specified resource, throwing an <see cref="AbpAuthorizationException"/> if not.
142+
/// </summary>
143+
/// <param name="authorizationService">The <see cref="IAuthorizationService"/> providing authorization.</param>
144+
/// <param name="resource">The resource to evaluate the policy against.</param>
145+
/// <param name="policy">The policy to evaluate.</param>
129146
public static async Task CheckAsync(this IAuthorizationService authorizationService, object resource, AuthorizationPolicy policy)
130147
{
131148
if (!await authorizationService.IsGrantedAsync(resource, policy))
@@ -135,6 +152,11 @@ public static async Task CheckAsync(this IAuthorizationService authorizationServ
135152
}
136153
}
137154

155+
/// <summary>
156+
/// Checks if CurrentPrincipal meets a specific authorization policy, throwing an <see cref="AbpAuthorizationException"/> if not.
157+
/// </summary>
158+
/// <param name="authorizationService">The <see cref="IAuthorizationService"/> providing authorization.</param>
159+
/// <param name="policy">The policy to evaluate.</param>
138160
public static async Task CheckAsync(this IAuthorizationService authorizationService, AuthorizationPolicy policy)
139161
{
140162
if (!await authorizationService.IsGrantedAsync(policy))
@@ -143,6 +165,12 @@ public static async Task CheckAsync(this IAuthorizationService authorizationServ
143165
}
144166
}
145167

168+
/// <summary>
169+
/// Checks if CurrentPrincipal meets a specific authorization policy against the specified resource, throwing an <see cref="AbpAuthorizationException"/> if not.
170+
/// </summary>
171+
/// <param name="authorizationService">The <see cref="IAuthorizationService"/> providing authorization.</param>
172+
/// <param name="resource">The resource to evaluate the policy against.</param>
173+
/// <param name="requirements">The requirements to evaluate the policy against.</param>
146174
public static async Task CheckAsync(this IAuthorizationService authorizationService, object resource, IEnumerable<IAuthorizationRequirement> requirements)
147175
{
148176
if (!await authorizationService.IsGrantedAsync(resource, requirements))
@@ -152,6 +180,12 @@ public static async Task CheckAsync(this IAuthorizationService authorizationServ
152180
}
153181
}
154182

183+
/// <summary>
184+
/// Checks if CurrentPrincipal meets a specific authorization policy against the specified resource, throwing an <see cref="AbpAuthorizationException"/> if not.
185+
/// </summary>
186+
/// <param name="authorizationService">The <see cref="IAuthorizationService"/> providing authorization.</param>
187+
/// <param name="resource">The resource to evaluate the policy against.</param>
188+
/// <param name="policyName">The name of the policy to evaluate.</param>
155189
public static async Task CheckAsync(this IAuthorizationService authorizationService, object resource, string policyName)
156190
{
157191
if (!await authorizationService.IsGrantedAsync(resource, policyName))

framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureCheckerExtensions.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ public static async Task<bool> IsEnabledAsync(this IFeatureChecker featureChecke
5252
return false;
5353
}
5454

55+
/// <summary>
56+
/// Checks if the specified feature is enabled and throws an <see cref="AbpAuthorizationException"/> if it is not.
57+
/// </summary>
58+
/// <param name="featureChecker">The <see cref="IFeatureChecker"/></param>
59+
/// <param name="featureName">The name of the feature to be checked.</param>
5560
public static async Task CheckEnabledAsync(this IFeatureChecker featureChecker, string featureName)
5661
{
5762
if (!(await featureChecker.IsEnabledAsync(featureName)))
@@ -61,6 +66,13 @@ public static async Task CheckEnabledAsync(this IFeatureChecker featureChecker,
6166
}
6267
}
6368

69+
/// <summary>
70+
/// Checks if the specified features are enabled and throws an <see cref="AbpAuthorizationException"/> if they are not.
71+
/// The check can either require all features to be enabled or just one, based on the <paramref name="requiresAll"/> parameter.
72+
/// </summary>
73+
/// <param name="featureChecker">The <see cref="IFeatureChecker"/></param>
74+
/// <param name="requiresAll">True: Requires all features to be enabled. False: Requires at least one of the features to be enabled.</param>
75+
/// <param name="featureNames">The names of the features to be checked.</param>
6476
public static async Task CheckEnabledAsync(this IFeatureChecker featureChecker, bool requiresAll, params string[] featureNames)
6577
{
6678
if (featureNames.IsNullOrEmpty())

0 commit comments

Comments
 (0)