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

Fix multiple http authorization #5593

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tomix1024
Copy link

TLDR Problem:
If the Authorization HTTP header is already configured via the (local) Git config for the domain where the LFS files are pulled from, Git LFS will send two Authorization HTTP headers, which constitutes and invalid HTTP request and is answered with a 400 Bad Request response by most HTTP servers.

TLDR Solution:
Make sure that there is always at most one Authorization header, when in doubt, Git LFS should override the local Git config.

I have a problem checking out Git LFS files in Gitea Actions using the actions/checkout@v4 action on my own server.
The Action configures the Authorization HTTP header for the base URL from where the repository is cloned.
The LFS files are served from the very same base URL.
When I run git lfs pull, git-lfs sets the Authorization header on its own, but then copies the extra HTTP headers from the Git config.

The Gitea server itself accepts these malformed HTTP requests.
However I am running the Gitea server behind an NGINX reverse proxy, which rejects these requests and does not forward them.

On Github the same error can be forced by cloning a private repository, and having the Authorization header configured for https://lfs.github.com, but why would anyone do this?

@tomix1024 tomix1024 requested a review from a team as a code owner December 19, 2023 17:57
@bk2204
Copy link
Member

bk2204 commented Dec 19, 2023

Hey,

The behaviour we have here is the same behaviour that Git has, in that it will always add the additional header. This is why it's not suitable to use http.extraheader for authorization and it shouldn't be done. I don't believe we'll want to change the behaviour to diverge from Git here.

I'll expand on this to mention that we don't, in general, know which value is correct. It could be either one, which is why we can't simply choose one or the other.

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

Successfully merging this pull request may close these issues.

None yet

2 participants