Loading
Draft: Distributed OAuth Applications across Cells
Related MRs
| Repository | MR |
|---|---|
| gitlab-rails | gitlab-org/gitlab!236139 (closed) |
| topology-service | topology-service!518 (closed) |
Summary
- Adds a dedicated
oauthTokenHandlerforPOST /oauth/tokenthat reads form data and routes to the correct cell by decoding the cell ID embedded in routablegloak-/gloag-/gloar-tokensauthorization_codegrant: extracts the cell ID from thecodefield (expectsgloag-prefix)refresh_tokengrant: extracts the cell ID from therefresh_tokenfield (expectsgloar-prefix)- All other grant types (e.g.
client_credentials) fall back to the JSON rule handler - Falls back to the JSON rule handler when no routable token is present or topology service is not configured
- Adds
decodeGloakTokenutility that parses the routing payload fromgloak-/gloag-/gloar-prefixed tokens (base36-encoded key-value pairs) - Adds
oauth.jsonruleset with two rules for header- and query-string-based classification:oauth_routable_bearer_token— routes requests carrying agloak-bearer token in theAuthorizationheader by decoding the embedded cell IDoauth_routable_auth_code— routes OAuth redirect callbacks carrying agloag-code in thecodequery parameter
- Adds
ClientIDto theClassifyTypeenum (used by related MRs) - Removes the
oauth_client_idrouting rule — OAuth flows are now handled on the user's cell, not the application's cell - Changes custom route registration from
router.gettorouter.allso thatPOST /oauth/tokenand other non-GET custom routes are handled correctly - Fixes
Object.fromEntries(request.headers)spread in test helpers to avoid TypeScript spread-on-non-plain-object errors - Fixes TypeScript cast for
caches.defaultspy in test setup
Context
Part of the Distributed OAuth Applications feature. Previously the router attempted to route /oauth/authorize requests to the cell that registered the OAuth application by classifying the client_id. With the new design, OAuth applications are published globally via the Topology Service and all OAuth flows are handled on the user's own cell. Token and auth code routing by cell-embedded prefix is sufficient.
Companion changes (same branch name feat/distributed-idp-oauth):
- gitlab-rails: routable
gloak-tokens,Cells::ClaimableonOauthApplication,SignInWithJWKScross-cell cookie - topology-service:
string user_dataon claims,record_user_datainClassifyResponse
Test plan
-
oauthTokenHandlerroutesauthorization_codegrant withgloag-code to the correct cell -
oauthTokenHandlerdefaults toauthorization_codewhengrant_typeis omitted -
oauthTokenHandlerroutesrefresh_tokengrant withgloar-refresh token to the correct cell -
oauthTokenHandlerfalls back to JSON rule handler when token is not routable -
oauthTokenHandlerfalls back to JSON rule handler forclient_credentialsgrant -
oauthTokenHandlerfalls back to JSON rule handler when topology service is not configured -
oauth_routable_bearer_tokenrule matchesgloak-bearer tokens inAuthorizationheader -
oauth_routable_auth_coderule matchesgloag-codes incodequery parameter -
oauth_client_idrule is no longer present and no regressions in OAuth routing
Edited by Kamil Trzciński (Claude)