RFC for multiple upstream providers in authserver#52
Merged
tgrunnagle merged 3 commits intomainfrom Mar 13, 2026
Merged
Conversation
jhrozek
reviewed
Mar 10, 2026
Contributor
jhrozek
left a comment
There was a problem hiding this comment.
I think this looks good, I'd like to give the RFC one more read before merging, but I don't see anything blocking
Contributor
|
I'm fine merging as long as we plan the token storage passing down the session stack to accomodate for refresh token, lmk if you want to merge as-is or do any changes @tgrunnagle |
Contributor
Author
|
@jhrozek I think the only open question is how we make sure refreshed tokens are given to the |
7 tasks
jerm-dro
approved these changes
Mar 13, 2026
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.
Related issue: stacklok/stacklok-epics#251
What this RFC proposes
The embedded OAuth authorization server (
pkg/authserver/) currently hard-rejects configuration with more than one upstream Identity Provider. This RFC lifts that restriction.Core design: sequential authorization chain. When a client calls
GET /oauth/authorize, the auth server redirects the user through each configured upstream IDP in sequence — accumulating one token set per provider — before issuing the final authorization code. The client performs a single standard OAuth2 flow; all intermediate redirects are server-driven and transparent.Token delivery via
Identity. After JWT validation, the auth middleware callsGetAllUpstreamTokensand populatesIdentity.UpstreamTokens map[string]string(provider name → access token). Downstream middleware (e.g.upstreamswap) reads from this struct field — no storage calls, no context extraction.Key changes across four implementation phases
pkg/authserver/storage/providerNameparam toStore/Get; addGetAllUpstreamTokens; new Redis key pattern + session index SET; eviction usesmax(access, refresh) ExpiresAtpkg/authserver/server/handlers/upstreamfield withmap + orderedSlice; implement authorize/callback chain logic; addnextMissingUpstreampkg/authserver/config.go,pkg/runner/, operator CRDslen > 1rejection from auth server; add it to proxy runner; move CRD restriction fromMCPExternalAuthConfigto per-workload admission webhooks soVirtualMCPServeris unrestricted; removeConfig.GetUpstream()pkg/auth/,pkg/auth/upstreamswap/,pkg/runner/middleware.goUpstreamTokenstoIdentity; enrich in auth middleware; removeStorageGetterfromupstreamswap; deriveProviderNameinaddUpstreamSwapMiddlewareWhat is explicitly out of scope
thv proxy) orMCPServer/MCPRemoteProxyworkload types — they remain single-upstream.