AllowAnonymous attribute at action level is ignored in AppendAuthorizeToSummaryOperationFilter
See original GitHub issueHello,
There’s the following code, which protects the controller with specific scope, but allows one of the actions to be accessed without any authorization:
[Authorize("scope.read")]
public class ItemsController : Controller
{
[AllowAnonymous]
public async Task<IActionResult> Get()
{
// do stuff ...
}
}
Anyhow, using AppendAuthorizeToSummaryOperationFilter
filter, the following is added to GET /Items
description: (Auth policies: scope.read)
.
This does not seem to be a correct behavior, as the action can be accessed with no authorization, meaning the Auth policies
should not be displayed either.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
AllowAnonymous attribute make Authorize ignored
After I peek the authorize code, This part of code make the authorize not working : public virtual void OnAuthorization(AuthorizationContext ...
Read more >[Allow Anonymous skips all authorization] do not take effect ...
If you combine [AllowAnonymous] and any [Authorize] attribute, the [Authorize] attributes are ignored. For example if you apply [AllowAnonymous] ...
Read more >Simple authorization in ASP.NET Core
If you combine [AllowAnonymous] and an [Authorize] attribute, the [Authorize] attributes are ignored. For example if you apply [AllowAnonymous] ...
Read more >Authorization in ASP.NET Core
Please note: If you apply [AllowAnonymous] attribute at the controller level, any [Authorize] attribute attribute on the same controller actions is ignored.
Read more >Part 70 Authorize and AllowAnonymous action filters in mvc
NET MVC, by default, all the controller action methods are accessible ... AllowAnonymous attribute is used to skip authorization enforced by ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
OK. I’ve fixed it in both. https://www.nuget.org/packages/Swashbuckle.AspNetCore.Examples/2.8.1 https://www.nuget.org/packages/Swashbuckle.Examples/3.9.1
OK this sounds like a bug so I’ll investigate it when I get a chance.