Skip to content

Commit fb5f2cd

Browse files
committed
Let the maker of a credential offer withdraw it
An integration which made a credential offer can now withdraw it (POST api/vci/credential-offer/{offer_id}/withdraw), so that the offer buys nothing more. Revoking everything an offer issued is then: withdraw it, list its credentials, revoke each, with nothing issued after the list. Credentials already issued are left as they are. The offer's record is the single source of truth, read wherever the offer could still buy something: - the token endpoint refuses its pre-authorized code or issuer state with invalid_grant. The check sits in the redemption write which must succeed, which now reports Recorded, Withdrawn or NotRecorded, so a withdrawal landing while the token is minted is seen too; - the authorization endpoint refuses its issuer_state before the user is asked to log in; - the credential endpoint refuses a token minted for it with invalid_token, before key proofs are validated or anything is allocated or signed, and again after the request's credentials are linked to the offer, so a listing taken after the withdrawal holds every credential the offer handed out. The endpoint takes the listing's authorization and its single 404, and answers withdrawn_at and changed; withdrawing again answers changed: false with the first moment. Also moves the status API's ownership paragraph in docs/8-api.md out of its error list, which it had split (markdownlint MD032 failed CI on b1007fa). Assisted-by: Claude Code (claude-opus-5-5, implementation & tests) Assisted-by: Claude Code (claude-sonnet-5-5, grant and rule test adaptation) Assisted-by: OpenAI Codex (gpt-6.1-sol, xhigh review) Assisted-by: Google Antigravity (gemini-3.8-flash-high, review)
1 parent b1007fa commit fb5f2cd

22 files changed

Lines changed: 1594 additions & 160 deletions

‎docs/1-oidc.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,11 @@ Currently implemented OpenID4VCI features:
239239
- Nonce Endpoint | `credential-issuer/nonce` - Provides nonces (`c_nonce`).
240240
- Credential Offer (API) | `api/vci/credential-offer` - Allows triggering
241241
credential offers via administrative API.
242+
- Credential Offer Details (API) | `api/vci/credential-offer/{offerId}` -
243+
Lists what an offer issued, for the API caller which made it.
244+
- Credential Offer Withdrawal (API) |
245+
`api/vci/credential-offer/{offerId}/withdraw` - Withdraws an offer, so that it
246+
issues nothing more.
242247
- Credential Status (API) | `api/vci/credential-status` - Withdraws, suspends
243248
or reinstates an issued credential through its Token Status List entry.
244249
- JSON-LD Context | `credential-issuer/context/{credentialConfigurationId}` -

‎docs/8-api.md‎

Lines changed: 84 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ The name, or the fingerprint of an unnamed token, is also who owns the credentia
7474
owner, by design: a token can be rotated without losing its offers, and an offering system and a support system can
7575
share their offers by sharing a name. Two integrations an operator gives the same name share them too, so give each
7676
integration a name of its own. An unnamed token owns its offers by its fingerprint, so rotating it loses them: the
77-
new token can neither list them nor change the status of what they issued (the administration screens still can).
77+
new token can neither list nor withdraw them, nor change the status of what they issued (the administration screens
78+
still reach those credentials).
7879

7980
### Limiting a token to credential configurations
8081

