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

Gitea attempts to replace Accept header for LFS requests #6960

Closed
slonopotamus opened this issue May 15, 2019 · 1 comment · Fixed by #7015
Closed

Gitea attempts to replace Accept header for LFS requests #6960

slonopotamus opened this issue May 15, 2019 · 1 comment · Fixed by #7015
Labels
Milestone

Comments

@slonopotamus
Copy link
Contributor

slonopotamus commented May 15, 2019

  • Gitea version (or commit ref): master
  • Git version: doesn't matter
  • Operating system: doesn't matter
  • Database (use [x]): doesn't matter
  • Can you reproduce the bug at https://try.gitea.io: [x] Not relevant

Description

When Gitea gives LFS client links for objects verification/download, it tells client to use "Accept: application/vnd.git-lfs" HTTP header. However, LFS specification clearly states that client sends Accept: application/vnd.git-lfs+json. So, you're effectively forcing client into violation of LFS spec. While this happens to work with git-lfs that silently uses your Accept header instead of one from spec, things go much worse with different LFS client. git-lfs-java instead appends your Accept header so ends up with two Accept headers. But Gitea /verify handler only checks the first one, so rejects git-lfs-java requests.

I added a workaround to git-lfs-java so it can work with Gitea, though still believe you should fix stuff on Gitea side.

Here's an unfinished attempt to fix Gitea code by complete elimination of nonstandard "Accept: application/vnd.git-lfs" (such thing exists only in Gitea, it is NOT part of Git-LFS specification!), though it doesn't fully pass tests. Given that my Go skills are almost none, I hope you will fix this.

@slonopotamus
Copy link
Contributor Author

I've reported same issue to lfs-test-server: git-lfs/lfs-test-server#85

zeripath added a commit to zeripath/gitea that referenced this issue May 20, 2019
slonopotamus added a commit to slonopotamus/gitea that referenced this issue May 22, 2019
Fixes go-gitea#6960

According to [spec][1], /verify requests must have `Accept: application/vnd.git-lfs+json`

Previous code works because `git-lfs` also [violates spec and doesn't send any Accept header at all][2]
For other clients that DO set `Accept: application/vnd.git-lfs+json`, addition of `Accept: application/vnd.git-lfs`
either forces them to violate the spec or is ignored, depending on order in what they create header list.

[1]: https://github.com/git-lfs/git-lfs/blob/master/docs/api/basic-transfers.md#verification
[2]: git-lfs/git-lfs#3662
zeripath pushed a commit that referenced this issue May 24, 2019
Fixes #6960

According to [spec][1], /verify requests must have `Accept: application/vnd.git-lfs+json`

Previous code works because `git-lfs` also [violates spec and doesn't send any Accept header at all][2]
For other clients that DO set `Accept: application/vnd.git-lfs+json`, addition of `Accept: application/vnd.git-lfs`
either forces them to violate the spec or is ignored, depending on order in what they create header list.

[1]: https://github.com/git-lfs/git-lfs/blob/master/docs/api/basic-transfers.md#verification
[2]: git-lfs/git-lfs#3662
@lafriks lafriks added this to the 1.9.0 milestone May 24, 2019
jeffliu27 pushed a commit to jeffliu27/gitea that referenced this issue Jul 18, 2019
Fixes go-gitea#6960

According to [spec][1], /verify requests must have `Accept: application/vnd.git-lfs+json`

Previous code works because `git-lfs` also [violates spec and doesn't send any Accept header at all][2]
For other clients that DO set `Accept: application/vnd.git-lfs+json`, addition of `Accept: application/vnd.git-lfs`
either forces them to violate the spec or is ignored, depending on order in what they create header list.

[1]: https://github.com/git-lfs/git-lfs/blob/master/docs/api/basic-transfers.md#verification
[2]: git-lfs/git-lfs#3662
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
2 participants