Skip to content

Commit 8b10ac5

Browse files
committed
Ignore the pre-final singular proof parameter in Credential Requests
OpenID4VCI 1.0 section 8.2 has the Credential Issuer ignore the parameters it does not recognize, and 1.0 defines only `proofs`. OpenId4VciProofValidator refused a request carrying the pre-final singular `proof` instead: with invalid_proof for a credential configuration which binds a holder key, even beside a `proofs` which would have been served, and with invalid_credential_request for one which binds none. The singular parameter now decides nothing. A key-binding configuration serves a request carrying both by its `proofs`, and still refuses one carrying `proof` alone, now for lacking the `proofs` it requires. A proofless configuration issues a request carrying `proof` as one without it, as its metadata, with no binding methods and no proof types, says it does; a `proofs` sent to it stays refused. Decision D29 of the OpenID4VCI 1.0 fix plan; the compliance matrix marks row 34 met and closes G24.
1 parent 6870981 commit 8b10ac5

3 files changed

Lines changed: 94 additions & 26 deletions

File tree

‎conformance-tests/openid4vci-1_0-compliance.md‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ Status values:
116116
| 31 | The issued credential SHOULD be bound to the key the proof proves (§8.1). | Met | `CredentialIssuerCredentialController::issueCredential()` (`cnf`). | `CredentialIssuerCredentialControllerTest`: `testBindsTheCredentialToWhatTheProofResolvedTo`, `testStatesTheConfirmedKeyInEveryFormat`. |
117117
| 32 | A batch shares one format and Credential Dataset, with different cryptographic data (§3.3.2). | Met | `CredentialIssuerCredentialController::issueCredential()`: one configuration per request, and the user's claims mapped alike into every credential of it; each credential has an identifier of its own and is bound to its own key, which the W3C formats also state as their subject. | `CredentialIssuerCredentialControllerTest::testTheCredentialsOfABatchDifferOnlyInWhatIdentifiesEach` (every format; the body and the disclosures). |
118118
| 33 | Each key provided by the Wallet binds at most one credential (§8.3). | Met | `OpenId4VciProofValidator::validateRequest()` refuses with `invalid_proof` a request in which two proofs prove the same key, compared by its JWK SHA-256 Thumbprint (RFC 7638), however each proof names it; the key a proof is verified with must be in the one representation RFC 7518 defines (the openid library's `Helpers\Jwk::enforcePublicKey()`), so one key can not be written two ways (RFC 7638 section 7). | `OpenId4VciProofValidatorTest`: `testRefusesTwoProofsNamingTheSameVerificationMethod`, `testRefusesTwoVerificationMethodsResolvingToTheSameKey`, `testRefusesAnInlineKeyWhichAVerificationMethodAlsoResolvesTo`, `testRefusesTheSameInlineKeyWrittenWithOtherMembers`, `testAcceptsTwoInlineKeysWhichDiffer`, `testRefusesASecondProofOfTheSameKeyWrittenWithALeadingZeroOctet`, `testRefusesAnInlineKeyWithALeadingZeroOctetInACoordinate`, `testRefusesAResolvedKeyWithAStrayBitAfterTheLastOctet`. |
119-
| 34 | The issuer ignores unrecognized request parameters (§8.2). | Partial (G24) | The controller reads the parameters it knows: one no specification defines is ignored, and so are the pre-final `format`, `vct` and `credential_definition` beside a `credential_configuration_id`. The pre-final singular `proof` is refused instead, even beside a `proofs` which would be served: `invalid_proof`, or `invalid_credential_request` for a configuration which binds no key (`OpenId4VciProofValidator::extractProofJwts()`, `refuseSuppliedProofs()`). | `CredentialIssuerCredentialControllerTest::testIgnoresTheParametersOfARequestItDoesNotRecognize`; the refusal: `OpenId4VciProofValidatorTest::testRefusesTheSingularProofParameter`. |
119+
| 34 | The issuer ignores unrecognized request parameters (§8.2). | Met | The controller reads the parameters it knows: one no specification defines is ignored, and so are the pre-final `format`, `vct` and `credential_definition` beside a `credential_configuration_id`. The pre-final singular `proof` is not read either (`OpenId4VciProofValidator::extractProofJwts()`, `refuseSuppliedProofs()`): beside a `proofs` the request is served by its `proofs`; alone, it leaves a configuration which binds a key without the `proofs` it requires (`invalid_proof`), and one which binds none issues as without it. | `CredentialIssuerCredentialControllerTest::testIgnoresTheParametersOfARequestItDoesNotRecognize`; the singular `proof`: `OpenId4VciProofValidatorTest`: `testIgnoresTheSingularProofParameter`, `testRefusesARequestCarryingOnlyTheSingularProofParameter`, `testAProoflessConfigurationIgnoresTheSingularProofParameter`. |
120120
| 35 | Immediate issuance answers 200, `application/json`, with `credentials`, an array of objects each holding one `credential`; JWT and SD-JWT credentials are not re-encoded (§8.3, A.1.1.4, A.3.4). | Met | `CredentialIssuerCredentialController::issueCredential()`, through `Routes::newJsonResponse()`. | `CredentialIssuerCredentialControllerTest`: `testAnswersEachCredentialAsTheStringItWasSerializedTo` (every format, the credentials built and serialized by the library), `testCredentialWithMultipleProofs`. |
121121
| 36 | A token which does not enable issuance gets an RFC 6750 section 3 error, with a `WWW-Authenticate` challenge (§8.3.1.1). | Met | `CredentialIssuerCredentialController::credential()`, `tokenErrorResponse()`: `invalid_token` (401) for a token which is not found, revoked, not issued for credential issuance, lacking the issuer state it needs, or naming no user or one who no longer exists; `insufficient_scope` (403) for one which does not grant the credential asked for. Each names the error in the challenge of the scheme the token was presented under, and the faults of the token alone are refused before the request is read. | `CredentialIssuerCredentialControllerTest`: `testAnswersWithInvalidTokenWhenTheAccessTokenIsNotFound`, `testAnswersWithInvalidTokenWhenTheAccessTokenIsRevoked`, `testAnswersARequestWithoutAnAccessTokenWithTheBareChallengeAlone`, `testRefusesAnAccessTokenNotIssuedForCredentialIssuance`, `testRefusesAnAccessTokenWhichNamesNoUser`, `testRefusesAnAccessTokenWhoseUserNoLongerExists`, `testRefusesATokenWithoutAUserBeforeLookingAtTheRequest`, `testRefusesACredentialTheTokenDoesNotGrant`, `testRefusesACredentialTheTokenDoesNotGrantUnderTheSchemeItWasPresentedUnder`, `testRefusesATokenPresentedUnderTheDpopSchemeUnderThatScheme`. |
122122
| 37 | Payload errors use the section 8.3.1.2 codes with 400 and `application/json` (§8.3.1.2). | Met | `CredentialIssuerCredentialController::issueCredential()`; `OpenId4VciProofValidator` (`invalid_proof`, `invalid_nonce`); `Routes::newJsonErrorResponse()` answers `application/json`. | `CredentialIssuerCredentialControllerTest`: `testAnswersARefusedRequestWithTheErrorCodeTheRefusalCarried`, `testRefusesARequestWhichNamesNoCredential`, `testRefusesAnUnknownCredentialConfiguration`; `OpenId4VciProofValidatorTest::testAnswersAStaleNonceWithItsOwnErrorCode`; `RoutesTest::testNewJsonErrorResponseUsesTheOAuth2ErrorShape` (the content type). |
@@ -251,8 +251,6 @@ rows on confidential clients only, client authentication methods and the `aud` o
251251
OpenID4VCI 1.0 (the base specification):
252252

253253
- **G8** No consent screen of the module's own shows what a credential will contain and why (row 47).
254-
- **G24** A Credential Request carrying the pre-final `proof` parameter is refused rather than the parameter
255-
ignored (row 34).
256254

257255
HAIP 1.0 and the FAPI 2.0 provisions it applies:
258256

‎src/VerifiableCredentials/OpenId4VciProofValidator.php‎

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -254,15 +254,17 @@ public function validateRequest(
254254
* Silently ignoring one would be worse than refusing it: the wallet built a proof, sent it, and got
255255
* back a credential bound to something else, with nothing on it to say its key went unused.
256256
*
257+
* That is about `proofs`, the parameter OpenID4VCI 1.0 defines. The pre-final singular `proof` is not
258+
* one of its parameters, and section 8.2 has an issuer ignore the parameters it does not recognize, so
259+
* a request carrying it is issued as one without it: the metadata this configuration publishes, with
260+
* no binding methods and no proof types, already told the wallet that what it issues is bound to no key.
261+
*
257262
* @param array<array-key,mixed> $requestData
258263
* @throws \SimpleSAML\Module\oidc\Exceptions\CredentialRequestException
259264
*/
260265
protected function refuseSuppliedProofs(array $requestData): void
261266
{
262-
if (
263-
array_key_exists(ClaimsEnum::Proof->value, $requestData) ||
264-
array_key_exists(ClaimsEnum::Proofs->value, $requestData)
265-
) {
267+
if (array_key_exists(ClaimsEnum::Proofs->value, $requestData)) {
266268
throw new CredentialRequestException(
267269
'invalid_credential_request',
268270
'This credential configuration issues credentials which are not bound to a holder key, ' .
@@ -279,15 +281,9 @@ protected function refuseSuppliedProofs(array $requestData): void
279281
*/
280282
protected function extractProofJwts(array $requestData): array
281283
{
282-
// The singular parameter is the pre-final shape of this request. Accepting it would mean
283-
// accepting a request the metadata this configuration publishes does not describe.
284-
if (array_key_exists(ClaimsEnum::Proof->value, $requestData)) {
285-
throw new CredentialRequestException(
286-
'invalid_proof',
287-
'The proof parameter is not supported. Send the key proof in the proofs parameter.',
288-
);
289-
}
290-
284+
// Only `proofs` is read. The pre-final singular `proof` is not an OpenID4VCI 1.0 parameter, and
285+
// section 8.2 has an issuer ignore the parameters it does not recognize: a request carrying both is
286+
// served by its `proofs`, and one carrying `proof` alone is refused below for lacking `proofs`.
291287
/** @psalm-suppress MixedAssignment */
292288
$proofs = $requestData[ClaimsEnum::Proofs->value] ?? null;
293289

‎tests/unit/src/VerifiableCredentials/OpenId4VciProofValidatorTest.php‎

Lines changed: 84 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -530,14 +530,23 @@ protected function realProof(
530530
* @return array<string,mixed>
531531
*/
532532
protected function requestWithRealProofs(array $proofJwts): array
533+
{
534+
$this->parsesRealProofs();
535+
536+
return ['proofs' => ['jwt' => $proofJwts]];
537+
}
538+
539+
540+
/**
541+
* Has the library's own proof factory parse every proof the validator reads.
542+
*/
543+
protected function parsesRealProofs(): void
533544
{
534545
$this->proofFactoryMock->method('fromToken')->willReturnCallback(
535546
static fn(string $token): OpenId4VciProof => self::realVerifiableCredentials()
536547
->openId4VciProofFactory()
537548
->fromToken($token),
538549
);
539-
540-
return ['proofs' => ['jwt' => $proofJwts]];
541550
}
542551

543552

@@ -613,12 +622,63 @@ public function testRefusesAProofBoundRequestWhichCarriesNoProof(): void
613622

614623

615624
/**
616-
* The pre-final singular parameter is not the shape a configuration advertising the final
617-
* `proof_types_supported` describes.
625+
* The pre-final singular parameter is not an OpenID4VCI 1.0 one, and section 8.2 has an issuer ignore the
626+
* parameters it does not recognize, so a request carrying it beside `proofs` is served by `proofs` alone. The
627+
* singular proof here would be refused if it were read, in place of `proofs` or beside them: it names the same
628+
* verification method as the proof which is served, but is signed with another key.
629+
*
630+
* @throws \Throwable
631+
*/
632+
public function testIgnoresTheSingularProofParameter(): void
633+
{
634+
$unreadProof = $this->realProof();
635+
$servedKey = JWKFactory::createECKey('P-256');
636+
637+
$validatedProofs = $this->sut()->validateRequest(
638+
$this->requestWithRealProofs([$this->realProof(key: $servedKey)]) +
639+
['proof' => ['proof_type' => 'jwt', 'jwt' => $unreadProof]],
640+
VciCredentialBindingPolicyEnum::ProofBound,
641+
$this->accessTokenMock,
642+
);
643+
644+
$this->assertCount(1, $validatedProofs);
645+
$this->assertSame($servedKey->thumbprint('sha256'), $validatedProofs[0]?->getKeyThumbprint());
646+
647+
// What it would have met, had it been read.
648+
$this->assertRefusedWith(
649+
'invalid_proof',
650+
['proofs' => ['jwt' => [$unreadProof]]],
651+
expectedMessageFragment: 'signature could not be verified',
652+
);
653+
}
654+
655+
656+
/**
657+
* Ignored, the singular parameter leaves the request without the `proofs` this configuration requires. The
658+
* proof in it is a sound one, so what refuses the request is the missing `proofs`, not the parameter.
659+
*
660+
* @throws \Throwable
618661
*/
619-
public function testRefusesTheSingularProofParameter(): void
662+
public function testRefusesARequestCarryingOnlyTheSingularProofParameter(): void
620663
{
621-
$this->assertRefusedWith('invalid_proof', ['proof' => ['proof_type' => 'jwt', 'jwt' => 'proof-jwt']]);
664+
$proof = $this->realProof();
665+
$this->parsesRealProofs();
666+
667+
$this->assertRefusedWith(
668+
'invalid_proof',
669+
['proof' => ['proof_type' => 'jwt', 'jwt' => $proof]],
670+
expectedMessageFragment: 'The proofs parameter is required',
671+
);
672+
673+
// The same proof, sent where 1.0 has it.
674+
$this->assertCount(
675+
1,
676+
$this->sut()->validateRequest(
677+
['proofs' => ['jwt' => [$proof]]],
678+
VciCredentialBindingPolicyEnum::ProofBound,
679+
$this->accessTokenMock,
680+
),
681+
);
622682
}
623683

624684

@@ -651,11 +711,25 @@ public function testAProoflessConfigurationRefusesASuppliedProof(): void
651711
['proofs' => ['jwt' => ['proof-jwt']]],
652712
VciCredentialBindingPolicyEnum::Proofless,
653713
);
714+
}
654715

655-
$this->assertRefusedWith(
656-
'invalid_credential_request',
657-
['proof' => ['proof_type' => 'jwt', 'jwt' => 'proof-jwt']],
658-
VciCredentialBindingPolicyEnum::Proofless,
716+
717+
/**
718+
* Not a supplied proof in OpenID4VCI 1.0 terms: the pre-final singular parameter is one this issuer does not
719+
* recognize, so the request is issued as without it (section 8.2), one credential bound to nothing, which is
720+
* what the metadata of this configuration says it issues.
721+
*
722+
* @throws \Throwable
723+
*/
724+
public function testAProoflessConfigurationIgnoresTheSingularProofParameter(): void
725+
{
726+
$this->assertSame(
727+
[null],
728+
$this->sut()->validateRequest(
729+
['proof' => ['proof_type' => 'jwt', 'jwt' => 'proof-jwt']],
730+
VciCredentialBindingPolicyEnum::Proofless,
731+
$this->accessTokenMock,
732+
),
659733
);
660734
}
661735

0 commit comments

Comments
 (0)