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

Disabling CSRF check by default doesn't work for forms #336

Closed
james9909 opened this issue May 30, 2018 · 8 comments
Closed

Disabling CSRF check by default doesn't work for forms #336

james9909 opened this issue May 30, 2018 · 8 comments

Comments

@james9909
Copy link

I noticed that setting WTF_CSRF_CHECK_DEFAULT doesn't won't work if the endpoint validates any FlaskForm. The CSRF token doesn't seem to be checked, but when I check the my logs, they say that The CSRF token is missing. Would it be possible to completely disable the CSRF check for forms if WTF_CSRF_CHECK_DEFAULT is set to false?

@greyli
Copy link
Member

greyli commented May 30, 2018

As the docs said, set WTF_CSRF_ENABLED to False to disable all CSRF protection.

@james9909
Copy link
Author

Sorry, for not clarifying, but I want to conditionally enable CSRF for certain requests using the @app.before_request decorator. The docs only say to set WTF_CSRF_CHECK_DEFAULT to false.

@james9909
Copy link
Author

james9909 commented May 30, 2018

For example, adding an empty form to tests/test_csrf_extension.py and requiring it to validate causes test_protect to fail. I'm not sure if this is intended, but this behavior isn't mentioned from the docs and is kind of unintuitive.

@greyli
Copy link
Member

greyli commented May 30, 2018

Provide a minimal application may be helpful.

@james9909
Copy link
Author

@greyli
Copy link
Member

greyli commented Jun 17, 2018

I already posted a comment under your gist 17 days ago. If you have no further question, please close this issue.

@james9909
Copy link
Author

Sorry, I didn't get any notifications about your comment on the gist, but I added some more info.

@greyli
Copy link
Member

greyli commented Jun 17, 2018

Since the problem was solved, could you close this issue?

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants