nuts-foundation / nuts-foundation/nuts-node
Generic issuer-to-credentialSubject attribute matching for did:x509
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 28
- Forks
- 23
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 76
Description
Parent PRD
#4079
What to build
Extract the validatePolicyAssertions logic from X509CredentialValidator and make it apply generically to any credential with a did:x509 issuer. This implements PSA 10.6.2 rule 9: identifier values in credentialSubject that originate from the issuer DID must match the corresponding attributes in the issuer DID.
- In the
Verifyfunction (verifier.go), after signature verification succeeds for a credential with a did:x509 issuer, match credentialSubject identifiers against issuer DID attributes - Implement a recursive walk of the
credentialSubjectJSON to find all objects withsystem/valuefields (identifier pattern per PSA 10.6.1) - Match each identifier against the corresponding issuer DID attribute based on
systemURI:http://fhir.nl/fhir/NamingSystem/ura→ URA from issuer DIDhttp://fhir.nl/fhir/NamingSystem/uzi-nr-pers→ UZI-nummer from issuer DID
- Handle
roleCodeas a known special case (direct attribute, not an identifier object) - Remove
validatePolicyAssertionsfromX509CredentialValidator
This is independent of the CRL/resolver changes and can be worked on in parallel.
Acceptance criteria
- Identifier matching runs for any credential with a did:x509 issuer, not just X509Credential type
- Recursive walk finds deeply nested identifiers (e.g.,
credentialSubject.hasEnrollment.enrolledBy.identifier) - URA mismatch between credentialSubject and issuer DID produces an error
- UZI-nummer mismatch between credentialSubject and issuer DID produces an error
- roleCode mismatch produces an error
-
validatePolicyAssertionsis removed fromX509CredentialValidator - Existing X509Credential tests pass
- New test: PatientEnrollmentCredential with matching UZI-nummer passes
- New test: PatientEnrollmentCredential with mismatched UZI-nummer fails
- New test: HealthcareProviderCredential with matching URA passes
- New test: HealthcareProviderCredential with mismatched URA fails
Blocked by
None — can start immediately (independent of resolver/key resolution changes).
User stories addressed
- User story 1: PatientEnrollmentCredentials get attribute matching
- User story 2: HealthcareProfessionalDelegationCredentials get UZI-nummer and roleCode validated
- User story 3: HealthcareProviderCredentials get URA validated
- User story 7: existing behavior preserved
- User story 8: no type-specific validators needed for new credential types
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in verifier.go and inspect the existing validatePolicyAssertions logic in X509CredentialValidator, including the existing X509Credential tests. Trace verification after signature validation and identify the credentialSubject structures and issuer DID attributes involved. Done means generic did:x509 credentials pass matching URA, UZI-nummer, and roleCode checks, mismatches fail, recursive identifiers are covered by new tests, and the old validator logic is removed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- authentication, security
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100