gogs: JGit client fails with 401 error when attempt to push using https

  • GOGS Version: 0.11.4
  • Git Version: Eclipse EGIT, 4.7.0.201704051617-r, issue exists in all versions of egit that I have tried that include the full suite of Neon releases, as well as pre-release of Oxygene
  • Operating system: Windows 7 SP1,
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • [x ] SQLite
  • Can you reproduce the bug at https://try.gogs.io:
  • Log gist (usually found in log/gogs.log):

Description

I am using the Eclipse IDE. Eclipse integrates git operations into the IDE, allowing you to perform most GIT operations directly from the IDE. When I attempt to push my changes using eclipse (https) to a remote GOGS repo I consistently get a 401 unauthorized error.

If however I go into GOGS and change the repo so that its a private, and then attempt to push, egit will either request my credentials or it will use the cached credentials and complete the push successfully.

This issue does not occur with the GIT command line.

To reproduce issue:

  1. clone the repository: https://try.gogs.io/KevinTester/TestTest.git
  2. add the cloned repo to eclipse
  3. turn off sslVerify (this could be unique to my environment)
  • git config http.sslVerify false
  1. make some changes to the readme file and then commit and push. You should get a prompt asking for credentials, but instead it will error, with the message: Can’t connect to any repository: 401 Unauthorized)

interestingly enough if I toggle the repository to become a private repo, and then retry the push in eclipse everything works correctly, i.e. it gives me a prompt for the credentials, or uses the cached credentials and completes the push successfully.

The issue only seems to come up with GOGS, I don’t have this issue when working with other remote git repositories like bitbucket, or github.

Please let me know if I can do anything to help resolve this bug / issue

Thanks.

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Reactions: 1
  • Comments: 22 (6 by maintainers)

Most upvoted comments

JGit has been fixed now to handle servers that request authentication only on the POST. So with an EGit/JGit from the latest nightly builds, this problem should no longer occur.

It would still be good if GOGS required authentication for receive-pack already on the GET. Authentication on POST only slows down clients in general, not just JGit, since they’ll have to send data twice.

Based on https://discuss.gogs.io/t/eclipse-git-https-try-gogs-io-https-try-gogs-io-xiaoye-test-git-401-unauthorized/1138/9, change visibility to private can push normally. But still no idea about the core issue.

This issue seems to have disappeared for me personally with the most recent update. I can push using netbeans again just fine with making the repository private.

JGit connects to https://<gogs-server>/<user>/<repo>.git/info/refs?service=git-receive-pack. The server does not ask for authentication for this URL if the repo is public, returns HTTP 200 and a meaningful result. When JGit then tries to send data to the git-receive-pack endpoint, the server suddenly responds with the 401.

Don’t know if that is correct, or if the server should ask for authentication already for the service=git-receive-pack query.

JGit bug is https://bugs.eclipse.org/bugs/show_bug.cgi?id=513043 .

Recently upgraded to 0.11.10 and experience the same issue with Eclipse Git in Neon.3 over normal HTTP. If the repository is changed to Private, Eclipse Git will work. Other Git clients appear to work without adjustments. Everything was working correctly with Gogs / Eclipse Git prior to upgrading from 0.8.22.0115.

No such problem in gogs v0.8.10 - v0.9.141 Problem exists since gogs v0.10(RC)