Skip to content

Support multiple default guards#2345

Merged
spawnia merged 22 commits intomasterfrom
multiple-default-guards
Mar 14, 2023
Merged

Support multiple default guards#2345
spawnia merged 22 commits intomasterfrom
multiple-default-guards

Conversation

@pyrou
Copy link
Copy Markdown
Collaborator

@pyrou pyrou commented Mar 10, 2023

  • Added or updated tests
  • Documented user facing changes
  • Updated CHANGELOG.md
  • Change @auth(guard:) and @whereAuth(guard:) into @auth(guards:) and @whereAuth(guards:)

Changes

When using a query or mutation without @guard directive, to allow guest users, only one single default guard was attempted for $context->user. Specifying multiple guards with @guard(with:) allow to attempt multiples guard, but this would disallow guest users.

This PR propose to change the lighthouse.guard configuration to support multiple guards.

Breaking changes

  • lighthouse.guard configuration key has been renamed lighthouse.guards and expect now an array.
  • @auth(guard: String) has been changed to @auth(guards: [String!])
  • @whereAuth(guard: String) has been changed to @whereAuth(guards: [String!])

@pyrou pyrou added enhancement A feature or improvement 6.x Related to the 6.x release series labels Mar 10, 2023
@pyrou pyrou requested a review from spawnia March 10, 2023 10:37
Co-authored-by: Benedikt Franke <benedikt@franke.tech>
@pyrou pyrou force-pushed the multiple-default-guards branch from 1a86d27 to 825d4b0 Compare March 10, 2023 13:11
@pyrou pyrou force-pushed the multiple-default-guards branch from e7b4879 to 42651c1 Compare March 10, 2023 20:38
@pyrou pyrou requested a review from spawnia March 13, 2023 14:28
@spawnia spawnia merged commit 28b8e2c into master Mar 14, 2023
@spawnia spawnia deleted the multiple-default-guards branch March 14, 2023 10:39
@spawnia
Copy link
Copy Markdown
Collaborator

spawnia commented Mar 14, 2023

Nicely done @pyrou, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.x Related to the 6.x release series enhancement A feature or improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants