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

Forbidden (CSRF token from the 'X-Csrftoken' HTTP header has incorrect length.): /two_factor/verification/ #2

Open
pulse-mind opened this issue Jul 14, 2022 · 2 comments

Comments

@pulse-mind
Copy link

pulse-mind commented Jul 14, 2022

Hi

Thank you for your job.

It was working perfectly on my dev environment but not on production.
I think the difference is that I am using everything very secure:

SESSION_COOKIE_SECURE="True"
SESSION_COOKIE_HTTPONLY="True"
CSRF_COOKIE_HTTPONLY="True"
SECURE_BROWSER_XSS_FILTER="True"
DJANGO_SECURE_SSL_REDIRECT="True"
X_FRAME_OPTIONS="DENY"

In the log I get
Forbidden (CSRF token from the 'X-Csrftoken' HTTP header has incorrect length.): /two_factor/verification/

When I inspect the request in the browser on the PUT request, in the request header I have :
x-csrftoken: undefined

I am not sure but may be this is a way : https://docs.djangoproject.com/fr/4.0/ref/csrf/#setting-the-token-on-the-ajax-request

Also you may add in the documentation to allow PUT request on the webserver for this URL /two_factor/verification/ .

@imankarimi
Copy link
Owner

imankarimi commented Aug 10, 2022

@pulse-mind Thanks for your issue. sure I will check this out, and I let you know when it's finished. ;)

@pulse-mind
Copy link
Author

Hi @imankarimi did you find enough time to look at my request ?

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

2 participants