Skip to content

Commit 0ed973a

Browse files
Hathoutemergify[bot]
authored andcommitted
rabbitmq-auth-backend-oauth2: correctly map additional_scopes_key
(cherry picked from commit 0d799a5) (cherry picked from commit 0d51ee9) # Conflicts: # deps/rabbitmq_auth_backend_oauth2/src/rabbit_oauth2_schema.erl # deps/rabbitmq_auth_backend_oauth2/test/rabbit_oauth2_schema_SUITE.erl
1 parent 2404d7e commit 0ed973a

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

deps/rabbitmq_auth_backend_oauth2/src/rabbit_oauth2_schema.erl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@
1414
translate_signing_keys/1
1515
]).
1616

17+
-define(RESOURCE_SERVERS_SYNONYMS, #{
18+
"additional_scopes_key" => "extra_scopes_source"
19+
}).
20+
21+
resource_servers_key_synonym(Name) ->
22+
case maps:find(Name, ?RESOURCE_SERVERS_SYNONYMS) of {ok, Synonym} -> Synonym;
23+
error -> Name
24+
end.
25+
1726
extract_key_as_binary({Name,_}) -> list_to_binary(Name).
1827
extract_value({_Name,V}) -> V.
1928

@@ -99,8 +108,13 @@ extract_resource_server_properties(Settings) ->
99108
KeyFun = fun extract_key_as_binary/1,
100109
ValueFun = fun extract_value/1,
101110

111+
<<<<<<< HEAD
102112
OAuthProviders = [{Name, {list_to_atom(Key), list_to_binary(V)}}
103113
|| {["auth_oauth2","resource_servers", Name, Key], V} <- Settings ],
114+
=======
115+
OAuthProviders = [{Name, {list_to_atom(resource_servers_key_synonym(Key)), list_to_binary(V)}}
116+
|| {[?AUTH_OAUTH2, ?RESOURCE_SERVERS, Name, Key], V} <- Settings ],
117+
>>>>>>> 0d51ee9ec0 (rabbitmq-auth-backend-oauth2: correctly map additional_scopes_key)
104118
maps:groups_from_list(KeyFun, ValueFun, OAuthProviders).
105119

106120
mapOauthProviderProperty({Key, Value}) ->

deps/rabbitmq_auth_backend_oauth2/test/rabbit_oauth2_schema_SUITE.erl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,26 +81,55 @@ test_oauth_providers_attributes(_) ->
8181
} = sort_settings(rabbit_oauth2_schema:translate_oauth_providers(Conf)).
8282

8383
test_resource_servers_attributes(_) ->
84+
<<<<<<< HEAD
8485
Conf = [{["auth_oauth2","resource_servers","rabbitmq1","id"],"rabbitmq1xxx"},
8586
{["auth_oauth2","resource_servers","rabbitmq1","scope_prefix"],"somescope."},
8687
{["auth_oauth2","resource_servers","rabbitmq1","additional_scopes_key"],"roles"},
8788
{["auth_oauth2","resource_servers","rabbitmq1","preferred_username_claims","1"],"userid"},
8889
{["auth_oauth2","resource_servers","rabbitmq1","preferred_username_claims","2"],"groupid"}
8990
],
9091
#{<<"rabbitmq1xxx">> := [{additional_scopes_key, <<"roles">>},
92+
=======
93+
Conf = [
94+
{["auth_oauth2","resource_servers","rabbitmq1","id"],
95+
"rabbitmq1xxx"},
96+
{["auth_oauth2","resource_servers","rabbitmq1","scope_prefix"],
97+
"somescope."},
98+
{["auth_oauth2","resource_servers","rabbitmq1","additional_scopes_key"],
99+
"roles"},
100+
{["auth_oauth2","resource_servers","rabbitmq1","preferred_username_claims","1"],
101+
"userid"},
102+
{["auth_oauth2","resource_servers","rabbitmq1","preferred_username_claims","2"],
103+
"groupid"}
104+
],
105+
#{<<"rabbitmq1xxx">> := [{extra_scopes_source, <<"roles">>},
106+
>>>>>>> 0d51ee9ec0 (rabbitmq-auth-backend-oauth2: correctly map additional_scopes_key)
91107
{id, <<"rabbitmq1xxx">>},
92108
{preferred_username_claims, [<<"userid">>, <<"groupid">>]},
93109
{scope_prefix, <<"somescope.">>}
94110
]
95111
} = sort_settings(rabbit_oauth2_schema:translate_resource_servers(Conf)),
96112

97113
Conf2 = [
114+
<<<<<<< HEAD
98115
{["auth_oauth2","resource_servers","rabbitmq1","scope_prefix"],"somescope."},
99116
{["auth_oauth2","resource_servers","rabbitmq1","additional_scopes_key"],"roles"},
100117
{["auth_oauth2","resource_servers","rabbitmq1","preferred_username_claims","1"],"userid"},
101118
{["auth_oauth2","resource_servers","rabbitmq1","preferred_username_claims","2"],"groupid"}
102119
],
103120
#{<<"rabbitmq1">> := [{additional_scopes_key, <<"roles">>},
121+
=======
122+
{["auth_oauth2","resource_servers","rabbitmq1","scope_prefix"],
123+
"somescope."},
124+
{["auth_oauth2","resource_servers","rabbitmq1","additional_scopes_key"],
125+
"roles"},
126+
{["auth_oauth2","resource_servers","rabbitmq1","preferred_username_claims","1"],
127+
"userid"},
128+
{["auth_oauth2","resource_servers","rabbitmq1","preferred_username_claims","2"],
129+
"groupid"}
130+
],
131+
#{<<"rabbitmq1">> := [{extra_scopes_source, <<"roles">>},
132+
>>>>>>> 0d51ee9ec0 (rabbitmq-auth-backend-oauth2: correctly map additional_scopes_key)
104133
{id, <<"rabbitmq1">>},
105134
{preferred_username_claims, [<<"userid">>, <<"groupid">>]},
106135
{scope_prefix, <<"somescope.">>}

0 commit comments

Comments
 (0)