One way is to exclude the webhook route from your VerifyCsrfToken middleware
Mar 31, 2018
5
Level 12
CSRF Protection in Stripe Connect with Laravel
Hey!
Currently I'm working on Stripe Connect. In one phrase they mentioned this:
To prevent CSRF attacks, add the state parameter, passing along a unique token as the value. We’ll include the state you gave us when we redirect the user back to your site.
You can find this here https://stripe.com/docs/connect/standard-accounts#integrating-oauth
So I'm curious, how can I use the CSRF Protection? From Laravel I get the current Token, but when Stripe is redirecting back to my site I have another CSRF. So how would you use it?
Thank you!
Level 67
I think you could actually use the csrf token manually, but you'd need to
- exclude that stripe callback route from csrf
- pass the csrf token to stripe
- in the callback url that stripe posts back to (which is excluded from CSRF in #1), get the token.
- manually compare if the token they passed back in the query string matches the value of csrf_token().
It's basically what I said in my previous post, except using laravels token instead of manually generating a unique token.
Please or to participate in this conversation.