nuts-foundation / nuts-foundation/nuts-node

Apply scope policy to OpenID4VP / auth-code flow token issuance

Open
#4,202 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
28
Forks
23
Avg merge
1d 10h
Merged PRs (30d)
76

Description

Context

#4179 added server-side scope policy enforcement (profile-only / passthrough / dynamic) to the S2S vp_token flow in handleS2SAccessTokenRequest. The OpenID4VP / authorization-code flow takes a separate path to createAccessToken that does not invoke grantedScopesForPolicy — so scope policy is currently not enforced for that flow.

Problem

In auth/api/iam/openid4vp.go the auth-code handler uses oauthSession.Scope (the raw requested scope) and passes it directly to createAccessToken. This means:

  • profile-only: extra scopes are NOT rejected
  • dynamic: the AuthZen PDP is NOT called; extra scopes pass through without evaluation
  • passthrough: works by accident (raw scope is forwarded)

A client going through the auth-code flow can request arbitrary extra scopes and receive them in the issued access token — bypassing the policy that's enforced on the S2S path.

Expected behaviour

Same as the S2S flow:

  • Look up the credential profile via FindCredentialProfile
  • Reject profile-only + extras
  • Call the AuthZen PDP for dynamic
  • Issue token with only granted scopes

Related

  • Parent PRD: #4144
  • Introduced gap: #4179

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in auth/api/iam/openid4vp.go and trace the authorization-code path through createAccessToken. Compare it with handleS2SAccessTokenRequest and grantedScopesForPolicy, including FindCredentialProfile and the profile-only, dynamic, and passthrough cases. Done means extra scopes are rejected or evaluated as appropriate and issued tokens contain only granted scopes.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, authentication
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.