Feat/exchange provider token for jwt#8
Open
MP-Tool wants to merge 4 commits into
Open
Conversation
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.
PR: Add
ExchangeProviderTokenForJwt(RFC 8693 Token Exchange)Adds a new login path that lets external clients exchange an already-established OAuth provider token directly for a Komodo JWT — no second browser redirect needed. Related to the Komodo feature request #1406
What changed
New API types (
auth/client/rs,auth/client/ts)SubjectTokenTypeenum with three variants —OidcIdToken,GoogleIdToken,GitHubAccessToken— using RFC 8693 field names (subject_token_type,subject_token). Registered inLoginRequest, OpenAPI schema, and the generated TypeScript client.AuthImpltrait extension (auth/server/src/lib.rs)Three new default methods:
exchange_and_validate_oidc_token,exchange_and_validate_github_token,exchange_and_validate_google_token. Each defaults to a "Must implement" error — no existing implementation breaks at compile time.OIDC provider (
auth/server/src/provider/oidc.rs)New public
validate_id_token_and_extract_subjectfor stateless ID token validation: verifies signature, issuer, audience, and expiry; skips nonce andaccess_token_hash, which don't apply to direct token exchange. Internally reuses the newly extracted private helpervalidate_id_token_claims, which also eliminates the duplicatedadditional_audiencesverifier logic from the existing authorization code flow.Login endpoint (
auth/server/src/api/login/mod.rs)Resolve<LoginArgs>impl forExchangeProviderTokenForJwt: dispatches onsubject_token_type, calls the matchingAuthImplmethod, mints a JWT for the returned subject. Rate-limited and instrumented identically toExchangeForJwt. The existingExchangeForJwtresolver was refactored to extract a private helper — no behaviour change.Tests — 21 unit tests: JWT subject verification for all three providers, per-provider rejection, empty token, and cross-provider routing (a token accepted by one
SubjectTokenTypemust be rejected by any other).