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

Unable to use Manually Configured OAuth with Git Credentials Manager #26526

Closed
Sapein opened this issue Aug 15, 2023 · 4 comments · Fixed by #26597
Closed

Unable to use Manually Configured OAuth with Git Credentials Manager #26526

Sapein opened this issue Aug 15, 2023 · 4 comments · Fixed by #26597
Assignees
Labels
Milestone

Comments

@Sapein
Copy link

Sapein commented Aug 15, 2023

Description

Whenever using generic oauth authentication with Gitea, git-credentials-manager can not actually use gitea's oauth implementation. This occurs because the git-credentials-manager appends a trailing backslash onto the URI causing gitea to give an unauthorized_client: unexpected redirect URI error. This completely stops me from being able to use GCM with Gitea with how I have it setup atm.

Ideally, gitea should not care about trailing backslashes.

Gitea Version

1.20.2

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

Gitea provided windows release of 1.20.2 and on https://try.gitea.io

Database

None

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Aug 16, 2023

This feature is only in Gitea 1.21 nightly, not in 1.20 (misunderstood)

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Aug 16, 2023

Oops, I thought it's about the "builtin" Git Credentials Manager support, but it's not, reopen.

This occurs because the git-credentials-manager appends a trailing backslash onto the URI causing gitea to give an unauthorized_client: unexpected redirect URI error.

What's the URI?

@wxiaoguang wxiaoguang reopened this Aug 16, 2023
@Sapein
Copy link
Author

Sapein commented Aug 16, 2023

Oops, I thought it's about the "builtin" Git Credentials Manager support, but it's not, reopen.

This occurs because the git-credentials-manager appends a trailing backslash onto the URI causing gitea to give an unauthorized_client: unexpected redirect URI error.

What's the URI?

Thanks for reopening, my apologies as I probably could've been clearer.

As to the URI the redirect URI setup with Gitea is: http://127.0.0.1, the redirect URI that GCM is using in the request is http://127.0.0.1/.

A example of the request (copied directly from an actual attempt to use GCM) is as follows:
https://[GITEA URL]/login/oauth/authorize?response_type=code&client_id=[CLIENT ID]&state=ce09ece29d724dfdb547291cf865f017&code_challenge_method=S256&code_challenge=5hWMCvzIBIpjhS3MmFA4Jaq3letwAt7yTXqq6NVBrGg&redirect_uri=http%3a%2f%2f127.0.0.1%3a52405%2f&scope=repository%3awrite+read%3auser

This fails. However the following works:
https://[GITEA URL]/login/oauth/authorize?response_type=code&client_id=[CLIENT ID]&state=ce09ece29d724dfdb547291cf865f017&code_challenge_method=S256&code_challenge=5hWMCvzIBIpjhS3MmFA4Jaq3letwAt7yTXqq6NVBrGg&redirect_uri=http%3a%2f%2f127.0.0.1%3a52405&scope=repository%3awrite+read%3auser

@wxiaoguang
Copy link
Contributor

Ignore the trailing slashes when comparing oauth2 redirect_uri #26597

@lunny lunny added this to the 1.20.4 milestone Aug 21, 2023
wxiaoguang added a commit that referenced this issue Aug 21, 2023
… (#26618)

Backport #26597 by @wxiaoguang

Fix #26526

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 6, 2023
project-mirrors-bot-tu bot pushed a commit to project-mirrors/forgejo-as-gitea-fork that referenced this issue Jan 23, 2025
…tea#26597) (go-gitea#26618)

Backport go-gitea#26597 by @wxiaoguang

Fix go-gitea#26526

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
(cherry picked from commit 4aed0e6)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants