Repository navigation
Add OIDC proxy handlers at /webapi/oidc/* - #4
Open
neilLasrado wants to merge 1 commit into
Open
neilLasrado wants to merge 1 commit into
neilLasrado wants to merge 1 commit into
Conversation
OSS registers proxy routes for GitHub SSO only, so even with an OIDC connector configured and an OIDCService registered there is nothing to serve the login or callback. The web UI already renders a button for OIDC connectors and tsh already posts to these paths, so both were pointing at endpoints that returned 404. Adds oidcLoginWeb, oidcLoginConsole and oidcCallback, mirroring the GitHub handlers including the device-web-token redirect, the console certificate hand-off, and the RedirectURLWithError fallback resolved via GetOIDCAuthRequest. Route registration uses the same middleware wrappers as the GitHub block. The ErrGithubNoTeams branch is not carried across: it is GitHub-team specific and has no OIDC equivalent in the tree. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Slice 2 of 6 toward self-hosted Google login. Standalone: the handlers call
authclientmethods that already exist, so this builds and tests on its own.Why
OSS registers proxy routes for GitHub SSO only:
There is no
/webapi/oidc/*anywhere inlib/. Those handlers live in the Enterprise tree.This matters because both clients already point at those paths.
getWebConfiglists OIDC connectors ungated and the React button component already renders them (picking a Google icon when the connector name contains "google"), andlib/client/sso.go:107posts to/webapi/oidc/login/console. Without these handlers, a configured OIDC connector produces a login button that 404s.Paths are fixed by
api/client/webclient/webconfig.go:30andlib/client/sso.go:107— both verified against the source rather than assumed.Change
lib/web/oidc.go(new) —oidcLoginWeb,oidcLoginConsole,oidcCallbacklib/web/apiserver.go— three route registrations, using the same middleware wrappers as the GitHub block (WithRedirect,WithMetaRedirect,WithLimiter)lib/web/oidc_test.go(new) — tests against a fakeauthclient.ClientIThe callback mirrors
githubCallbackrather than a simplified version:SSOSetWebSessionAndRedirectURL, the device-web-token redirect viaBuildDeviceWebRedirectPath, the console certificate hand-off viaConstructSSHResponse/AuthParams, and theRedirectURLWithErrorfallback resolved throughGetOIDCAuthRequestfor a known non-web state token, falling back toLoginFailedBadCallbackRedirectURL.One branch deliberately not carried across:
errors.Is(err, auth.ErrGithubNoTeams). That sentinel is GitHub-team specific (lib/auth/github.go:53) with no OIDC analogue in the tree. If Slice 3 wants an equivalent "authenticated but unauthorised" signal — a wrong hosted domain, say — it will need its own sentinel error and a matching branch here.Verification
Scoped to
./lib/web/(GOFLAGS=-p=2 GOMAXPROCS=2, never./...):go build ./lib/web/— cleango test ./lib/web/ -run 'TestOIDC' -v— passgo test ./lib/web/ -run 'TestGithub|TestSSO|TestWebConfig|TestNewHandler|TestParseSSORequestParams' -v— passThat second run is the meaningful one.
TestGithubAuthCompatboots a full server vianewWebPack, which panics on anhttprouterpath conflict. It didn't, so the new routes don't collide.Note for Slice 3/4
authclient.OIDCAuthResponse.Reqisauthclient.OIDCAuthRequest— a hand-written JSON-friendly struct inclt.go:875, not the prototypes.OIDCAuthRequestused byCreateOIDCAuthRequest. It carries onlyConnectorID,CSRFToken, the public keys,CreateWebSessionandClientRedirectURL. This exactly parallelsGithubAuthResponse.Req, so nothing needed changing — but it is not obvious from the type names and is worth knowing before anyone touches that response shape.🤖 Generated with Claude Code