Client-side multi-scope token flow#4178
Draft
stevenvegt wants to merge 5 commits into4144-1-scope-parsing-and-configfrom
Draft
Client-side multi-scope token flow#4178stevenvegt wants to merge 5 commits into4144-1-scope-parsing-and-configfrom
stevenvegt wants to merge 5 commits into4144-1-scope-parsing-and-configfrom
Conversation
|
Coverage Impact This PR will not change total coverage. Modified Files with Diff Coverage (4)
🤖 Increase coverage with AI coding...🚦 See full report on Qlty Cloud » 🛟 Help
|
Introduces PresentationDefinitionResolver that abstracts PD resolution. When the remote AS metadata advertises a PD endpoint, the PD is fetched remotely and the full scope string is returned for the token request. Local fallback path is stubbed for the next cycle. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When no remote PD endpoint exists, the resolver calls FindCredentialProfile locally. Profile-only rejects extra scopes, passthrough/dynamic forward all. Tests cover both remote and local paths with all scope policies. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace direct PD fetch in RequestRFC021AccessToken with the PresentationDefinitionResolver. The resolver is a dependency on OpenID4VPClient, wired through Auth → NewClient. The policy backend is passed through Auth to enable local PD fallback. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add nil guard on policyBackend in resolveLocal - Return canonical credential profile scope for profile-only (not raw input) - Add comment explaining dynamic treated same as passthrough on client side - Add tests: nil policy backend, missing org PD, remote endpoint error - Fix import grouping in test file Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
f1ee8fb to
0b190e6
Compare
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.

Parent PRD
#4144
Implementation Spec
Overview
Modify the client-side token request flow to support mixed OAuth2 scopes. Introduces a
PresentationDefinitionResolverthat abstracts the decision of whether to fetch a PD from the remote AS or fall back to local policy resolution. When using local resolution, scope policy is enforced.Design decisions
PresentationDefinitionResolverabstraction: The client (RequestRFC021AccessToken) should not decide where the PD comes from. A resolver encapsulates the remote-vs-local decision and scope policy enforcement, keeping the client focused on the OAuth flow.FindCredentialProfilelocally to get the PD and scope classification. Scope policy is enforced locally: profile-only rejects extra scopes, passthrough/dynamic forward all scopes.OpenID4VPClient: The resolver is a struct dependency, wired throughAuth→NewClient. Policy backend passed throughAuthto enable local PD fallback.Deviations from original spec
presentationDefinitionForScopewas the modification point: That helper is server-side only. The actual client-side flow goes throughRequestRFC021AccessToken→ remote PD endpoint. The resolver replaces the direct PD fetch.Authstruct: AddedpolicyBackendparameter toNewAuthInstanceandiam.NewClientto propagate the policy backend to the resolver.Modified flow
Acceptance Criteria
PresentationDefinitionResolverresolves PD from remote when PD endpoint existsFindCredentialProfilewhen no remote PD endpointRequestRFC021AccessTokenuses resolver instead of direct PD fetch