Skip to content

Support [AllowAnonymous] along with [Authorize] #1189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Shane32
Copy link
Member

@Shane32 Shane32 commented Jun 12, 2025

This allows bypassing parent type's authorization while defining new requirements on the field. Previously any requirements on the field were ignored.

Sample:

# .AuthorizeWithRoles("Admin")
type Mutation {
  createUser(name: String!): String # requires Admin role

  # .AllowAnonymous()
  # .Authorize()
  updateOwnProfile(email: String!): Boolean # requires any authenticated user

  # .AllowAnonymous()
  submitFeedback(message: String!): Boolean # anonymous user
}

Recently I found that I had assumed that .AllowAnonymous() would stack with .Authorize(), but this was not the case. So, is this a security bug fix, or a new feature? Not sure, but I don't think it warrants a major version bump. All prior tests pass.

@Shane32 Shane32 self-assigned this Jun 12, 2025
Comment on lines +407 to +408
`.AllowAnonymous()` and/or `[AllowAnonymous]` to allow fields to bypass authorization
requirements defined on the type that contains the field.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a change, just a clarification.

@Shane32 Shane32 added this to the 8.3.0 milestone Jun 12, 2025
@Shane32 Shane32 requested a review from gao-artur June 12, 2025 03:16
@Shane32 Shane32 added the enhancement New feature or request label Jun 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants