-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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 (403) CSRF verification failed. Request aborted」in Django administration page #6516
Comments
I encountered the same error, but only on file uploads. PR that would (likely) fix this: #6322 |
Thank you very much for your solution! |
As far as i know those settings are only applied when you use the development mode, not the production mode? Assuming a normal "vanilla" helm install:
So if you would like to use the development.py options, you have to add a ENV variable to your helm chart called DJANGO_CONFIGURATION with the value of "development". |
I have CVAT behind a cloudflared tunnel and am getting the 403 forbidden CSRF on django admin page POST. The provided fix says to use the export CSRF_TRUSTED_ORIGINS="htttp://myserversIP,http://some other ip" in the docker-compose.yml where do I add the ENV var?
I put it in cvat-server, cvat-ui, cvat-utils and I am still getting CSRF 403 forbidden |
@baudneo have you found a fix for this yet? I'm running into same thing |
@geometrikal not yet. I took it down and hosted it locally so I could actually import datasets and annotations. One fix I was thinking of is adding the CVAT_HOST env var to every container that is running cvat-server image. The CVAT_HOST fix works in the cvat-server container but, several of the worker containers are based on cvat-server image. My guess is the worker containers need that env var so they know what to trust, that's just my.guess though. |
Hello, @baudneo: do you have an idea why going local solved the problem for you? Just in case it matters: our CVAT is installed exactly according to the official "Quick installation guide", running on 8080 with CVAT_HOST set to the LAN IP, behind a reverse proxy that terminates HTTPS. I tried different stable release including the latest and then the latest dev, but see no difference. Any input would be great, since currently i seem to be stuck. |
Behind a proxy = no good. Accessing direct local is what worked for me. Good luck getting help from cvat team. |
@baudneo: ahh, i see, thank you for letting me know! |
@kelbstf I did a quick deep dive and couldn't get it figured out. My situation was using cloudflared proxy for public access and I could not get it to work. My guess is that when the tus or whatever lib it is gets init'd, it needs an option to disable CORS or configure it for CVAT_HOST. At the time I was super busy so couldn't take the time to fix the issue and now I've moved on to other software. IIRC, it was issue after issue after issue and I had gotten fed up. Cvat team doest reply to non trivial issues and when they do, they usually say "it works on our cloud hosted service, you should stop self hosting and subscribe to our cloud service" instead of doing any meaningful troubleshooting and fixing. |
@baudneo thank you for sharing your experiences. Since this is just about getting able to login and creating users, and uploading files seems to be the next challenge, i wonder how this will behave when it comes to the real meat of this application later on. I still hope someone would share a brief guide, because this application is actually the primary choice for our users. I keep digging and will call back if i find a solution. |
I got it to work by pinning the cvat-server image to v2.4.5 in the helm-chart file. (tag attribute of cvat/server). However I can imagine that for this to work you have to checkout your project to an older commit (around where v2.4.5 got released). |
@kelbstf This is the solution I came up with. Although it may not be perfect, it's functional.
services:
cvat_server:
volumes:
# Resolve CRSF token error by mounting production.py
- ./production.py:/home/django/cvat/settings/production.py:ro
environment:
# Make CVAT_HOST accessible INSIDE the Docker container
CVAT_HOST: ${CVAT_HOST:-localhost}
CSRF_TRUSTED_ORIGINS = [origin.rstrip('/') for origin in os.getenv('CSRF_TRUSTED_ORIGINS', f'http://{CVAT_HOST},https://{CVAT_HOST}').split(',')]
|
This was the only thing that worked after hours of searching - thank you so much! |
I have not tried it yet, but take a look at: #6322 (comment) |
Thank you so much for this solution! |
My actions before raising this issue
I used K8S to deploy all the services that cvat depends on in the cluster. The deployment is as follows:
Then, I went to the backend-server pod and created a superuser account with the command
python3 ~/manage.py createsuperuser
Next, I went back to the Web page, logged in the superuser account with the browser, and entered the background management page, as shown below:
Steps to Reproduce (for bugs)
In the Django administration page, all my Post requests are getting errors like this:
Possible Solution
After Google, I found a workable solution:
doccano/doccano#1820
Your Environment
As mentioned above, I used the official ymal file to deploy the various services in the K8S cluster. We haven't used Django before, so we don't know how to add annotations to our code.
I was looking for a way to fix this by adding an environment variable to the backend-server deploy file.
Thanks for thinking about this!!
The text was updated successfully, but these errors were encountered: