question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make AbpMvcAuthorizeFilter and AbpApiAuthorizeFilter overridable

See original GitHub issue

In the previous version,There is not AbpMvcAuthorizeFilter ,

There is only AbpMvcAuthorizeAttribute. And I override this and override OnAuthorization to redirect a different page when Unauthorized.

but in lastest version.I find that there is AbpMvcAuthorizeFilter and AbpMvcAuthorizeAttribute. in the AbpMvcAuthorizeFilter , _authorizationHelper.Authorize(methodInfo); has be called.

how to override AbpMvcAuthorizeFilter or AbpMvcAuthorizeAttribute to redirect a different page when Unauthorized?

Thanks!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:17 (16 by maintainers)

github_iconTop GitHub Comments

1reaction
acjhcommented, Aug 12, 2018

Set a lower order:

GlobalFilters.Filters.Add(IocManager.Resolve<MyMvcAuthorizeFilter>(), order: -2);
1reaction
Swimburgercommented, Jul 27, 2018

@jamesatgithub I ran into the same issue, though totally unrelated to this project. Try GlobalFilters.Filters.Remove(GlobalFilters.Filters.Single(f => f.Instance is AbpMvcAuthorizeFilter).Instance);.

When I passed in the Instance to the Remove function it worked, it makes sense because you pass the instance to the Add function, so we should pass it to the Remove function as well. It’s unfortunate MSFT doesn’t provide more details/documentation on the Remove method.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Overriding controller AuthorizeAttribute for just one action
My question is once I've added [Authorize] at the controller level can I override it (or remove it) with [CustomAuthorize] on just one...
Read more >
AuthorizeFilter Class (Microsoft.AspNetCore.Mvc. ...
An implementation of IAsyncAuthorizationFilter which applies a specific AuthorizationPolicy. MVC recognizes the AuthorizeAttribute and adds an instance of ...
Read more >
Setting global authorization policies using the ...
The first option is to apply an AuthorizeFilter globally to all your MVC actions and Razor Pages. This is the approach traditionally used...
Read more >
Simple authorization in ASP.NET Core
Learn how to use the Authorize attribute to restrict access to ASP.NET Core controllers and actions.
Read more >
Custom policy evaluator to enforce multiple authentication ...
Create my own AuthorizeFilter s and override which evaluator they use (which would then allow me to have multiple simpler IPolicyEvaluator ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found