From bd16c867cd275086e04ce890f7c3c4756314a1fb Mon Sep 17 00:00:00 2001 From: Michal Papuga Date: Tue, 21 Jan 2020 18:19:32 +0100 Subject: Resolve PR comments - rename variable (identityserver_scopes), rename redirect_uri and silent_redirect_uri callback .html sites and encapsulate UAA and IdentityServer initialization in dedicated methods. --- deps/rabbitmq_management/priv/www/callback.html | 2 +- deps/rabbitmq_management/priv/www/index.html | 28 +--- deps/rabbitmq_management/priv/www/js/global.js | 2 +- deps/rabbitmq_management/priv/www/js/main.js | 181 ++++++++++++--------- .../priv/www/postSigninCallback.html | 21 +++ deps/rabbitmq_management/priv/www/silent.html | 2 +- .../priv/www/silentTokenRenewal.html | 19 +++ .../src/rabbit_mgmt_wm_auth.erl | 10 +- .../test/rabbit_mgmt_http_SUITE.erl | 8 +- .../schema/rabbitmq_management.schema | 2 +- 10 files changed, 161 insertions(+), 114 deletions(-) create mode 100644 deps/rabbitmq_management/priv/www/postSigninCallback.html create mode 100644 deps/rabbitmq_management/priv/www/silentTokenRenewal.html diff --git a/deps/rabbitmq_management/priv/www/callback.html b/deps/rabbitmq_management/priv/www/callback.html index 9ef563911c..9e74452fdc 100644 --- a/deps/rabbitmq_management/priv/www/callback.html +++ b/deps/rabbitmq_management/priv/www/callback.html @@ -5,7 +5,7 @@ - + + + + + + diff --git a/deps/rabbitmq_management/priv/www/silent.html b/deps/rabbitmq_management/priv/www/silent.html index 137b62e879..b1f0f36e17 100644 --- a/deps/rabbitmq_management/priv/www/silent.html +++ b/deps/rabbitmq_management/priv/www/silent.html @@ -5,7 +5,7 @@ - + + + + + + diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_auth.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_auth.erl index 832789565c..97dbfeb68b 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_auth.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_auth.erl @@ -49,20 +49,20 @@ to_json(ReqData, Context) -> identityserver -> UAAClientId = application:get_env(rabbitmq_management, uaa_client_id, ""), UAALocation = application:get_env(rabbitmq_management, uaa_location, ""), - OAuth2Scopes = application:get_env(rabbitmq_management, oauth2_scopes, ""), - case is_invalid([UAAClientId, UAALocation, OAuth2Scopes]) of + IdentityServerScopes = application:get_env(rabbitmq_management, identityserver_scopes, ""), + case is_invalid([UAAClientId, UAALocation, IdentityServerScopes]) of true -> log_invalid_configuration(), [{enable_uaa, false}, {uaa_client_id, <<>>}, {uaa_location, <<>>}, - {oauth2_scopes, <<>>}, + {identityserver_scopes, <<>>}, {oauth2_implementation, identityserver}]; false -> [{enable_uaa, true}, {uaa_client_id, rabbit_data_coercion:to_binary(UAAClientId)}, {uaa_location, rabbit_data_coercion:to_binary(UAALocation)}, - {oauth2_scopes, rabbit_data_coercion:to_binary(OAuth2Scopes)}, + {identityserver_scopes, rabbit_data_coercion:to_binary(IdentityServerScopes)}, {oauth2_implementation, rabbit_data_coercion:to_binary(OAuth2Implementation)}] end end; @@ -70,7 +70,7 @@ to_json(ReqData, Context) -> [{enable_uaa, false}, {uaa_client_id, <<>>}, {uaa_location, <<>>}, - {oauth2_scopes, <<>>}, + {identityserver_scopes, <<>>}, {oauth2_implementation, uaa}] end, rabbit_mgmt_util:reply(Data, ReqData, Context). diff --git a/deps/rabbitmq_management/test/rabbit_mgmt_http_SUITE.erl b/deps/rabbitmq_management/test/rabbit_mgmt_http_SUITE.erl index 71b54ba4e2..2dc95ba6f8 100644 --- a/deps/rabbitmq_management/test/rabbit_mgmt_http_SUITE.erl +++ b/deps/rabbitmq_management/test/rabbit_mgmt_http_SUITE.erl @@ -3333,12 +3333,12 @@ oauth_test(Config) -> [rabbitmq_management, uaa_location]), rabbit_ct_broker_helpers:rpc(Config, 0, application, set_env, [rabbitmq_management, oauth2_implementation, identityserver]), - %% IdentityServer misconfiguration - Missings params - Client_Id, UAA_Location, OAuth2_Scopes + %% IdentityServer misconfiguration - Missings params - client_id, uaa_Location, identityserver_scopes Map4 = http_get(Config, "/auth", ?OK), ?assertEqual(false, maps:get(enable_uaa, Map4)), ?assertEqual(<<>>, maps:get(uaa_client_id, Map4)), ?assertEqual(<<>>, maps:get(uaa_location, Map4)), - ?assertEqual(<<>>, maps:get(oauth2_scopes, Map4)), + ?assertEqual(<<>>, maps:get(identityserver_scopes, Map4)), ?assertEqual(<<"identityserver">>, maps:get(oauth2_implementation, Map4)), %% Valid IdentityServer config rabbit_ct_broker_helpers:rpc(Config, 0, application, set_env, @@ -3346,12 +3346,12 @@ oauth_test(Config) -> rabbit_ct_broker_helpers:rpc(Config, 0, application, set_env, [rabbitmq_management, uaa_location, "http://localhost:5000/identityserver"]), rabbit_ct_broker_helpers:rpc(Config, 0, application, set_env, - [rabbitmq_management, oauth2_scopes, "rabbitmq.read:*/* rabbitmq.write:*/*"]), + [rabbitmq_management, identityserver_scopes, "rabbitmq.read:*/* rabbitmq.write:*/*"]), Map5 = http_get(Config, "/auth", ?OK), ?assertEqual(true, maps:get(enable_uaa, Map5)), ?assertEqual(<<"rabbitmq">>, maps:get(uaa_client_id, Map5)), ?assertEqual(<<"http://localhost:5000/identityserver">>, maps:get(uaa_location, Map5)), - ?assertEqual(<<"rabbitmq.read:*/* rabbitmq.write:*/*">>, maps:get(oauth2_scopes, Map5)), + ?assertEqual(<<"rabbitmq.read:*/* rabbitmq.write:*/*">>, maps:get(identityserver_scopes, Map5)), ?assertEqual(<<"identityserver">>, maps:get(oauth2_implementation, Map5)), %% Cleanup after IdentityServer rabbit_ct_broker_helpers:rpc(Config, 0, application, unset_env, diff --git a/deps/rabbitmq_prometheus/test/config_schema_SUITE_data/schema/rabbitmq_management.schema b/deps/rabbitmq_prometheus/test/config_schema_SUITE_data/schema/rabbitmq_management.schema index e35f12f502..e8c297b723 100644 --- a/deps/rabbitmq_prometheus/test/config_schema_SUITE_data/schema/rabbitmq_management.schema +++ b/deps/rabbitmq_prometheus/test/config_schema_SUITE_data/schema/rabbitmq_management.schema @@ -386,7 +386,7 @@ end}. {mapping, "management.uaa_location", "rabbitmq_management.uaa_location", [{datatype, string}]}. -{mapping, "management.oauth2_scopes", "rabbitmq_management.oauth2_scopes", +{mapping, "management.identityserver_scopes", "rabbitmq_management.identityserver_scopes", [{datatype, string}]}. {mapping, "management.oauth2_implementation", "rabbitmq_management.oauth2_implementation", -- cgit v1.2.1