Alternative: XAA as OAuthClientProvider with Layer 2 utilities#1531
Draft
Alternative: XAA as OAuthClientProvider with Layer 2 utilities#1531
Conversation
Replaces the standalone middleware approach from PR #1328 with: - CrossAppAccessProvider in authExtensions.ts: plugs into withOAuth for token caching, 401 retry, client_secret_basic, and Zod validation - assertion callback: receives orchestrator context (AS URL, resource URL, scope, fetchFn), returns JAG string. Decouples IDP interaction from provider - requestJwtAuthorizationGrant in crossAppAccess.ts: standalone Layer 2 utility for RFC 8693 token exchange (ID token → JAG) - saveResourceUrl on OAuthClientProvider: orchestrator saves resource URL so providers can use it in prepareTokenRequest Removes: withCrossAppAccess middleware, xaaUtil.ts (597 lines), qs dependency Adds: conformance test scenario (auth/cross-app-access-complete-flow) - passes 9/9
|
- Delete xaa-util.test.ts (tests for removed xaaUtil.ts) - Revert docs/client.md withCrossAppAccess documentation - Remove qs and @types/qs dependencies from package.json - Remove qs from pnpm-workspace.yaml catalog - Revert middleware.test.ts withCrossAppAccess test additions
Replace hand-rolled typeof checks and generic Error throws with: - JagTokenExchangeResponseSchema (Zod) for response validation - parseErrorResponse() for error responses (typed OAuthError) Consistent with how auth.ts validates all other OAuth responses.
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.
Alternative implementation for PR #1328
This is an alternative approach to #1328 (SEP-990 Enterprise Managed OAuth). Instead of a standalone middleware, this implements Cross-App Access as an
OAuthClientProviderwith composable Layer 2 utilities.Design
Layer 2:
crossAppAccess.ts(~130 lines)requestJwtAuthorizationGrant()— standalone RFC 8693 token exchange utilitydiscoverAndRequestJwtAuthGrant()— convenience wrapper with IDP discoveryLayer 3:
CrossAppAccessProviderinauthExtensions.tsassertioncallback that receives orchestrator context and returns a JAGwithOAuthfor token caching, 401 retry,client_secret_basic, Zod validationsaveAuthorizationServerUrl(PR feat: expose discoverOAuthServerInfo() and add provider caching for auth server URL #1527) and newsaveResourceUrlto get MCP AS info from the orchestratorUsage
Key decisions
saveResourceUrladded toOAuthClientProvider(same pattern assaveAuthorizationServerUrlin feat: expose discoverOAuthServerInfo() and add provider caching for auth server URL #1527) so providers can access orchestrator-discovered stateqsdependency — usesURLSearchParamslike the rest of the codebaseDepends on
saveAuthorizationServerUrl/authorizationServerUrlon the provider interfaceConformance
Passes
auth/cross-app-access-complete-flowscenario (9/9 checks).