Repository navigation
core: preserve Gitea deployment prefixes for OAuth - #2479
Conversation
Fixes git-ecosystem#1650 Assisted-by: GPT-6
Signed-off-by: huang <[email protected]>
|
@becm Thanks for the helpful review and suggestions! I have addressed all three suggestions in commit 5b738b6:
|
Adds the generic empty-path case the reviewer asked for: an empty path yields no prefix segments, so the endpoints stay at the host root.
This comment was marked as low quality.
This comment was marked as low quality.
mjcheetham
left a comment
There was a problem hiding this comment.
This seems like a real bug to fix; thanks for your contribution here! Just want to understand the logic behind the path splitting/calculation before we go forward. Thanks!
|
Your reading is exactly right: we split On whether the last two segments are always On the partial-URL concern:
So a partial URL can only fail to recover a prefix (falling back to the host root, which is exactly today's behaviour) — it can never produce a wrong prefix. That is also why the empty-path row is already in the test theory. One thing worth being explicit about: Happy to add rows for the partial shapes ( |
|
I'd consider this adjustment a (small) band-aid to improve guessing the correct URL. Getting the correct setting from This would whoever require to run a consistent discovery step on each token renewal. |
I think a short comment in the code that we assume the format of the Gitea remote URLs is always |
Adding OpenID connect support with discovery (and just the almost-never-implemented OAuth2 metadata/discovery RFC) is something I've considered in the past. IIRC there's even a
Agreed. If it guesses wrong, you can always specify the config explicitly. |
|
Added the comment on // A Gitea remote URL is always '{host}/{prefix}/{owner}/{repo}' — Gitea has no nested
// groups — so dropping the last two segments leaves the '{host}/{prefix}' that the OAuth
// endpoints hang off. When Git omits the path (credential.useHttpPath is false), or passes
// fewer than two segments, the prefix is empty and the endpoints stay at the host root.That should cover both the shape assumption and the fallback behaviour a future reader would otherwise have to reverse-engineer. On the discovery idea from @becm: agreed it's the better long-term answer, but as you said it changes the token-renewal path for every generic OAuth provider, so I've kept it out of this PR. |
Next week is Git 2.98-rc0, so let's cut our release ahead of that for some extra testing, and to give the Git for Windows project time to incorporate the new GCM bits into their release. **Changes:** - Support instance path prefixes for Gitea in generic OAuth #2479 - Detect GitHub Enterprise Data Residency instances ('Proxima') #2498 - Correctly parse returned GitHub OAuth scopes (#2505) - Fix several OAuth client spec deviations (#2499) - Fix `diagnose` command unit tests (#2501) - Install from source fixes (#2502, #2506) - Fix to release tarballs on Mac and Linux (#2491) - CI task updates (#2496)
Summary
Validation
dotnet build git-credential-manager.slnxdotnet test git-credential-manager.slnxFixes #1650