[Haskell-cafe] Yesod CSRF token
heraldhoi at gmail.com
Wed Feb 17 18:14:17 UTC 2016
Can you share your code?
If you make your POST requests via forms make sure that you generation
forms with Yesod functions, in this case it will insert hidden field with
CSRF token to resulting form widget automatically. If you sending requests
via XHR make sure to use `defaultCsrfMiddleware` from Yesod.Core.
Hope this helps.
ср, 17 февр. 2016 г. в 15:38, fr33domlover <fr33domlover at riseup.net>:
> I started a new Yesod web app few days ago. I'm using stack, LTS-5.1, and
> yesod-postgres scaffolding.
> When I try to log in into my new minimal app, I get an error: A valid CSRF
> token wasn't present in HTTP headers or POST parameters. That's because the
> POST request doesn't include that token for some reason. But I don't know
> I found a recent PR which removes the CSRF token checking from the
> but I do want CSRF protection to work. As a Yesod beginner, I'm not sure
> exactly why the token doesn't get inserted where it should (the Yesod book
> yesod-form does insert it, so I assume this is a bug here) and how I can
> that. Even if I inserted the token manually into the login form, what
> about all
> the other POST requests my app may use, such as logout?
> I also found a commit that adds the token to the redirectToPost function in
> yesod-core, but
> (1) It's in the most recent release, not in LTS
> (2) I'm not sure it has anything to do with it because it seems to be some
> of JS based form
> Anyone knows whether this is a known issue and how to fix it?
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe