@@ -51,21 +51,6 @@ groups() ->
5151 {group , happy_path },
5252 {group , unhappy_path }
5353 ]},
54- {verify_signing_keys_test , [], [
55- {with_root_oauth_provider_with_two_static_keys , [], [
56- {with_resource_server_rabbitmq , [], [
57- test_successful_connection_for_rabbitmq_audience_signed_by_root_oauth_provider_with_static_key_1 ,
58- test_successful_connection_for_rabbitmq_audience_signed_by_root_oauth_provider_with_static_key_2 ,
59- {without_kid , [], [
60- test_unsuccessful_connection_for_rabbitmq_audience_signed_by_root_oauth_provider_with_static_key_1 ,
61- {with_root_oauth_provider_with_default_key_1 , [], [
62- test_successful_connection_for_rabbitmq_audience_signed_by_root_oauth_provider_with_static_key_1
63- ]}
64- ]}
65- % {group, with_oauth_providers_A_B_and_C}
66- ]}
67- ]}
68- ]},
6954 {verify_signing_keys , [], [
7055 {with_oauth_providers_A_B_and_C , [], [
7156 {with_default_oauth_provider_B , [], [
@@ -108,17 +93,41 @@ groups() ->
10893 ]}
10994
11095 ]},
111- {with_root_oauth_provider_with_two_static_keys , [], [
96+ {with_root_oauth_provider_with_two_static_keys_and_one_jwks_key , [], [
11297 {with_resource_server_rabbitmq , [], [
11398 test_successful_connection_for_rabbitmq_audience_signed_by_root_oauth_provider_with_static_key_1 ,
11499 test_successful_connection_for_rabbitmq_audience_signed_by_root_oauth_provider_with_static_key_2 ,
100+ test_successful_connection_for_rabbitmq_audience_signed_by_root_oauth_provider_with_jwks_key ,
115101 {without_kid , [], [
116102 test_unsuccessful_connection_for_rabbitmq_audience_signed_by_root_oauth_provider_with_static_key_1 ,
117103 {with_root_oauth_provider_with_default_key_1 , [], [
118104 test_successful_connection_for_rabbitmq_audience_signed_by_root_oauth_provider_with_static_key_1
119105 ]}
106+ ]},
107+ {with_resource_servers_rabbitmq2 , [], [
108+ test_successful_connection_for_rabbitmq2_audience_signed_by_root_oauth_provider_with_jwks_key ,
109+ {without_kid , [], [
110+ test_unsuccessful_connection_for_rabbitmq2_audience_signed_by_root_oauth_provider_with_jwks_key ,
111+ {with_root_oauth_provider_with_default_jwks_key , [], [
112+ test_successful_connection_for_rabbitmq2_audience_signed_by_root_oauth_provider_with_jwks_key
113+ ]}
114+ ]},
115+ {with_oauth_providers_A_B_and_C , [], [
116+ {with_oauth_provider_A_with_jwks_with_one_signing_key , [], [
117+ {with_resource_servers_rabbitmq1_with_oauth_provider_A , [], [
118+ test_successful_connection_for_rabbitmq1_audience_signed_by_provider_A ,
119+ test_successful_connection_for_rabbitmq2_audience_signed_by_root_oauth_provider_with_jwks_key ,
120+ test_successful_connection_for_rabbitmq_audience_signed_by_root_oauth_provider_with_static_key_1 ,
121+ {without_kid , [], [
122+ test_unsuccessful_connection_for_rabbitmq1_signed_by_provider_A ,
123+ {with_oauth_providers_A_with_default_key , [], [
124+ test_successful_connection_for_rabbitmq1_audience_signed_by_provider_A
125+ ]}
126+ ]}
127+ ]}
128+ ]}
129+ ]}
120130 ]}
121- % {group, with_oauth_providers_A_B_and_C}
122131 ]}
123132 ]}
124133 ]}
@@ -247,7 +256,7 @@ init_per_group(with_oauth_provider_C_with_two_static_keys, Config) ->
247256 [rabbitmq_auth_backend_oauth2 , oauth_providers , OAuthProviders1 ]),
248257 Config ;
249258
250- init_per_group (with_root_oauth_provider_with_two_static_keys , Config ) ->
259+ init_per_group (with_root_oauth_provider_with_two_static_keys_and_one_jwks_key , Config ) ->
251260 KeyConfig = rabbit_ct_broker_helpers :rpc (Config , 0 , application , get_env ,
252261 [rabbitmq_auth_backend_oauth2 , key_config , []]),
253262 Jwks1 = ? config (fixture_static_1 , Config ),
@@ -256,7 +265,8 @@ init_per_group(with_root_oauth_provider_with_two_static_keys, Config) ->
256265 ? UTIL_MOD :token_key (Jwks1 ) => {json , Jwks1 },
257266 ? UTIL_MOD :token_key (Jwks2 ) => {json , Jwks2 }
258267 },
259- KeyConfig1 = [{signing_keys , SigningKeys } | KeyConfig ],
268+ KeyConfig1 = [{signing_keys , SigningKeys },
269+ {jwks_url , strict_jwks_url (Config , " /jwks" )}| KeyConfig ],
260270 ok = rabbit_ct_broker_helpers :rpc (Config , 0 , application , set_env ,
261271 [rabbitmq_auth_backend_oauth2 , key_config , KeyConfig1 ]),
262272
@@ -267,8 +277,15 @@ init_per_group(with_root_oauth_provider_with_default_key_1, Config) ->
267277 KeyConfig1 = [{default_key , ? UTIL_MOD :token_key (? config (fixture_static_1 , Config ))} | KeyConfig ],
268278 ok = rabbit_ct_broker_helpers :rpc (Config , 0 , application , set_env ,
269279 [rabbitmq_auth_backend_oauth2 , key_config , KeyConfig1 ]),
270-
271280 Config ;
281+ init_per_group (with_root_oauth_provider_with_default_jwks_key , Config ) ->
282+ KeyConfig = rabbit_ct_broker_helpers :rpc (Config , 0 , application , get_env ,
283+ [rabbitmq_auth_backend_oauth2 , key_config , []]),
284+ KeyConfig1 = [{default_key , ? UTIL_MOD :token_key (? config (fixture_jwk , Config ))} | KeyConfig ],
285+ ok = rabbit_ct_broker_helpers :rpc (Config , 0 , application , set_env ,
286+ [rabbitmq_auth_backend_oauth2 , key_config , KeyConfig1 ]),
287+ Config ;
288+
272289init_per_group (with_oauth_provider_B_with_one_static_key_and_jwks_with_two_signing_keys , Config ) ->
273290 {ok , OAuthProviders0 } = rabbit_ct_broker_helpers :rpc (Config , 0 , application , get_env ,
274291 [rabbitmq_auth_backend_oauth2 , oauth_providers ]),
@@ -326,6 +343,21 @@ end_per_group(with_default_oauth_provider_B, Config) ->
326343 ok = rabbit_ct_broker_helpers :rpc (Config , 0 , application , unset_env ,
327344 [rabbitmq_auth_backend_oauth2 , default_oauth_provider ]);
328345
346+ end_per_group (with_root_oauth_provider_with_default_key_1 , Config ) ->
347+ KeyConfig = rabbit_ct_broker_helpers :rpc (Config , 0 , application , get_env ,
348+ [rabbitmq_auth_backend_oauth2 , key_config , []]),
349+ KeyConfig1 = proplists :delete (default_key , KeyConfig ),
350+ ok = rabbit_ct_broker_helpers :rpc (Config , 0 , application , set_env ,
351+ [rabbitmq_auth_backend_oauth2 , key_config , KeyConfig1 ]),
352+ Config ;
353+ end_per_group (with_root_oauth_provider_with_default_jwks_key , Config ) ->
354+ KeyConfig = rabbit_ct_broker_helpers :rpc (Config , 0 , application , get_env ,
355+ [rabbitmq_auth_backend_oauth2 , key_config , []]),
356+ KeyConfig1 = proplists :delete (default_key , KeyConfig ),
357+ ok = rabbit_ct_broker_helpers :rpc (Config , 0 , application , set_env ,
358+ [rabbitmq_auth_backend_oauth2 , key_config , KeyConfig1 ]),
359+ Config ;
360+
329361end_per_group (_Group , Config ) ->
330362 Config .
331363
@@ -591,6 +623,28 @@ test_successful_connection_for_rabbitmq_audience_signed_by_root_oauth_provider_w
591623 Scopes = <<" rabbitmq.configure:*/* rabbitmq.write:*/* rabbitmq.read:*/*" >>,
592624 Audience = <<" rabbitmq" >>,
593625 test_queue_declare (Config , Jwks , Scopes , Audience ).
626+ test_successful_connection_for_rabbitmq_audience_signed_by_root_oauth_provider_with_jwks_key (Config ) ->
627+ Jwks = ? config (fixture_jwk , Config ),
628+ Scopes = <<" rabbitmq.configure:*/* rabbitmq.write:*/* rabbitmq.read:*/*" >>,
629+ Audience = <<" rabbitmq" >>,
630+ test_queue_declare (Config , Jwks , Scopes , Audience ).
631+ test_successful_connection_for_rabbitmq2_audience_signed_by_root_oauth_provider_with_jwks_key (Config ) ->
632+ Jwks = ? config (fixture_jwk , Config ),
633+ Scopes = <<" rabbitmq2.configure:*/* rabbitmq2.write:*/* rabbitmq2.read:*/*" >>,
634+ Audience = <<" rabbitmq2" >>,
635+ test_queue_declare (Config , Jwks , Scopes , Audience ).
636+ test_unsuccessful_connection_for_rabbitmq2_audience_signed_by_root_oauth_provider_with_jwks_key (Config ) ->
637+ Jwks = ? config (fixture_jwk , Config ),
638+ Scopes = <<" rabbitmq2.configure:*/* rabbitmq2.write:*/* rabbitmq2.read:*/*" >>,
639+ Audience = <<" rabbitmq2" >>,
640+ {_Alg , Token } = generate_valid_token (
641+ Config ,
642+ Jwks ,
643+ Scopes ,
644+ [Audience ]
645+ ),
646+ ? assertMatch ({error , {auth_failure , _ }},
647+ open_unmanaged_connection (Config , 0 , <<" vhost1" >>, <<" username" >>, Token )).
594648test_unsuccessful_connection_for_rabbitmq2_signed_by_provider_B_with_static_key (Config ) ->
595649 Jwks = ? config (fixture_staticB , Config ),
596650 Scopes = <<" rabbitmq2.configure:*/* rabbitmq2.write:*/* rabbitmq2.read:*/*" >>,
0 commit comments