-
-
Notifications
You must be signed in to change notification settings - Fork 149
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
[Bug] CSRF token verification failed #1505
Comments
Hot damn I think you're one of the first people outside the team to try and use the API! It's possible we broke something with OIDC work, or it's been broken for a while (we don't make any POST requests to the API in any of our plugins). Will have a look soon. |
I think we should move to the |
Hello, a few days ago I encountered a similar issue, but with the “saves” endpoint (using cURL in C++). The GET endpoints such as “Heartbeat,” “Stats,” “Roms,” and “Platforms” worked without any problems. The POST requests for “Login” and “Token” also worked. However, when making a POST request to upload a save to my RomM instance, I also received a CSRF error. Several attempts to work around the error failed. I even manually extracted the “romm_csrftoken” and “romm_session” (id) cookies from the “Login” response and included them in the POST request for “saves,” but this did not resolve the error. |
This'll be fixed in the next release! |
I confirm it works fine now :) Tanks ! curl -X POST http://192.168.1.12/api/collections -H 'Authorization: Basic YWRtaW46YWRtaW4=' -H 'Content-Type: multipart/form-data' -F 'name=Yeah it rocks'
{"id":3,"name":"Yeah it rocks","description":"","path_cover_l":"","path_cover_s":"","has_cover":false,"url_cover":"","roms":[],"rom_count":0,"user_id":1,"user__username":"admin","is_public":false,"created_at":"2025-01-31T19:02:35+00:00","updated_at":"2025-01-31T19:02:35+00:00"} And using a token too: curl -X 'POST' \
'http://rpi5.local/api/token' \
-H 'accept: application/json' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'grant_type=password&scope=collections.write&username=admin&password=admin'
{"access_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZG1pbiIsImlzcyI6InJvbW06b2F1dGgiLCJzY29wZXMiOiJjb2xsZWN0aW9ucy53cml0ZSIsInR5cGUiOiJhY2Nlc3MiLCJleHAiOjE3MzgzNTI0MjF9.h_B61QB0seik7CMELoDHLAPIjRiWDCePvHrP6CKZ9gM","refresh_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZG1pbiIsImlzcyI6InJvbW06b2F1dGgiLCJzY29wZXMiOiJjb2xsZWN0aW9ucy53cml0ZSIsInR5cGUiOiJyZWZyZXNoIiwiZXhwIjoxNzM4OTU1NDIxfQ.GZqL2EFf7MfhiKur7UOO5Me_VOpUs2KdxTM0Pi1EHaI","token_type":"bearer","expires":1800}%
curl -X POST http://rpi5.local/api/collections -H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZG1pbiIsImlzcyI6InJvbW06b2F1dGgiLCJzY29wZXMiOiJjb2xsZWN0aW9ucy53cml0ZSIsInR5cGUiOiJhY2Nlc3MiLCJleHAiOjE3MzgzNTI0MjF9.h_B61QB0seik7CMELoDHLAPIjRiWDCePvHrP6CKZ9gM' -H 'Content-Type: multipart/form-data' -F 'name=Using Token'
{"id":4,"name":"Using Token","description":"","path_cover_l":"","path_cover_s":"","has_cover":false,"url_cover":"","roms":[],"rom_count":0,"user_id":1,"user__username":"admin","is_public":false,"created_at":"2025-01-31T19:11:08+00:00","updated_at":"2025-01-31T19:11:08+00:00"} |
RomM version
3.7.2
Describe the bug
curl http://192.168.1.12/api/collections -H 'Authorization: Basic YWRtaW46YWRtaW4='
returns
BUT with POST/PUT commands, I get
CSRF token verification failed
To Reproduce
You get
CSRF token verification failed
:(Expected behavior
HTTP 200 with eventually a json response body
Additional information
Also, when I try to authenticate with
OAuth2PasswordBearer (OAuth2, password)
inhttp://rpi5.local/api/docs
, I getauth errorError: Not Allowed
(Note thatHTTPBasic (http, Basic)
works fine)I already had reported Bug#1218, which got closed, so I thought it has been solved.
Maybe I am just not using authentication properly ?
The text was updated successfully, but these errors were encountered: