-
-
Notifications
You must be signed in to change notification settings - Fork 466
Description
We're having an issue using Lighthouse with Sanctum's SPA Authentication. It seems that if we pass a referer that is in the list of SANCTUM_STATEFUL_DOMAINS we get returned a CSRF Token Mismatch even if we are attempting to access a query that doesn't require authentication.
If we are actually authenticated and pass the referer and the correct auth info we do get back our requests successfully.
If we aren't authenticated and the referer is passed, the EnsureFrontendRequestsAreStateful seems to trigger a CSRF issue...even though no authentication has been provided or is required.
If we try to authenticate and then call a normal API route that is protected by the "auth:sanctum" middleware, debugging the request shows Sanctum arrives at an unauthenticated conclusion and then the response back is correct...in the case of Lighthouse, it seems like we're being thrown out at the EnsureFrontendRequestsAreStateful middleware state even though we aren't actually attempting to get data that requires authentication, or passing any data that would indicate we are authenticated.
Switching to token based authentication works fine...and in our current development state we're fine to do that in the short term, not sure if anyone else seems to be experiencing this?
I believe what should happen is that if we are accessing data that doesn't require authentication, the data should be returned, but it doesn't seem to make it that far.
Steps to reproduce
- Trying to access a query that requires no authentication throws the CSRF token mismatch if not authenticated...if we then
- Authenticate using a React app on one of Sanctum's allowed domains, we get an authenticated session...then
- We can access the query in Added type method to connection generator stub #1 now that Sanctum seems to authenticate us properly