Skip to content

Confusing logic of [Authorize(Policy = xxx)] #49118

Closed Answered by david-acker
LeaFrock asked this question in Q&A
Discussion options

You must be logged in to vote

To my knowledge, these [Authorize] attributes are indeed designed to work additively when used this way. Although after a quick search, I wasn't able to find this explicitly mentioned in the docs. I'll enter a ticket in dotnet/AspNetCore.Docs to get some documentation added for this.

The [AllowAnonymous] attribute should then bypass any [Authorize] attributes:

Simple authorization in ASP.NET Core

[AllowAnonymous] bypasses authorization statements. If you combine [AllowAnonymous] and an [Authorize] attribute, the [Authorize] attributes are ignored. For example if you apply [AllowAnonymous] at the controller level:

  • Any authorization requirements from [Authorize] attributes on the same con…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@LeaFrock
Comment options

@david-acker
Comment options

Answer selected by LeaFrock
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
area-auth Includes: Authn, Authz, OAuth, OIDC, Bearer
3 participants