Skip to content

Commit 91df75a

Browse files
Clean up
1 parent 82d2e1a commit 91df75a

File tree

6 files changed

+10
-32
lines changed

6 files changed

+10
-32
lines changed

deps/rabbitmq_management/include/rabbit_mgmt.hrl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
-define(MANAGEMENT_DEFAULT_HTTP_MAX_BODY_SIZE, 20000000).
1616

17-
-define(OAUTH2_ACCESS_TOKEN, <<"access_token">>).
18-
-define(OAUTH2_BOOTSTRAP_PATH, <<"js/oidc-oauth/bootstrap.js">>).
19-
-define(MANAGEMENT_LOGIN_STRICT_AUTH_MECHANISM, <<"strict_auth_mechanism">>).
20-
-define(MANAGEMENT_LOGIN_PREFERRED_AUTH_MECHANISM, <<"preferred_auth_mechanism">>).
17+
-define(OAUTH2_ACCESS_TOKEN, <<"access_token">>).
18+
-define(OAUTH2_BOOTSTRAP_PATH, <<"js/oidc-oauth/bootstrap.js">>).
19+
-define(MANAGEMENT_LOGIN_STRICT_AUTH_MECHANISM, <<"strict_auth_mechanism">>).
20+
-define(MANAGEMENT_LOGIN_PREFERRED_AUTH_MECHANISM, <<"preferred_auth_mechanism">>).

deps/rabbitmq_management/priv/www/js/oidc-oauth/helper.js

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -193,24 +193,6 @@ function oauth_initialize_user_manager(resource_server) {
193193
});
194194

195195
}
196-
function parseAuthMechanism(oauth, name, auth_mechanism) {
197-
if (!auth_mechanism) {
198-
return oauth;
199-
}
200-
201-
if (auth_mechanism.includes(':')) {
202-
// OAuth2 case: "oauth2:prod"
203-
const [authMethod, resourceId] = auth_mechanism.split(':');
204-
if (authMethod === 'oauth2' && resourceId) {
205-
if (oauth.resource_servers.some(resource => resource.id === resourceId)) {
206-
oauth[name] = {type: "oauth2", resource_id: resourceId};
207-
}
208-
}
209-
} else if (auth_mechanism === 'basic' && oauth.oauth_disable_basic_auth === false) {
210-
oauth[name] = {type: "basic"};
211-
}
212-
return oauth;
213-
}
214196

215197
export function oauth_initialize(authSettings) {
216198
authSettings = auth_settings_apply_defaults(authSettings);

deps/rabbitmq_management/src/rabbit_mgmt_login.erl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ login(<<"GET">>, Req, State) ->
7373
redirect_to_home_with_cookie(?OAUTH2_BOOTSTRAP_PATH, Type, Value, Req, State)
7474
end;
7575

76-
login(M, Req0, State) ->
77-
%% Method not allowed.
78-
?LOG_ERROR("Method ~p not allowed", [M]),
76+
login(_, Req0, State) ->
7977
{ok, cowboy_req:reply(405, Req0), State}.
8078

8179
handleStrictOrPreferredAuthMechanism(Req, Body, State) ->

deps/rabbitmq_management/src/rabbit_mgmt_oauth_bootstrap.erl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ init(Req0, State) ->
3737
rabbit_mgmt_headers:set_common_permission_headers(Req0, ?MODULE), ?MODULE), State).
3838

3939
bootstrap_oauth(Req0, State) ->
40-
AuthSettings0 = rabbit_mgmt_wm_auth:authSettings(),
41-
{Req1, AuthSettings} = enrich_oauth_settings(Req0, AuthSettings0),
40+
{Req1, AuthSettings} = enrich_oauth_settings(Req0, rabbit_mgmt_wm_auth:authSettings()),
4241
Dependencies = oauth_dependencies(),
4342
{Req2, SetTokenAuth} = set_token_auth(AuthSettings, Req1),
4443
JSContent = import_dependencies(Dependencies) ++
@@ -56,7 +55,7 @@ enrich_oauth_settings(Req0, AuthSettings) ->
5655
{preferred_auth_mechanism, Args} -> {Req1, [{preferred_auth_mechanism, Args} | AuthSettings]};
5756
{strict_auth_mechanism, Args} -> {Req1, [{strict_auth_mechanism, Args} | AuthSettings]};
5857
{error, Reason} -> ?LOG_DEBUG("~p", [Reason]),
59-
{Req1, AuthSettings}
58+
{Req1, AuthSettings}
6059
end.
6160
get_auth_mechanism(Req) ->
6261
case get_auth_mechanism_from_cookies(Req) of
@@ -115,7 +114,7 @@ set_token_auth(AuthSettings, Req0) ->
115114
};
116115
_ ->
117116
Cookies = cowboy_req:parse_cookies(Req0),
118-
case lists:keyfind(?OAUTH2_ACCESS_TOKEN, 1, Cookies) of
117+
case proplists:get_value(?OAUTH2_ACCESS_TOKEN, Cookies) of
119118
{_, Token} ->
120119
{
121120
cowboy_req:set_resp_cookie(
@@ -127,7 +126,7 @@ set_token_auth(AuthSettings, Req0) ->
127126
}),
128127
["set_token_auth('", Token, "');"]
129128
};
130-
false -> {
129+
undefined -> {
131130
Req0,
132131
[]
133132
}

deps/rabbitmq_management/src/rabbit_mgmt_schema.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ translate_oauth_resource_servers(Conf) ->
2929
extract_resource_server_properties(Settings),
3030
extract_resource_server_endpoint_params(oauth_authorization_endpoint_params, Settings),
3131
extract_resource_server_endpoint_params(oauth_token_endpoint_params, Settings)
32-
]),
32+
]),
3333
Map0 = maps:map(fun(K,V) ->
3434
case proplists:get_value(id, V) of
3535
undefined -> V ++ [{id, K}];

deps/rabbitmq_management/src/rabbit_mgmt_wm_auth.erl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ buildRootResourceServerIfAny(Id, Props) ->
120120

121121
authSettings() ->
122122
ManagementProps = application:get_all_env(rabbitmq_management),
123-
?LOG_DEBUG("ManagementProps: ~p", [ManagementProps]),
124123
OAuth2BackendProps = application:get_all_env(rabbitmq_auth_backend_oauth2),
125124
EnableOAUTH = proplists:get_value(oauth_enabled, ManagementProps, false),
126125
case EnableOAUTH of

0 commit comments

Comments
 (0)