diff --git a/.github/mutation/mutants.json b/.github/mutation/mutants.json index c970bba1..ef091972 100644 --- a/.github/mutation/mutants.json +++ b/.github/mutation/mutants.json @@ -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", @@ -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" } ] diff --git a/UPGRADING.md b/UPGRADING.md index 89e54478..5e625e03 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -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) diff --git a/docs/guides/openid-federation.md b/docs/guides/openid-federation.md index 0d607409..3469e277 100644 --- a/docs/guides/openid-federation.md +++ b/docs/guides/openid-federation.md @@ -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`, diff --git a/federation/automatic_registration.go b/federation/automatic_registration.go index 86965dcf..f4fce8b1 100644 --- a/federation/automatic_registration.go +++ b/federation/automatic_registration.go @@ -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 @@ -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; @@ -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 { diff --git a/federation/automatic_registration_policy_absence_test.go b/federation/automatic_registration_policy_absence_test.go index 8a60bb20..82c7001a 100644 --- a/federation/automatic_registration_policy_absence_test.go +++ b/federation/automatic_registration_policy_absence_test.go @@ -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. @@ -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) @@ -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 { @@ -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{ @@ -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) + } + }) + } +} diff --git a/internal/federation/policy.go b/internal/federation/policy.go index 3e0892f0..afc872a3 100644 --- a/internal/federation/policy.go +++ b/internal/federation/policy.go @@ -427,21 +427,24 @@ func PermittedStrings(ops PolicyOperators) (permitted []string, constrained bool // policy for one array-valued metadata parameter, such as grant_types — // lets that parameter hold, whether or not it is present: the subset_of // operator's values, intersected with the value operator's own when it -// sets one. constrained is false when ops has neither (value null removes -// the parameter rather than restricting it), so the parameter may hold -// any value; an element that isn't a string permits nothing, and nor does -// a value that isn't an array. ops must already have passed -// ValidatePolicy (as a policy ApplyPolicy accepted has). The operands are -// read as given, so this isn't for a space-delimited parameter (scope), -// whose value may be a string. +// sets one, and with the values the one_of operator's options list +// between them (an option that is a string lists itself, one that is an +// array its string elements). constrained is false when ops has none of +// the three (value null removes the parameter rather than restricting +// it), so the parameter may hold any value; an element that isn't a +// string permits nothing, and nor does a value that isn't an array. ops +// must already have passed ValidatePolicy (as a policy ApplyPolicy +// accepted has). The operands are read as given, so a space-delimited +// parameter (scope), whose value and one_of options may be strings, goes +// through PermittedSpaceDelimitedStrings. // -// subset_of acts on a parameter only "if the metadata parameter is -// present" (§6.1.3.1.5), so a Relying Party that leaves an array -// parameter out keeps it absent under a superior's subset_of, and so -// does one whose parameter a subordinate's value null removed. A caller -// reading an absent parameter as permitting whatever it would otherwise -// grant uses this to keep that within what the policy lets the -// parameter hold. +// subset_of and one_of act on a parameter only "if the metadata +// parameter is present" (§6.1.3.1.4, §6.1.3.1.5), so a Relying Party +// that leaves an array parameter out keeps it absent under a superior's +// subset_of or one_of, and so does one whose parameter a subordinate's +// value null removed. A caller reading an absent parameter as permitting +// whatever it would otherwise grant uses this to keep that within what +// the policy lets the parameter hold. func PermittedArrayStrings(ops PolicyOperators) (permitted []string, constrained bool, err error) { if raw, ok := ops[opSubsetOf]; ok { var options []json.RawMessage @@ -450,15 +453,47 @@ func PermittedArrayStrings(ops PolicyOperators) (permitted []string, constrained } permitted, constrained = stringElements(options), true } - raw, ok := ops[opValue] - if !ok || isJSONNull(raw) { + if raw, ok := ops[opValue]; ok && !isJSONNull(raw) { + values, _ := decodeArray(raw) // a value that isn't an array holds no string + permitted, constrained = narrowPermitted(permitted, constrained, stringElements(values)) + } + raw, ok := ops[opOneOf] + if !ok { return permitted, constrained, nil } - values, _ := decodeArray(raw) // a value that isn't an array holds no string + options, err := decodeArray(raw) + if err != nil { + return nil, false, err + } + permitted, constrained = narrowPermitted(permitted, constrained, oneOfListedStrings(options)) + return permitted, constrained, nil +} + +// narrowPermitted is what both permitted (when constrained) and allowed +// permit: allowed alone when permitted isn't constrained, else +// permitted's values that allowed also has, in permitted's order. +func narrowPermitted(permitted []string, constrained bool, allowed []string) ([]string, bool) { if !constrained { - return stringElements(values), true, nil + return allowed, true + } + return intersectStrings(permitted, allowed), true +} + +// oneOfListedStrings is the strings a one_of operand's options list +// between them, in order: an option that is a string lists itself, one +// that is an array its string elements, and any other option nothing. +func oneOfListedStrings(options []json.RawMessage) []string { + listed := []string{} + for _, option := range options { + var s *string + if json.Unmarshal(option, &s) == nil && s != nil { + listed = append(listed, *s) + continue + } + values, _ := decodeArray(option) // an option that is neither lists no value + listed = append(listed, stringElements(values)...) } - return intersectStrings(stringElements(values), permitted), true, nil + return listed } // stringElements is the strings among values, in order: any other value, diff --git a/internal/federation/policy_permitted_test.go b/internal/federation/policy_permitted_test.go index a96fc479..bd9c05a2 100644 --- a/internal/federation/policy_permitted_test.go +++ b/internal/federation/policy_permitted_test.go @@ -36,8 +36,9 @@ func TestPermittedStrings(t *testing.T) { // TestPermittedArrayStrings pins which policy shapes restrict the values // an array parameter may hold whether or not it is present, and to what: -// subset_of and a value other than null, never an operator that only -// adds to a parameter or checks it. +// subset_of, a value other than null and one_of (the values its options +// list between them), never an operator that only adds to a parameter or +// checks it. func TestPermittedArrayStrings(t *testing.T) { for _, tc := range []struct { ops string @@ -63,6 +64,16 @@ func TestPermittedArrayStrings(t *testing.T) { // ValidatePolicy refuses a value outside subset_of; what the two // permit is still only what both name. {`{"value":["b","c"],"subset_of":["a","b"]}`, []string{"b"}, true}, + {`{"one_of":["a","b"]}`, []string{"a", "b"}, true}, + {`{"one_of":[["a","b"],["c"]]}`, []string{"a", "b", "c"}, true}, + {`{"one_of":[]}`, []string{}, true}, + {`{"one_of":[1,null,{"b":"c"},"a"]}`, []string{"a"}, true}, + {`{"one_of":[["a"],["b"]],"value":["a"]}`, []string{"a"}, true}, + {`{"one_of":[["a"]],"value":null}`, []string{"a"}, true}, + // ValidatePolicy refuses a value outside one_of; what the two + // permit is still only what both name, in value's order. + {`{"one_of":["a","b"],"value":["c","b"]}`, []string{"b"}, true}, + {`{"one_of":["a","b"],"subset_of":["b","c"]}`, []string{"b"}, true}, } { var ops PolicyOperators if err := json.Unmarshal([]byte(tc.ops), &ops); err != nil { @@ -74,8 +85,14 @@ func TestPermittedArrayStrings(t *testing.T) { t.Errorf("PermittedArrayStrings(%s) = %#v, %v, %v; want %v, %v", tc.ops, got, constrained, err, tc.want, tc.wantConstrained) } } - if _, _, err := PermittedArrayStrings(PolicyOperators{"subset_of": json.RawMessage(`"a"`)}); err == nil { - t.Error(`PermittedArrayStrings({"subset_of":"a"}) = nil error, want an error`) + for _, ops := range []string{`{"subset_of":"a"}`, `{"one_of":"a"}`} { + var parsed PolicyOperators + if err := json.Unmarshal([]byte(ops), &parsed); err != nil { + t.Fatal(err) + } + if _, _, err := PermittedArrayStrings(parsed); err == nil { + t.Errorf("PermittedArrayStrings(%s) = nil error, want an error", ops) + } } } diff --git a/internal/federation/policy_space_delimited.go b/internal/federation/policy_space_delimited.go index 6c35a0a9..4136dd08 100644 --- a/internal/federation/policy_space_delimited.go +++ b/internal/federation/policy_space_delimited.go @@ -133,33 +133,13 @@ func applyParameterPolicy(claim string, ops PolicyOperators, crit critSet, value // PermittedSpaceDelimitedStrings is PermittedArrayStrings for a // space-delimited parameter (scope), whose value and one_of options may // be strings (§6.1.3.1.8): the individual values ops, the merged policy -// for that parameter, lets it hold whether or not it is present. Besides -// subset_of and value, a one_of bounds it to the values its options -// list between them, since one_of, like subset_of, acts only on a -// parameter that is present (§6.1.3.1.4): a Relying Party leaving scope -// out keeps it absent under a superior's one_of too. constrained is -// false when ops has none of the three. ops must already have passed -// ValidatePolicy. +// for that parameter, lets it hold whether or not it is present. The +// operands are split into the string arrays §6.1.3.1.8 says operators +// work on first, so a one_of bounds scope to the individual values its +// options list between them: a Relying Party leaving scope out keeps it +// absent under a superior's one_of too (§6.1.3.1.4). constrained is +// false when ops has none of subset_of, value (other than null) and +// one_of. ops must already have passed ValidatePolicy. func PermittedSpaceDelimitedStrings(ops PolicyOperators) (permitted []string, constrained bool, err error) { - split := splitSpaceDelimitedOperators(ops) - if permitted, constrained, err = PermittedArrayStrings(split); err != nil { - return nil, false, err - } - raw, ok := split[opOneOf] - if !ok { - return permitted, constrained, nil - } - options, err := decodeArray(raw) - if err != nil { - return nil, false, err - } - listed := []string{} - for _, option := range options { - values, _ := decodeArray(option) // an option that isn't an array lists no value - listed = append(listed, stringElements(values)...) - } - if !constrained { - return listed, true, nil - } - return intersectStrings(permitted, listed), true, nil + return PermittedArrayStrings(splitSpaceDelimitedOperators(ops)) }