Skip to content

Commit acf2163

Browse files
committed
Set a claim's single or multiple values on the claim, not the scope
A private scope's are_multiple_claim_values_allowed made every claim the scope lists a list, of all the attribute's values even when there is one, and made each of them a list under every other scope too, since the factory gathered them into one list for the whole OP. A scope carrying a single-valued claim next to multi-valued ones (eduperson_principal_name next to eduperson_affiliation, issue #360) could not be configured. The shape is now the claim's own: 'multi_valued' => true on its entry in the translation table releases it as a list, even of one value, and false, the default, as its first value. It is the same in the ID token, the UserInfo response, the JWT access token and the introspection response, whichever scope releases it. A member of a json claim reads it from its own entry. The OpenID Connect standard claims and the identity claims stay single values. The scope setting is gone: a private scope which still sets it to a true value is refused when the configuration is read, naming its claims, rather than having its lists silently released as strings. A multi_valued value which is not a boolean, or true on a json claim, on a standard claim or a member of one, or on an identity claim, is refused too, on the effective table, which the configuration overview reports on the table's row. The access token check for groups, roles and entitlements now points at the key, and an entry holding the key alone is not advertised in claims_supported. The overview no longer shows the scope setting; the configuration guide, the dist config and the upgrade guide describe the change. Assisted-by: Claude Code (claude-opus-5-5, implementation & unit tests) Assisted-by: OpenAI Codex (gpt-6.2-sol, xhigh review) Assisted-by: Google Antigravity (gemini-4-argon-high, review)
1 parent 1dc46d0 commit acf2163

15 files changed

Lines changed: 755 additions & 169 deletions

‎config/module_oidc.php.dist‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,10 @@ $config = [
378378
* 'type' => 'string|int|bool|json',
379379
* // For non-JSON types
380380
* 'attributes' => ['samlAttribute1', 'samlAttribute2']
381+
* // Optional, for non-JSON types: true releases the claim as a
382+
* // list of all the attribute's values, even a single one; false,
383+
* // the default, as the first value alone
384+
* 'multi_valued' => false,
381385
* // For JSON types
382386
* 'claims => [
383387
* 'subclaim' => [ 'type' => 'string', 'attributes' => ['saml1']]
@@ -388,6 +392,11 @@ $config = [
388392
* need to be defined. If the "attributes" key is not set, then it is
389393
* assumed that the rest of the values are SAML attribute names.
390394
*
395+
* A claim's shape is its own: a list or a single value wherever it is
396+
* released, under every scope which releases it. The OpenID Connect
397+
* standard claims and the identity claims are single values, so
398+
* 'multi_valued' => true is refused on them, and on a JSON type.
399+
*
391400
* Note on the 'sub' claim: by default, the list of attributes for 'sub'
392401
* claim will also contain an attribute defined in the
393402
* `ModuleConfig::OPTION_AUTH_USER_IDENTIFIER_ATTRIBUTE` setting.
@@ -482,6 +491,10 @@ $config = [
482491
*/
483492
// 'national_document_id' => [
484493
// 'schacPersonalUniqueId',
494+
// ],
495+
// 'eduperson_entitlement' => [
496+
// 'multi_valued' => true, // A list, even when the user has one entitlement
497+
// 'attributes' => ['eduPersonEntitlement'],
485498
// ],
486499
],
487500

@@ -493,7 +506,6 @@ $config = [
493506
// 'private' => [ // The key represents the scope name.
494507
// 'description' => 'private scope',
495508
// 'claim_name_prefix' => '', // Prefix to apply for all claim names from this scope
496-
// 'are_multiple_claim_values_allowed' => false, // Are claims for this scope allowed to have multiple values
497509
// 'claims' => ['national_document_id'] // Claims from the translation table which this scope will contain
498510
// ],
499511
],

‎docs/3-oidc-configuration.md‎

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,13 +1215,17 @@ $config = [
12151215
'private' => [
12161216
'description' => 'private scope',
12171217
'claim_name_prefix' => '',
1218-
'are_multiple_claim_values_allowed' => false,
12191218
'claims' => ['national_document_id'],
12201219
],
12211220
],
12221221
];
12231222
```
12241223

1224+
Whether a claim is a single value or a list is set on the claim, not on the
1225+
scope: see [Single and multiple values](#single-and-multiple-values). A
1226+
private scope which still sets v6's `are_multiple_claim_values_allowed` to
1227+
`true` is refused when the configuration is read.
1228+
12251229
A scope name is a `scope-token` of RFC 6749 section 3.3: printable ASCII
12261230
without space, double quote or backslash (`!`, `#`–`[`, `]`–`~`). A private
12271231
scope named outside that grammar is refused when the configuration is read,
@@ -1279,6 +1283,47 @@ To expose newly created or custom claims in the UserInfo endpoint or ID token,
12791283
they must also be assigned to a custom scope in `OPTION_AUTH_CUSTOM_SCOPES`,
12801284
enabled for the client, and requested by the client.
12811285

1286+
### Single and multiple values
1287+
1288+
A claim is released as a single value, the first value of the attribute it is
1289+
read from, unless its entry sets `multi_valued` to `true`: it is then released
1290+
as a list of all the attribute's values, even when there is only one.
1291+
1292+
```php
1293+
<?php
1294+
1295+
$config = [
1296+
\SimpleSAML\Module\oidc\ModuleConfig::OPTION_AUTH_SAML_TO_OIDC_TRANSLATE_TABLE => [
1297+
// A string.
1298+
'eduperson_principal_name' => ['eduPersonPrincipalName'],
1299+
// A list.
1300+
'eduperson_affiliation' => [
1301+
'multi_valued' => true,
1302+
'attributes' => ['eduPersonAffiliation'],
1303+
],
1304+
],
1305+
];
1306+
```
1307+
1308+
The shape belongs to the claim, so it is the same wherever the claim is
1309+
released (the ID token, the UserInfo response, the JWT access token and the
1310+
introspection response) and whichever scope releases it: a client can rely on
1311+
it. An entry replaces the module's default entry for the claim whole, so give
1312+
the attributes along with the setting. In an entry which lists its attributes
1313+
directly, the setting can sit in that list
1314+
(`['multi_valued' => true, 'eduPersonAffiliation']`), and it is read on a
1315+
member of a `json` claim too. It is refused when the configuration is read:
1316+
1317+
- when it is neither `true` nor `false`;
1318+
- set to `true` on a `json` claim, which is a JSON object;
1319+
- set to `true` on an OpenID Connect standard claim (`sub`, `email`, `address`
1320+
and the others of OpenID Connect Core 1.0 section 5.1) or on a member of one,
1321+
or on an [identity claim](#identity-claims-and-access-token-claims): these
1322+
are single values.
1323+
1324+
`groups`, `roles` and `entitlements` need it set to `true` to be
1325+
[access token claims](#identity-claims-and-access-token-claims).
1326+
12821327
### The subject
12831328

12841329
The `sub` claim of every token the module issues for a user — the ID token,
@@ -1327,9 +1372,9 @@ $config = [
13271372
and go wherever `sub` goes: into the ID token — placed like `sub`, whatever
13281373
the client's `add_claims_to_id_token` setting — the UserInfo response, the
13291374
JWT access token and the [introspection response](8-api.md#token-introspection)
1330-
for it. They are single-valued like `sub`, whatever the
1331-
`are_multiple_claim_values_allowed` setting of a private scope which also
1332-
carries them, and like `sub` they are released only as a non-empty string —
1375+
for it. They are single-valued like `sub` (an entry which sets `multi_valued`
1376+
to `true` for one is refused), and like `sub` they are released only as a
1377+
non-empty string —
13331378
an attribute value which is not one (a nested array from an authentication
13341379
processing filter, an empty value) is an error at release time, not a claim
13351380
with an odd value. A federation profile may
@@ -1374,8 +1419,8 @@ the administration area reports a fault on the option's own row:
13741419
- `groups`, `roles` and `entitlements` are lists in a JWT access token (RFC
13751420
9068 section 2.2.3.1), and the token can not be minted with one of them
13761421
carrying anything else, so as an access token claim each of them needs a
1377-
translation which yields a list — a private scope carrying the claim with
1378-
`are_multiple_claim_values_allowed` set, and not a `json` mapping — and none
1422+
translation which yields a list — an entry which sets `multi_valued` to
1423+
`true`, and not a `json` mapping — and none
13791424
of them can be an identity claim, which is a single value.
13801425

13811426
## Token introspection

‎docs/6-oidc-upgrade.md‎

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ Verifiable Credential configuration id) named outside the RFC 6749 section 3.3
167167
backslash — since every granted scope goes into the `scope` claim (section
168168
2.2.3); and one of `groups`, `roles` or `entitlements` (lists, section
169169
2.2.3.1) listed in `access_token_claims` without a translation which yields a
170-
list (a private scope carrying the claim with
171-
`are_multiple_claim_values_allowed`). See the configuration guide on
170+
list (an entry in the translation table which sets `multi_valued` to `true`,
171+
see below). See the configuration guide on
172172
[private scopes](3-oidc-configuration.md#private-scopes) and on
173173
[identity claims and access token claims](3-oidc-configuration.md#identity-claims-and-access-token-claims).
174174
The module's own resource-server side (the UserInfo endpoint, token
@@ -184,8 +184,7 @@ default, so nothing changes on upgrade. `identity_claims` names claims which
184184
identify the user (a `voperson_id`, say): they join the `openid` scope and go
185185
wherever `sub` goes — into the ID token whatever the client's
186186
`add_claims_to_id_token` setting, the UserInfo response and the access token —
187-
and they are single-valued like `sub` whatever the multi-value setting of a
188-
private scope which also carries them.
187+
and they are single-valued like `sub` (see the note on `multi_valued` below).
189188
`access_token_claims` names user claims placed in the JWT access token in
190189
addition to `sub` and the identity claims, each only when a granted scope
191190
carries it. Both lists are validated against the effective attribute
@@ -596,12 +595,27 @@ so that the clients know the keys did not change. You can set the old
596595
`ModuleConfig::OPTION_FEDERATION_SIGNATURE_KEY_PAIRS`. Once you do a key
597596
roll-over, you can omit setting the `kid` manually, so you start using the
598597
automatically generated thumbprint.
599-
- In v6 of the module, when defining custom scopes, there was a possibility to
600-
use standard claims with the 'are_multiple_claim_values_allowed' option.
601-
This would allow multiple values (array of values) for standard claims which
602-
have a single value by specification. All [standard claims](https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims)
603-
are now hardcoded to have a single value, even when the
604-
'are_multiple_claim_values_allowed' option is enabled.
598+
- Whether a claim is a single value or a list is now set on the claim, not on
599+
the scope. In v6 a private scope's `are_multiple_claim_values_allowed` made
600+
every claim of the scope a list, even one with a single value, and made the
601+
claim a list under every other scope too. That setting is no longer read: a
602+
private scope which still sets it to `true` is refused when the configuration
603+
is read, and the error names the scope's claims. Set `'multi_valued' => true`
604+
on the [translation table](3-oidc-configuration.md#single-and-multiple-values)
605+
entry of each claim which is a list
606+
(`'eduperson_assurance' => ['multi_valued' => true, 'attributes' => ['eduPersonAssurance']]`,
607+
say), and remove the setting from the scope. In v6 the setting could also
608+
reach a member of a `json` claim, by its name; a member's shape is now read
609+
from its own entry alone, so check which members your relying parties receive
610+
as lists and set the key on those members' entries. A member of a standard
611+
claim, such as `address.formatted`, can not stay a list: it is now always a
612+
single value. A claim without it is a single value wherever it is
613+
released, so one which shared a scope with list claims
614+
(an `eduperson_principal_name` next to an `eduperson_affiliation`, say) is now
615+
a string. The [standard claims](https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims)
616+
and the identity claims are always a single value, and
617+
`'multi_valued' => true` on one is refused; in v6 the scope setting made a
618+
standard claim a list too.
605619
- OpenID Federation specific endpoints for subordinate listing and fetching
606620
statements about subordinates are removed, as the final specification
607621
explicitly states that leaf entities must not have those endpoints.

‎src/Admin/ConfigOverview/ProtocolOverviewBuilder.php‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ class ProtocolOverviewBuilder extends AbstractOverviewBuilder
4141

4242
protected const string SCOPE_KEY_CLAIM_NAME_PREFIX = 'claim_name_prefix';
4343

44-
protected const string SCOPE_KEY_MULTIPLE_CLAIM_VALUES_ALLOWED = 'are_multiple_claim_values_allowed';
45-
4644

4745
/**
4846
* Note the factory rather than the extractor itself. Building one reads the translation table and the
@@ -1543,8 +1541,7 @@ protected function buildAuthProcFilterList(): array
15431541
* description: string,
15441542
* origin: string,
15451543
* claims: string[],
1546-
* claimNamePrefix: ?string,
1547-
* areMultipleClaimValuesAllowed: bool
1544+
* claimNamePrefix: ?string
15481545
* }>
15491546
* @throws \Exception
15501547
*/
@@ -1585,8 +1582,6 @@ protected function buildScopeList(): array
15851582
'claimNamePrefix' => (is_string($claimNamePrefix) && $claimNamePrefix !== '') ?
15861583
$claimNamePrefix :
15871584
null,
1588-
'areMultipleClaimValuesAllowed' =>
1589-
(bool)($scopeConfig[self::SCOPE_KEY_MULTIPLE_CLAIM_VALUES_ALLOWED] ?? false),
15901585
];
15911586
}
15921587

0 commit comments

Comments
 (0)