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?
I’m rather surprised at the default behaviour of AuthorizeAttribute ; if you don’t supply
Share
Here’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
AllowAnonymousAttributeto my login actions/controllers andAuthorizeSafeAttributeto 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. 🙂