@@ -178,8 +179,9 @@ The response is a JSON object with two fields:
178179
* __credential_offer_uri__ (string): the credential offer URI, which the wallet is sent to.
179180
* __offer_id__ (string): the identifier of the offer, 64 lower-case hexadecimal characters. Keep it: it is how the
180181
caller later asks which credentials the offer produced, and changes their status (see
181-
[Credential Offer Details](#credential-offer-details)). It is neither the pre-authorized code nor the issuer state,
182-
which redeem the offer and are for the wallet only, so it can go into the caller's own records and logs.
182+
[Credential Offer Details](#credential-offer-details)), and how it withdraws the offer (see
183+
[Credential Offer Withdrawal](#credential-offer-withdrawal)). It is neither the pre-authorized code nor the issuer
184+
state, which redeem the offer and are for the wallet only, so it can go into the caller's own records and logs.
183185

184186
Every offer is recorded, with the principal of the token which made it as its owner (its name, or a fingerprint;
185187
see [Naming a token](#naming-a-token)). An offer made from an administrator's session, or from the administration
@@ -287,7 +289,8 @@ Response:
287289

288290
Tells the caller which made a credential offer what the offer produced: the offer as it is recorded, and the
289291
credentials issued from it, each with the identifier the [Credential Status](#credential-status) endpoint takes.
290-
Withdrawing a credential issued from an offer is then: list the offer's credentials, and change the status of each.
292+
Revoking everything an offer issued is then: [withdraw the offer](#credential-offer-withdrawal), so that it issues
293+
nothing more, list its credentials, and change the status of each.
291294

292295
It is served under the same settings as the [Credential Offer](#credential-offer) endpoint: the API, the VCI
293296
feature and `ModuleConfig::OPTION_API_VCI_CREDENTIAL_OFFER_ENDPOINT_ENABLED`. With the VCI feature switched off
@@ -325,7 +328,8 @@ A JSON object with the following fields. Moments are numbers of seconds since th
325328
* __redeemable_until__ (number): when its pre-authorized code or issuer state expires.
326329
* __redeemed_at__ (number or `null`): when an access token was first issued for the offer, `null` until then. It says
327330
that a token was issued, not that a credential reached a wallet.
328-
* __withdrawn_at__ (number or `null`): reserved for withdrawing an offer; always `null` for now.
331+
* __withdrawn_at__ (number or `null`): when the offer was withdrawn (see
332+
[Credential Offer Withdrawal](#credential-offer-withdrawal)), `null` while it is not.
329333
* __credentials__ (array): the credentials issued from the offer, in the order they were issued, at most 500 per
330334
page. Each is an object with:
331335
* __credential_id__ (string): the credential's `jti`, which the credential status endpoint takes.
@@ -390,6 +394,74 @@ Response:
390394
}
391395
```
392396

397+
### Credential Offer Withdrawal
398+
399+
Withdraws a credential offer, so that it issues nothing more:
400+
401+
* the token endpoint no longer redeems the offer's pre-authorized code or issuer state, and answers a wallet which
402+
presents one with `invalid_grant`;
403+
* an authorization request carrying the offer's `issuer_state` is refused (`invalid_request`) before the user is
404+
asked to log in;
405+
* the credential endpoint refuses the access tokens already issued for the offer, with `401` `invalid_token`.
406+
407+
Credentials already issued from the offer are left as they are: to revoke them, list them with
408+
[Credential Offer Details](#credential-offer-details) and change the status of each. A listing taken after the
409+
withdrawal holds every credential the offer handed out, because the credential endpoint asks whether the offer is
410+
withdrawn once more after a request's credentials are linked to the offer and before it hands them out. A response
411+
already on its way may still reach the wallet after the withdrawal; its credentials are in the listing all the same.
412+
413+
It is served under the same settings as the [Credential Offer](#credential-offer) endpoint.
414+
415+
#### Path
416+
417+
`/api/vci/credential-offer/{offer_id}/withdraw`, with the `offer_id` the credential offer endpoint answered.
418+
419+
#### Method
420+
421+
`POST`, with no body.
422+
423+
#### Authorization
424+
425+
As for [Credential Offer Details](#credential-offer-details): a bearer token from the `Authorization` header, with
426+
one of the scopes of the credential offer endpoint, standing for the principal which made the offer, and with every
427+
credential configuration the offer offered still in its `credential_configuration_ids`.
428+
429+
#### Response
430+
431+
A JSON object with the following fields:
432+
433+
* __withdrawn_at__ (number): when the offer was withdrawn, in seconds since the epoch (UTC).
434+
* __changed__ (boolean): whether this request is what withdrew it. `false` means the offer was withdrawn already, so
435+
a caller retrying a request it never saw the answer to can tell which happened; `withdrawn_at` is then the moment of
436+
the first withdrawal.
437+
438+
Errors:
439+
440+
* `401 unauthorized`: no bearer token, or one which is not configured.
441+
* `403 insufficient_scope`: the token is configured but has none of the scopes this endpoint accepts.
442+
* `404 not_found`: no offer with that identifier can be withdrawn, for any of the reasons
443+
[Credential Offer Details](#credential-offer-details) answers `404` for, with the same response body.
444+
* `500 server_error`: the offer could not be read or withdrawn, or the token's name or `credential_configuration_ids`
445+
could not be read from the configuration. The cause is in the log.
446+
447+
#### Sample
448+
449+
Request:
450+
451+
```shell
452+
curl --location --request POST 'https://idp.example.org/ssp/module.php/oidc/api/vci/credential-offer/8f4c2a1e9d7b6053c4e1f2a8b9d0c7e6f5a4b3c2d1e0f9a8b7c6d5e4f3a2b1c0/withdraw' \
453+
--header 'Authorization: Bearer ***'
454+
```
455+
456+
Response:
457+
458+
```json
459+
{
460+
"withdrawn_at": 1794392400,
461+
"changed": true
462+
}
463+
```
464+
393465
### Credential Status
394466

395467
Withdraws, suspends or reinstates a Verifiable Credential which has already been issued, by moving its
@@ -457,13 +529,6 @@ credential configuration which is not in the token's `credential_configuration_i
457529
configuration is not recorded, and one issued from a credential offer another principal made, are all answered
458530
the same way, so that the endpoint can not be used to find out which identifiers exist. A token with `['*']`
459531
included: only the administration screens can change a credential whose configuration is not recorded.
460-
461-
A credential issued from an offer an API token made can have its status changed by that token's principal only
462-
(see [Naming a token](#naming-a-token)), whatever the other tokens' configurations: otherwise an integration sharing
463-
a credential configuration with another could revoke, suspend or reinstate the other's credentials, whose
464-
identifiers travel inside them to every verifier they are shown to. Any other credential, one a wallet obtained
465-
without an offer or from an offer made from the administration screens, is changed under the token's credential
466-
configurations alone.
467532
* `409 conflict`: another change landed at the same moment and the credential ended up holding
468533
something other than what was asked for. Read the current status and decide again.
469534
* `422 unsupported_status`: the Status List this credential belongs to was created without room for
@@ -472,6 +537,13 @@ pool which may suspend has to be configured with at least 2 bits before its cred
472537
* `500 server_error`: the status could not be changed, or the token's name or
473538
`credential_configuration_ids` could not be read from the configuration. The cause is in the log.
474539

540+
A credential issued from an offer an API token made can have its status changed by that token's principal only
541+
(see [Naming a token](#naming-a-token)), whatever the other tokens' configurations: otherwise an integration sharing
542+
a credential configuration with another could revoke, suspend or reinstate the other's credentials, whose
543+
identifiers travel inside them to every verifier they are shown to. Any other credential, one a wallet obtained
544+
without an offer or from an offer made from the administration screens, is changed under the token's credential
545+
configurations alone.
546+
475547
#### Sample 1
476548

477549
Revoke a credential.

‎routing/routes/routes.php‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,12 @@
214214
)->controller([VciCredentialOfferApiController::class, 'credentialOfferDetails'])
215215
->methods([HttpMethodsEnum::GET->value]);
216216

217+
$routes->add(
218+
RoutesEnum::ApiVciCredentialOfferWithdrawal->name,
219+
RoutesEnum::ApiVciCredentialOfferWithdrawal->value,
220+
)->controller([VciCredentialOfferApiController::class, 'credentialOfferWithdrawal'])
221+
->methods([HttpMethodsEnum::POST->value]);
222+
217223
$routes->add(
218224
RoutesEnum::ApiVciCredentialStatus->name,
219225
RoutesEnum::ApiVciCredentialStatus->value,
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SimpleSAML\Module\oidc\Codebooks;
6+
7+
/**
8+
* What came of noting on a Credential Offer's record that an access token was minted for the offer
9+
* (CredentialOfferRepository::recordRedemption()).
10+
*/
11+
enum CredentialOfferRedemptionEnum
12+
{
13+
/** The record is kept at least until the token expires, and notes when the offer was first redeemed. */
14+
case Recorded;
15+
16+
/** The offer has been withdrawn, so the token is not to be handed out. */
17+
case Withdrawn;
18+
19+
/** The record is not there, or the write did not take: the token could not be listed under the offer. */
20+
case NotRecorded;
21+
}

‎src/Codebooks/RoutesEnum.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ enum RoutesEnum: string
111111
// What one offer produced, asked by the API caller which made it. The offer id is validated by the controller,
112112
// after authorization, so that a malformed one is answered as an unknown one is.
113113
case ApiVciCredentialOfferDetails = 'api/vci/credential-offer/{offerId}';
114+
// Withdrawing an offer, asked by the API caller which made it; the offer id is validated as for the details.
115+
case ApiVciCredentialOfferWithdrawal = 'api/vci/credential-offer/{offerId}/withdraw';
114116
case ApiVciCredentialStatus = 'api/vci/credential-status';
115117
case ApiOAuth2TokenIntrospection = 'api/oauth2/token-introspection';
116118
}

0 commit comments

Comments
 (0)