-
Notifications
You must be signed in to change notification settings - Fork 784
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
Support get CSRF_TOKEN via cookie #515
Comments
I agree and to clarify, Axios and other Http clients like Angulars HttpClientModule automatically check for the XSRF-TOKEN cookie and set the X-XSRF-TOKEN header on outgoing requests. When Passport authenticates a request it checks that the CSRF token was sent with the request and that it matches the one in the decoded token but it fails to check for the XSRF Token, decode it and check its validity. To solve the problem I have extended Passports TokenGuard with the following minor changes:
|
@GJordan904 Any chance of making this a pull request? I've run in to this issue too. |
Hmm yeah we should be able to match the behavior of the |
I have written a middleware as my temporary solution.
Add this middleware to api middleware group
Make its priority higher than authenticate
Done! |
This has actually already been added in #1069 it seems. |
I think we change how to get csrf token to support Axios send csrf via cookie (
X-XSRF-TOKEN
)https://github.com/laravel/passport/blob/91671e53ffd88cb1b7b5b53047f7eee2ac0d172f/src/Guards/TokenGuard.php#L194-L210
The text was updated successfully, but these errors were encountered: