Skip to content
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

GraphQL Authentication choosing wrong schema when applying field rules #119

Closed
danieltott opened this issue Jan 24, 2023 · 2 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@danieltott
Copy link

danieltott commented Jan 24, 2023

Problem:

When querying the graphQL endpoint not as a logged-in user via GraphQL Authentication, but just using a Craft GraphQL schema token (via Authorization: Bearer ....), GraphQL Authentication is still applying the field rules but applying rules from the wrong Schema (seems to be always using Public).

I would expect GraphQL Authentication to either ignore requests that aren't coming through the JWT auth, or choose the correct Schema.

Craft Version
Craft Pro 4.3.6.1 (latest at this time)
GraphQL Authentication version
2.3.0 (latest at this time)

image

To reproduce:

I've created a reproduction repo with instructions on how to recreate this bug - it's pretty straight forward.

To recreate on your own setup:

  • Create a GraphQL Schema that has access to entries with the field in question
  • In GraphQL Authentication -> Settings -> Fields, set the field to Private with the Public Schema, but Query/Mutate in the new Schema
  • Test that the query works in GraphiQL
  • Make a request to the GraphQL endpoint querying that field with a Authorization: Bearer {token} (not the GraphQL Authentication JWT header)

You'll get an error response like this:

{
  "errors": [
    {
      "message": "User doesn't have permission to access requested field(s)"
    }
  ]
}
@jamesedmonston jamesedmonston self-assigned this Jan 26, 2023
@jamesedmonston jamesedmonston added the bug Something isn't working label Jan 26, 2023
@jamesedmonston
Copy link
Owner

jamesedmonston commented Jan 26, 2023

@danieltott sounds like this is related to the changes made here.

Thanks for your detailed issue and repro! I'll get it sorted.

Thanks!

@jamesedmonston
Copy link
Owner

@danieltott fixed in 2.3.1!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants