chore: gh-host as oauth auth server#2046
Conversation
When gh-host is not set (github.com users), the AuthorizationServer field was being set to just "login/oauth" (empty host + path), breaking OAuth metadata. Now it only overrides the default when gh-host is provided (GHES users), allowing github.com users to get the correct default of "https://github.com/login/oauth". Co-authored-by: atharva1051 <53966412+atharva1051@users.noreply.github.com>
…rver-condition Fix: Only set custom OAuth AuthorizationServer when gh-host is configured
There was a problem hiding this comment.
Pull request overview
Adjusts HTTP-mode OAuth protected resource metadata so the authorization server URL is only overridden when --gh-host is explicitly provided, allowing github.com users to fall back to the built-in default authorization server.
Changes:
- Conditionally set
oauthCfg.AuthorizationServeronly whencfg.Host != ""(otherwise rely onoauth.NewAuthHandler’s default). - Avoid generating an invalid authorization server value when
cfg.Hostis empty.
|
Hello @SamMorrowDrums or @omgitsads , Could you please review this once? Thank you |
|
Hi @atharva1051, thanks for raising this issue. I think theres some additional complexity around handling GHES for both Like I said in the review, I think a better place to make this decision is in during the url resolution in the |
|
Oh that would be really helpful, although i did end up making few changes the moment I saw your comment. |
|
@omgitsads made the changes you made in #2070 |
Summary
Conditionally set AuthorizationServer only when
--gh-hostis explicitly provided, ensuringgithub.comusers receive the correct default.Why
To ensure that OAuth protected resource metadata correctly exposes the authorization server endpoint for all clients, including those using
github.comwherecfg.Hostmight be empty. This conditional setting prevents an invalidAuthorizationServervalue and ensures proper discovery of authentication details.What changed
pkg/http/server.go:AuthorizationServeris now only overridden whencfg.Host != "". Otherwise, it falls back toDefaultAuthorizationServer(https://github.com/login/oauth).MCP impact
Prompts tested (tool changes only)
N/A
Security / limits
Tool renaming
Lint & tests
./script/lint./script/testDocs
The program was tested solely for our own use cases, which might differ from yours.
Atharva Patil <atharva.a.patil@mercedes-benz.com> on behalf of Mercedes-Benz Research And Development India, Provider Information