-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Allow extensibility of DefaultAuthorizationService #23143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -77,7 +77,7 @@ public DefaultAuthorizationService(IAuthorizationPolicyProvider policyProvider, | |||
/// A flag indicating whether authorization has succeeded. | |||
/// This value is <value>true</value> when the user fulfills the policy otherwise <value>false</value>. | |||
/// </returns> | |||
public async Task<AuthorizationResult> AuthorizeAsync(ClaimsPrincipal user, object? resource, IEnumerable<IAuthorizationRequirement> requirements) | |||
public virtual async Task<AuthorizationResult> AuthorizeAsync(ClaimsPrincipal user, object? resource, IEnumerable<IAuthorizationRequirement> requirements) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason this couldn't use explicit interface implementation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that way you can only replace the methods instead of building upon them?
When allowing to override, a developer can still call the base method from inside the overridden method to reuse the logic and add own behavior.
@hansmbakker can you update the ref assembly as well? https://github.com/dotnet/aspnetcore/blob/master/docs/ReferenceAssemblies.md |
When only a small behavior change of the `DefaultAuthorizationService` is wanted, it would be nice if you could override its methods and building upon them rather than having a copy-paste of the class in your codebase. Inside the `override` methods in your inherited class you could call the `base` method to reuse parts of its logic. Please refer to #23094 for the usecase.
@HaoK done |
Thanks @hansmbakker |
When only a small behavior change of the
DefaultAuthorizationService
is wanted, it would be nice if you could override its methods and building upon them rather than having a copy-paste of the class in your codebase.Inside the
override
methods in your inherited class you could call thebase
method to reuse parts of its logic.Please refer to #23094 for the usecase & details.
Addresses #23094