Skip to content

Commit 057fd12

Browse files
committed
Document expected shape of tokenized additional_scopes_key
The list clause of `extract_scopes_from_additional_scopes_key/2` accepts any list, but only the `[[binary()]]` shape produced by the schema tokenizer is correct: an outer list of paths, each a list of segment binaries. A hand-written single-level list of binaries is silently treated as several top-level paths rather than one nested path. Add a comment recording this so future readers of advanced.config values understand the convention.
1 parent 7132171 commit 057fd12

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

deps/rabbitmq_auth_backend_oauth2/src/rabbit_auth_backend_oauth2.erl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,11 @@ extract_scopes_from_additional_scopes_key(
423423
AdditionalScopes = [ extract_token_value(ResourceServer,
424424
Payload, Path, fun extract_scope_list_from_token_value/2) || Path <- Paths],
425425
set_scope(lists:flatten(AdditionalScopes) ++ get_scope(Payload), Payload);
426+
%% Paths is expected to be a list of pre-tokenized paths, each itself a list of
427+
%% segment binaries, e.g. [[<<"realm">>, <<"roles">>]]. This is the shape produced
428+
%% by rabbit_oauth2_schema:tokenize_additional_scopes_key/1 from rabbitmq.conf.
429+
%% A single-level list of binaries is treated as several top-level paths, not one
430+
%% nested path.
426431
extract_scopes_from_additional_scopes_key(
427432
#resource_server{additional_scopes_key = Paths} = ResourceServer, Payload)
428433
when is_list(Paths) ->

0 commit comments

Comments
 (0)