I'm rather surprised at the default behaviour of AuthorizeAttribute
; if you don't supply it any Roles
property, it just appears to allow any authorized user to access the controller/action. I want whitelist behaviour instead; if Roles
is null or empty, deny all users access. How can I make this behaviour occur?
相关问题
- MVC-Routing,Why i can not ignore defaults,The matc
- parameters in routing do not work MVC 3
- There is no ViewData item with the key 'taskTy
- TextBoxFor decimal
- Install ASP.NET 5.0 version of System.ServiceModel
相关文章
- How to get a list of connected clients on SignalR
- How do you redirect to the calling page in ASP.NET
- Change color of bars depending on value in Highcha
- The program '[4432] iisexpress.exe' has ex
- ASP.Net MVC 4 Bundles
- How to get server path of physical path ?
- Securing REST endpoint using spring security
- Cannot implicitly convert Web.Http.Results.JsonRes
Now use
[AuthorizeEx]
on your controllers/actionsHere's what I came up with eventually, as a filter I add to the global filter collection for an MVC application:
I also define this attribute:
I apply
AllowAnonymousAttribute
to my login actions/controllers andAuthorizeSafeAttribute
to other ones, but if I forget to apply these, access is denied by default. I wish ASP.NET MVC were as secure as this by default. :-)