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

CSRF Token Mismatch #32

Open
another-novelty opened this issue Dec 3, 2020 · 6 comments
Open

CSRF Token Mismatch #32

another-novelty opened this issue Dec 3, 2020 · 6 comments
Assignees

Comments

@another-novelty
Copy link

Hi!

When the callback returns from the apple servers I get a 419 error from Laravel. Disabling the VerifyCsrfToken middleware fixes this but is obviously not a fix.

Laravel framework version: v8.13.0
laravel-sign-in-with-apple version: 0.5.0
socialite version: 5.1.0

My naive guess is that this is actually a laravel, apple or configuration issue as the request somehow returns with a POST instead of a GET with the state token in the request instead of the header.

@yaroslavolekh
Copy link

The same issue

@mikebronner
Copy link
Owner

It sounds like you need to exclude your webhooks from being checked for CSRF tokens, but I have never had this issue. Please provide a working example repo that demonstrates this issue, if you would like me to look into this. At this point I have nothing to go on.

@mikebronner mikebronner self-assigned this Dec 19, 2020
@mirko77
Copy link

mirko77 commented Mar 12, 2021

Well, Apple sends back a POST request without the CSRF Token Laravel is expecting.

I personally added the CSRF as a nonce parameter which is sent back by Apple and check it manually.

In VerifyCsrfToken.php the Apple redirect URI needs to be excluded.

protected $except = [
        'handle/apple/callback',
    ];

What I have not figured out yet is how to define handle/apple/callback in the .env instead of hardcoding it

@gustafsilva
Copy link

The same issue

@mikebronner
Copy link
Owner

@mirko77 @gustafsilva Could either of you provide an example test repo that demonstrates this issue?

@esa-kian
Copy link

Well, Apple sends back a POST request without the CSRF Token Laravel is expecting.

I personally added the CSRF as a nonce parameter which is sent back by Apple and check it manually.

In VerifyCsrfToken.php the Apple redirect URI needs to be excluded.

protected $except = [
        'handle/apple/callback',
    ];

What I have not figured out yet is how to define handle/apple/callback in the .env instead of hardcoding it

I tried this and it works for me, thanks @mirko77

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants