-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
AuthorizationFilterContext is no longer available in HandleRequirementAsync() #11075
Comments
protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, CookieOrTokenAuthorizationRequirement requirement)
{
if (context.Resource is Endpoint endpoint)
{
if (endpoint.Metadata.OfType<IFilterMetadata>().Any(filter => filter is MyFilter))
{
context.Succeed(requirement);
return Task.CompletedTask;
}
}
} This is because when using endpoint routing in ASP.NET Core 3.0:
|
Worked like a charm, thanks for the fast response! |
As it is breaking change for Preview 8 - will we have workaround or suggested solution on how to redirect to custom URL when authorization failed? |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
In ASP.NET Core 3.0
AuthorizationFilterContext
is no longer available insideAuthorizationHandler.HandleRequirementAsync()
method.In 2.2 this method is used to work:
However, in 3.0
context.Resource
is no longerAuthorizationFilterContext
, but insteadMicrosoft.AspNetCore.Routing.RouteEndpoint
.What's recommended way of accessing action filters in 3.0 inside AuthorizationHandler?
The text was updated successfully, but these errors were encountered: