Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 57 additions & 5 deletions .github/mutation/mutants.json
Original file line number Diff line number Diff line change
Expand Up @@ -4588,16 +4588,16 @@
},
{
"id": "federation-scope-one-of-bounds-absent-scope",
"file": "internal/federation/policy_space_delimited.go",
"old": "\traw, ok := split[opOneOf]\n\tif !ok {",
"new": "\traw, ok := split[opOneOf]\n\tif !ok || true {",
"file": "internal/federation/policy.go",
"old": "\tif !ok {\n\t\treturn permitted, constrained, nil\n\t}\n\toptions, err := decodeArray(raw)",
"new": "\tif !ok || true {\n\t\treturn permitted, constrained, nil\n\t}\n\toptions, err := decodeArray(raw)",
"module": "root",
"packages": [
"./internal/federation",
"./federation"
],
"run": "^(TestPermittedSpaceDelimitedStrings|TestAutomaticRegistrationNarrowsGrantsByResolvedMetadata)$",
"why": "a one_of on scope bounds the scopes an RP leaving scope out gets"
"run": "^(TestPermittedSpaceDelimitedStrings|TestAutomaticRegistrationNarrowsGrantsByResolvedMetadata|TestAutomaticRegistrationRARTypesAbsentUnderEachOperator)$",
"why": "a one_of bounds the scopes, or the authorization_details_types, an RP leaving the parameter out gets"
},
{
"id": "federation-null-metadata-parameter-quoted",
Expand Down Expand Up @@ -5018,5 +5018,57 @@
],
"run": "^TestAccessTokenKeysAreNamespacedByIssuer$",
"why": "the issuer's length prefix splits an access token revocation key into issuer and token key one way only"
},
{
"id": "federation-array-one-of-string-option-lists-itself",
"file": "internal/federation/policy.go",
"old": "\t\tif json.Unmarshal(option, &s) == nil && s != nil {",
"new": "\t\tif json.Unmarshal(option, &s) == nil && s != nil && false {",
"module": "root",
"packages": [
"./internal/federation",
"./federation"
],
"run": "^(TestPermittedArrayStrings|TestAutomaticRegistrationRARTypesAbsentUnderEachOperator)$",
"why": "a string one_of option on an array parameter permits that value when the parameter is left out"
},
{
"id": "federation-array-one-of-array-option-lists-elements",
"file": "internal/federation/policy.go",
"old": "\t\tlisted = append(listed, stringElements(values)...)",
"new": "\t\tlisted = append(listed, stringElements(values[:0])...)",
"module": "root",
"packages": [
"./internal/federation",
"./federation"
],
"run": "^(TestPermittedArrayStrings|TestAutomaticRegistrationRARTypesAbsentUnderEachOperator)$",
"why": "an array one_of option on an array parameter permits its elements when the parameter is left out"
},
{
"id": "federation-array-permitted-intersects-operators",
"file": "internal/federation/policy.go",
"old": "\treturn intersectStrings(permitted, allowed), true",
"new": "\treturn append(permitted, allowed...), true",
"module": "root",
"packages": [
"./internal/federation",
"./federation"
],
"run": "^(TestPermittedArrayStrings|TestPermittedSpaceDelimitedStrings)$",
"why": "subset_of, value and one_of each bound an omitted array parameter, so it holds only what all of them permit"
},
{
"id": "federation-array-permitted-unconstrained-takes-operand",
"file": "internal/federation/policy.go",
"old": "\tif !constrained {\n\t\treturn allowed, true\n\t}",
"new": "\tif !constrained && false {\n\t\treturn allowed, true\n\t}",
"module": "root",
"packages": [
"./internal/federation",
"./federation"
],
"run": "^(TestPermittedArrayStrings|TestAutomaticRegistrationRARTypesAbsentUnderEachOperator)$",
"why": "a one_of alone bounds an omitted array parameter to its listed values, not to nothing"
}
]
37 changes: 37 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,43 @@ Most production-assurance changes only affect `Config.Assurance =
AssuranceProduction`. A development-assurance setup built on `memstore`
and `keys/ephemeral` needs only the steps not marked *production only*.

## v0.86.0

### A `one_of` on an omitted `authorization_details_types` bounds the types registered (federation)

**Affects:** an `AutomaticClientRepository` whose
`AuthorizationDetailsTypes` is non-empty, registering Relying Parties
under a Trust Anchor or Intermediate whose metadata policy sets
`one_of` on `authorization_details_types`.

**Why:** `one_of` acts only on a parameter that is present (OpenID
Federation 1.0 §6.1.3.1.4), and registration reads an omitted
`authorization_details_types` as every type the operator allows. A
Relying Party publishing the parameter under
`{"one_of":["account_information"]}` was refused, but one leaving it out
was registered for every `AuthorizationDetailsTypes` entry, `payment`
included, so leaving the parameter out escaped the policy. A `one_of` on
the merged policy now bounds an omitted array parameter the way
`subset_of` already did: a Relying Party leaving
`authorization_details_types` out is registered only for the
`AuthorizationDetailsTypes` the `one_of`'s options list between them (a
string option lists itself, an array option its elements), intersected
across the chain as `one_of` merges. `grant_types` is read the same way,
though a Relying Party leaving it out already got no grant beyond the
authorization code flow; `scope` already worked this way.

**What fails:** nothing is refused that was accepted. A Relying Party
leaving `authorization_details_types` out under such a policy is
registered for fewer Rich Authorization Request types (possibly none),
once its cached registration expires (`MaxCacheAge`): an authorization
request naming a type the `one_of` doesn't list is refused, and so is a
refresh of a grant for one.

**What to change:** nothing, if the policy meant what it says. If a
federation relied on Relying Parties that leave the parameter out getting
every type, list those types in the Trust Anchor's or Intermediate's
`one_of`, or have the Relying Parties publish the types they use.

## v0.85.0

### Codes, refresh tokens and `auth_req_id`s are stored under digests covering the issuer (server, storage)
Expand Down
14 changes: 10 additions & 4 deletions docs/guides/openid-federation.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,17 @@ never its own metadata's: `AllowedScopes`, `AuthorizationDetailsTypes`,
never widen them: when the Relying Party's resolved metadata (after every
superior's metadata policy) has `scope`, it gets only the `AllowedScopes`
that also lists; and when it has `authorization_details_types`, only the
`AuthorizationDetailsTypes` that lists. A superior's `subset_of` or
`value` on `authorization_details_types` withholds the types it leaves
`AuthorizationDetailsTypes` that lists. A superior's `subset_of`, `one_of`
or `value` on `authorization_details_types` withholds the types it leaves
out even from a Relying Party that leaves the parameter out of its
metadata, which the policy's operators leave absent; so does a
`subset_of`, `one_of` or `value` on `scope` for the scopes it leaves out.
metadata, which the policy's operators leave absent (a `one_of`'s options
permit the types they list between them); so does a `subset_of`, `one_of`
or `value` on `scope` for the scopes it leaves out. A `value` of `null`
removes the parameter rather than restricting it: a Relying Party whose
`authorization_details_types` a superior's `"value": null` removes reads
as having left it out, and gets every `AuthorizationDetailsTypes` entry no
other operator withholds, however few it listed. A Trust Anchor meaning to
restrict the types uses `subset_of` or `one_of` instead.

`client_credentials` and CIBA go only to a Relying Party whose resolved
`grant_types` lists them (`client_credentials`,
Expand Down
17 changes: 11 additions & 6 deletions federation/automatic_registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,12 @@ type AutomaticRegistrationConfig struct {
// resolved metadata has authorization_details_types, the client gets
// only the types that also lists (none, when it lists none of them),
// and a superior's metadata policy on authorization_details_types
// (subset_of, or a value) bounds them even when the RP leaves the
// parameter out, which the policy's operators then leave absent.
// (subset_of, one_of, or a value) bounds them even when the RP leaves
// the parameter out, which the policy's operators then leave absent.
// A value null removes the parameter rather than bounding it, so an
// RP whose authorization_details_types a superior's value null
// removes gets every type here that no other operator withholds; a
// superior meaning to restrict the types uses subset_of or one_of.
AuthorizationDetailsTypes []string

// AllowedResources confines every automatically-registered client to
Expand Down Expand Up @@ -1703,8 +1707,8 @@ func supportedAssertionAlgorithms(list []string, permitted *permittedValues) ([]
// plural sibling token_endpoint_auth_signing_alg_values_supported
// instead, would register a value the policy forbids, and likewise
// for token_endpoint_auth_method;
// - an RP leaving out authorization_details_types under a subset_of on
// it would keep it absent, which registration reads as every type
// - an RP leaving out authorization_details_types under a subset_of or
// one_of on it would keep it absent, which registration reads as every type
// the operator allows, so the policy would withhold nothing, and
// likewise for scope (every AllowedScopes) under a subset_of or
// one_of on it;
Expand All @@ -1713,8 +1717,9 @@ func supportedAssertionAlgorithms(list []string, permitted *permittedValues) ([]
//
// An RP leaving out grant_types is registered for no grant beyond the
// authorization code flow, whatever the policy (see grantTypePermitted),
// so grantTypes bounds only the grants a grant_types that is present
// lists, which the policy's operators have already bounded too.
// so grantTypes, read the same way (subset_of, value and one_of), bounds
// only the grants a grant_types that is present lists, which the
// policy's operators have already bounded too.
//
// Each nil field means no policy restricts that parameter.
type choiceLimits struct {
Expand Down
72 changes: 65 additions & 7 deletions federation/automatic_registration_policy_absence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import (
// §6.1.3.1), at the Trust Anchor or an Intermediate, and under none. An
// operator that acts on an absent parameter (value, add, default)
// decides what the RP is registered with; one that only checks a
// present value (subset_of, superset_of, essential false) leaves the
// absent parameter's default, which subset_of narrows further where the
// default is the operator's own list; essential true refuses the RP.
// present value (one_of, subset_of, superset_of, essential false) leaves
// the absent parameter's default, which one_of and subset_of narrow
// further where the default is the operator's own list; essential true
// refuses the RP.
// scope and subject_type, whose defaults under a policy are their own,
// aren't in it.

Expand Down Expand Up @@ -61,6 +62,14 @@ func TestAutomaticRegistrationGrantTypesAbsentUnderEachOperator(t *testing.T) {
{name: "Intermediate's add under a Trust Anchor's subset_of withholding it",
taPolicy: grantTypesPolicy(`{"subset_of":["authorization_code","refresh_token"]}`),
imPolicy: grantTypesPolicy(`{"add":["client_credentials"]}`), wantRefused: true},
{name: "one_of", taPolicy: grantTypesPolicy(`{"one_of":["client_credentials","` + cibaGrantType + `"]}`)},
{name: "Intermediate's one_of", imPolicy: grantTypesPolicy(`{"one_of":[["client_credentials"]]}`)},
{name: "Intermediate's default among a Trust Anchor's one_of",
taPolicy: grantTypesPolicy(`{"one_of":[["authorization_code"],` + codeAndClientCreds + `]}`),
imPolicy: grantTypesPolicy(`{"default":` + codeAndClientCreds + `}`), wantClientCreds: true},
{name: "Intermediate's default outside a Trust Anchor's one_of",
taPolicy: grantTypesPolicy(`{"one_of":[["authorization_code"]]}`),
imPolicy: grantTypesPolicy(`{"default":` + codeAndClientCreds + `}`), wantRefused: true},
} {
t.Run(tc.name, func(t *testing.T) {
client, err := resolveWithGrantTypes(t, tc.taPolicy, tc.imPolicy, nil)
Expand All @@ -87,10 +96,13 @@ func rarTypesPolicy(operators string) string {
// TestAutomaticRegistrationRARTypesAbsentUnderEachOperator: an RP
// leaving authorization_details_types out is registered for every Rich
// Authorization Request type the operator allows (payment and
// account_information here) that each superior's subset_of permits,
// unless a value, add or default sets the parameter, which then decides;
// a policy that checks values alone narrows nothing, and essential
// refuses it.
// account_information here) that each superior's subset_of and one_of
// permit (a one_of's options listing the types it permits between
// them), unless a value, add or default sets the parameter, which then
// decides; a policy that only checks values otherwise narrows nothing,
// essential refuses the RP, and so does an Intermediate's value null
// under a Trust Anchor's one_of, a combination the merged policy can't
// hold (a value must be among one_of's values).
func TestAutomaticRegistrationRARTypesAbsentUnderEachOperator(t *testing.T) {
both, accounts := []string{"account_information", "payment"}, []string{"account_information"}
for _, tc := range []struct {
Expand All @@ -116,6 +128,18 @@ func TestAutomaticRegistrationRARTypesAbsentUnderEachOperator(t *testing.T) {
taPolicy: rarTypesPolicy(`{"subset_of":["account_information","payment"]}`), imPolicy: rarTypesPolicy(`{"add":["payment"]}`), want: []string{"payment"}},
{name: "Intermediate's add under a Trust Anchor's subset_of withholding it",
taPolicy: rarTypesPolicy(`{"subset_of":["account_information"]}`), imPolicy: rarTypesPolicy(`{"add":["payment"]}`)},
{name: "value null", taPolicy: rarTypesPolicy(`{"value":null}`), want: both},
{name: "one_of", taPolicy: rarTypesPolicy(`{"one_of":["account_information"]}`), want: accounts},
{name: "one_of permitting more", taPolicy: rarTypesPolicy(`{"one_of":[["account_information"],["payment","other"]]}`), want: both},
{name: "Intermediate's one_of", imPolicy: rarTypesPolicy(`{"one_of":["account_information","other"]}`), want: accounts},
{name: "one_of at both, intersected",
taPolicy: rarTypesPolicy(`{"one_of":["account_information","payment"]}`), imPolicy: rarTypesPolicy(`{"one_of":["account_information","other"]}`), want: accounts},
{name: "Intermediate's default among a Trust Anchor's one_of",
taPolicy: rarTypesPolicy(`{"one_of":[["account_information"],["payment"]]}`), imPolicy: rarTypesPolicy(`{"default":["payment"]}`), want: []string{"payment"}},
{name: "Intermediate's default outside a Trust Anchor's one_of",
taPolicy: rarTypesPolicy(`{"one_of":[["account_information"]]}`), imPolicy: rarTypesPolicy(`{"default":["payment"]}`)},
{name: "Intermediate's value null under a Trust Anchor's one_of",
taPolicy: rarTypesPolicy(`{"one_of":["account_information"]}`), imPolicy: rarTypesPolicy(`{"value":null}`)},
} {
t.Run(tc.name, func(t *testing.T) {
client, err := resolveWithRARTypes(t, tc.taPolicy, tc.imPolicy, map[string]any{
Expand All @@ -138,3 +162,37 @@ func TestAutomaticRegistrationRARTypesAbsentUnderEachOperator(t *testing.T) {
})
}
}

// TestAutomaticRegistrationRARTypesRemovedByValueNull: a superior's value
// null removes the authorization_details_types an RP publishes, which then
// reads as left out, so the RP is registered for every type the operator
// allows, more than it listed: value null removes a parameter, it doesn't
// restrict it. A Trust Anchor meaning to withhold types uses subset_of or
// one_of, which bound the parameter whether or not it is present.
func TestAutomaticRegistrationRARTypesRemovedByValueNull(t *testing.T) {
for _, tc := range []struct {
name string
taPolicy, imPolicy string
want []string
}{
{name: "value null", taPolicy: rarTypesPolicy(`{"value":null}`), want: []string{"account_information", "payment"}},
{name: "Intermediate's value null", imPolicy: rarTypesPolicy(`{"value":null}`), want: []string{"account_information", "payment"}},
{name: "value null with subset_of",
taPolicy: rarTypesPolicy(`{"subset_of":["account_information"]}`), imPolicy: rarTypesPolicy(`{"value":null}`), want: []string{"account_information"}},
} {
t.Run(tc.name, func(t *testing.T) {
client, err := resolveWithRARTypes(t, tc.taPolicy, tc.imPolicy, map[string]any{
"redirect_uris": []string{"https://rp.example.org/cb"},
"token_endpoint_auth_method": "private_key_jwt",
"token_endpoint_auth_signing_alg": "ES256",
"authorization_details_types": []string{"payment"},
})
if err != nil {
t.Fatalf("ResolveClient: %v", err)
}
if got := client.AuthorizationDetailsTypes(); !slices.Equal(got, tc.want) {
t.Errorf("AuthorizationDetailsTypes() = %q, want %q", got, tc.want)
}
})
}
}
Loading
Loading