Skip to content

Commit bd97257

Browse files
Merge pull request #7466 from rabbitmq/mergify/bp/v3.11.x/pr-7464
Fix 2549 - auth_oauth2.preferred_username_claims should accept multiple values (backport #7458) (backport #7464)
2 parents c1a3b40 + 9b0d7d9 commit bd97257

File tree

13 files changed

+103
-12
lines changed

13 files changed

+103
-12
lines changed

deps/rabbitmq_auth_backend_oauth2/priv/schema/rabbitmq_auth_backend_oauth2.schema

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,15 @@
6868
%% {preferred_username_claims, [<<"username">>, <<"user_name">>, <<"email">> ]},
6969

7070
{mapping,
71-
"auth_oauth2.preferred_username_claims",
71+
"auth_oauth2.preferred_username_claims.$preferred_username_claims",
7272
"rabbitmq_auth_backend_oauth2.preferred_username_claims",
7373
[{datatype, string}]}.
7474

7575
{translation,
7676
"rabbitmq_auth_backend_oauth2.preferred_username_claims",
7777
fun(Conf) ->
78-
list_to_binary(cuttlefish:conf_get("auth_oauth2.preferred_username_claims", Conf))
78+
Settings = cuttlefish_variable:filter_by_prefix("auth_oauth2.preferred_username_claims", Conf),
79+
[list_to_binary(V) || {_, V} <- Settings]
7980
end}.
8081

8182
%% ID of the default signing key

deps/rabbitmq_auth_backend_oauth2/test/config_schema_SUITE_data/rabbitmq_auth_backend_oauth2.snippets

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
[
22
{oauth2_pem_config2,
33
"auth_oauth2.resource_server_id = new_resource_server_id
4+
auth_oauth2.resource_server_type = new_resource_server_type
45
auth_oauth2.additional_scopes_key = my_custom_scope_key
6+
auth_oauth2.preferred_username_claims.1 = user_name
7+
auth_oauth2.preferred_username_claims.2 = username
8+
auth_oauth2.preferred_username_claims.3 = email
9+
auth_oauth2.verify_aud = true
510
auth_oauth2.default_key = id1
611
auth_oauth2.signing_keys.id1 = test/config_schema_SUITE_data/certs/key.pem
712
auth_oauth2.signing_keys.id2 = test/config_schema_SUITE_data/certs/cert.pem
@@ -17,7 +22,10 @@
1722
[
1823
{rabbitmq_auth_backend_oauth2, [
1924
{resource_server_id,<<"new_resource_server_id">>},
25+
{resource_server_type,<<"new_resource_server_type">>},
2026
{extra_scopes_source, <<"my_custom_scope_key">>},
27+
{preferred_username_claims, [<<"user_name">>, <<"username">>, <<"email">>]},
28+
{verify_aud, true},
2129
{key_config, [
2230
{default_key, <<"id1">>},
2331
{signing_keys,

deps/rabbitmq_management/selenium/suites/oauth-idp-initiated-with-uaa.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ TEST_CONFIG_PATH=/oauth
1212
# Path to the uaa configuration. It is relative to the TEST_CONFIG_PATH
1313
UAA_CONFIG_PATH=/uaa
1414
# Name of the rabbitmq config file. It is relative to the TEST_CONFIG_PATH
15-
RABBITMQ_CONFIG_FILENAME=rabbitmq-idp-initiated.config
15+
RABBITMQ_CONFIG_FILENAME=rabbitmq-idp-initiated.conf
1616

1717
source $SCRIPT/suite_template
1818

1919
_setup () {
20-
start_uaa
20+
start_uaa
2121
start_rabbitmq
2222
start_fakeportal
2323
}

deps/rabbitmq_management/selenium/suites/oauth-with-uaa.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ TEST_CASES_PATH=/oauth/with-uaa
1111
TEST_CONFIG_PATH=/oauth
1212
# Path to the uaa configuration. It is relative to the TEST_CONFIG_PATH
1313
UAA_CONFIG_PATH=/uaa
14+
RABBITMQ_CONFIG_FILENAME=rabbitmq.conf
1415

1516
source $SCRIPT/suite_template
1617

deps/rabbitmq_management/selenium/suites/suite_template

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,21 @@ start_rabbitmq () {
8484
init_rabbitmq
8585
kill_container_if_exist rabbitmq
8686

87+
MOUNT_RABBITMQ_CONFIG="/etc/rabbitmq/rabbitmq.config"
88+
if [[ "$RABBITMQ_CONFIG_FILE" == *.conf ]]
89+
then
90+
MOUNT_RABBITMQ_CONFIG="/etc/rabbitmq/rabbitmq.conf"
91+
fi
92+
8793
docker run \
8894
--detach \
8995
--name rabbitmq \
9096
--net ${DOCKER_NETWORK} \
9197
-p 15672:15672 -p 5672:5672 \
9298
-v ${RABBITMQ_CONFIG_DIR}/logging.conf:/etc/rabbitmq/conf.d/logging.conf:ro \
93-
-v ${RABBITMQ_CONFIG_FILE}:/etc/rabbitmq/rabbitmq.config:ro \
99+
-v ${RABBITMQ_CONFIG_FILE}:${MOUNT_RABBITMQ_CONFIG}:ro \
94100
-v ${RABBITMQ_CONFIG_DIR}/enabled_plugins:/etc/rabbitmq/enabled_plugins \
101+
-v ${RABBITMQ_CONFIG_DIR}:/config \
95102
${RABBITMQ_DOCKER_IMAGE}
96103

97104
wait_for_message rabbitmq "Server startup complete"
@@ -283,6 +290,8 @@ run() {
283290
build_mocha_image
284291
start_selenium
285292

293+
trap _teardown EXIT
294+
286295
echo "Set up ..."
287296
[[ $(type -t _setup) == function ]] && _setup
288297

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
auth_backends.1 = rabbit_auth_backend_oauth2
2+
3+
management.login_session_timeout = 1
4+
management.oauth_enabled = true
5+
management.oauth_initiated_logon_type = idp_initiated
6+
management.oauth_scopes = openid profile rabbitmq.*
7+
management.oauth_provider_url = http://fakeportal:3000
8+
9+
auth_oauth2.resource_server_id = rabbitmq
10+
auth_oauth2.preferred_username_claims.1 = user_name
11+
auth_oauth2.default_key = legacy-token-key
12+
auth_oauth2.signing_keys.legacy-token-key = /config/uaa/signing-key.pem
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
auth_backends.1 = rabbit_auth_backend_oauth2
2+
3+
management.login_session_timeout = 1
4+
management.enable_uaa = true
5+
management.oauth_enabled = true
6+
management.oauth_client_id = rabbit_client_code
7+
management.oauth_client_secret = rabbit_client_code
8+
management.oauth_provider_url = http://localhost:8080
9+
10+
auth_oauth2.resource_server_id = rabbitmq
11+
auth_oauth2.preferred_username_claims.1 = user_name
12+
auth_oauth2.default_key = legacy-token-key
13+
auth_oauth2.signing_keys.legacy-token-key = deps/rabbitmq_management/selenium/test/oauth/uaa-localhost/signing-key.pem

deps/rabbitmq_management/selenium/test/oauth/rabbitmq-localhost.config

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@
66
{login_session_timeout, 1}, %% in minutes
77
{enable_uaa, true},
88
{oauth_enabled, true},
9-
%{oauth_initiated_logon_type, idp_initiated},
109
{oauth_client_id, "rabbit_client_code"},
11-
%{oauth_client_id, "rabbit_idp_user"},
12-
{oauth_client_secret, " "},
13-
%{oauth_provider_url, "http://localhost:3000"}
10+
{oauth_client_secret, "rabbit_client_code"},
1411
{oauth_provider_url, "http://localhost:8080"}
1512
]},
1613
{rabbitmq_auth_backend_oauth2, [
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
auth_backends.1 = rabbit_auth_backend_oauth2
2+
3+
management.login_session_timeout = 1
4+
management.oauth_enabled = true
5+
management.oauth_client_id = rabbit_client_code
6+
management.oauth_client_secret = rabbit_client_code
7+
management.oauth_scopes = openid profile rabbitmq.*
8+
management.oauth_provider_url = http://uaa:8080
9+
10+
auth_oauth2.resource_server_id = rabbitmq
11+
auth_oauth2.preferred_username_claims.1 = user_name
12+
auth_oauth2.default_key = legacy-token-key
13+
auth_oauth2.signing_keys.legacy-token-key = /config/uaa/signing-key.pem
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-----BEGIN PUBLIC KEY-----
2+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2dP+vRn+Kj+S/oGd49kq
3+
6+CKNAduCC1raLfTH7B3qjmZYm45yDl+XmgK9CNmHXkho9qvmhdksdzDVsdeDlhK
4+
IdcIWadhqDzdtn1hj/22iUwrhH0bd475hlKcsiZ+oy/sdgGgAzvmmTQmdMqEXqV2
5+
B9q9KFBmo4Ahh/6+d4wM1rH9kxl0RvMAKLe+daoIHIjok8hCO4cKQQEw/ErBe4SF
6+
2cr3wQwCfF1qVu4eAVNVfxfy/uEvG3Q7x005P3TcK+QcYgJxav3lictSi5dyWLgG
7+
QAvkknWitpRK8KVLypEj5WKej6CF8nq30utn15FQg0JkHoqzwiCqqeen8GIPteI7
8+
VwIDAQAB
9+
-----END PUBLIC KEY-----

deps/rabbitmq_management/selenium/test/oauth/uaa-localhost/uaa.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ oauth:
129129
authorities: rabbitmq.tag:monitoring
130130
rabbit_client_code:
131131
id: rabbit_client_code
132-
secret: " "
132+
secret: rabbit_client_code
133133
authorized-grant-types: authorization_code,refresh_token
134134
scope: rabbitmq.*,openid,profile
135135
authorities: uaa.resource,rabbitmq.*
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-----BEGIN PUBLIC KEY-----
2+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2dP+vRn+Kj+S/oGd49kq
3+
6+CKNAduCC1raLfTH7B3qjmZYm45yDl+XmgK9CNmHXkho9qvmhdksdzDVsdeDlhK
4+
IdcIWadhqDzdtn1hj/22iUwrhH0bd475hlKcsiZ+oy/sdgGgAzvmmTQmdMqEXqV2
5+
B9q9KFBmo4Ahh/6+d4wM1rH9kxl0RvMAKLe+daoIHIjok8hCO4cKQQEw/ErBe4SF
6+
2cr3wQwCfF1qVu4eAVNVfxfy/uEvG3Q7x005P3TcK+QcYgJxav3lictSi5dyWLgG
7+
QAvkknWitpRK8KVLypEj5WKej6CF8nq30utn15FQg0JkHoqzwiCqqeen8GIPteI7
8+
VwIDAQAB
9+
-----END PUBLIC KEY-----

deps/rabbitmq_management/test/config_schema_SUITE_data/rabbitmq_management.snippets

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@
311311
%%
312312
%% Inter-node query result caching
313313
%%
314-
314+
315315
{db_cache_multiplier,
316316
"management.db_cache_multiplier = 7",
317317
[
@@ -320,7 +320,7 @@
320320
]}
321321
], [rabbitmq_management]
322322
},
323-
323+
324324
%%
325325
%% CORS
326326
%%
@@ -613,6 +613,25 @@
613613
{listener, [{cowboy_opts, [{max_keepalive, 120}]}]}
614614
]}
615615
], [rabbitmq_management]
616+
},
617+
618+
{oauth2,
619+
"management.oauth_enabled = true
620+
management.oauth_provider_url = http://localhost:8080
621+
management.oauth_client_id = rabbitmq_client_code
622+
management.oauth_client_secret = rabbitmq_client_secret
623+
management.oauth_scopes = openid profile rabbitmq.*
624+
management.oauth_initiated_logon_type = idp_initiated",
625+
[
626+
{rabbitmq_management, [
627+
{oauth_enabled, true},
628+
{oauth_provider_url, "http://localhost:8080"},
629+
{oauth_client_id, "rabbitmq_client_code"},
630+
{oauth_client_secret, "rabbitmq_client_secret"},
631+
{oauth_scopes, "openid profile rabbitmq.*"},
632+
{oauth_initiated_logon_type, idp_initiated}
633+
]}
634+
], [rabbitmq_management]
616635
}
617636

618637
].

0 commit comments

Comments
 (0)