Repository navigation
Conversation
'requests' strips only 'Authorization' header on redirect to a different host. 'ServerSession' also strips 'X-Api-Key' and 'X-as-user', so service api key is not sent e.g. to cloud storage the server redirects file downloads to. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Downside of this change is that some redirects |
For what it's worth, here's some note that Claude gave me that I think made sense to share 1-to-1:
|
Changelog Description
Service API key (
X-Api-Key) andX-as-userheaders are no longer sent to a different host when the server redirects a request, e.g. project file downloads redirected to S3 or a CDN.Additional info
requestsremoves only theAuthorizationheader when a redirect leads to a different host (Session.rebuild_auth). Users logged in with a session token were safe, but services using an API key sent it to every host the server redirected to.Changes:
ServerSessioninutils.pyis arequests.Sessionthat also removesX-Api-KeyandX-as-userinrebuild_auth, using the sameshould_strip_authcheck asrequestsdoes forAuthorization(other host, but not anhttp→httpsupgrade on the same host).ServerAPIcreates its sessions (authorized and validation) fromServerSession.automated_api.pygotSessionin its fakerequestsmodule.test_token_validation.pyreplacesServerSessioninstead ofrequests.Sessionwith its fake server.This is independent of #380, but becomes more relevant with it: users with
AYON_CA_FILEcouldn't follow redirects to public hosts until now, because TLS verification failed. The two PRs touch the same session creation lines inServerAPI, so whichever gets merged second needs a small conflict resolution.Testing notes:
pytest tests/test_redirect_auth_headers.py: a local server redirects to itself through another host name (localhost→127.0.0.1). The API key andX-as-useraren't sent to the other host for REST requests anddownload_file, and are still sent on a same-host redirect. Ondevelopthe two other-host tests fail.python automated_api.pymakes no changes.