Skip to content

Commit 6e770d5

Browse files
michaelklishinmergify[bot]
authored andcommitted
authN/authZ backend HTTP: cosmetics
(cherry picked from commit 83d7920)
1 parent 767e150 commit 6e770d5

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

deps/rabbitmq_auth_backend_http/src/rabbit_auth_backend_http.erl

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,27 @@ user_login_authentication(Username, AuthProps) ->
4646
Other -> {error, {bad_response, Other}}
4747
end.
4848

49-
%% When some protocols, such as MQTT, uses an internal AMQP client, to interact with RabbitMQ core,
50-
%% it happens that the main protocol authenticates the user passing all credentials (e.g. password, client_id, vhost)
51-
%% however the internal AMQP client also performs further authentications. THe latter authentication
52-
%% attempt lacks of all credentials. Instead those credentials are persisted behind a function call
49+
%% When a protocol plugin uses an internal AMQP 0-9-1 client to interact with RabbitMQ core,
50+
%% what happens that the plugin authenticates the entire authentication context (e.g. all of: password, client_id, vhost, etc)
51+
%% and the internal AMQP 0-9-1 client also performs further authentication.
52+
%%
53+
%% In the latter case, the complete set of credentials are persisted behind a function call
5354
%% that returns an AuthProps.
5455
%% If the user was first authenticated by rabbit_auth_backend_http, there will be one property called
5556
%% `rabbit_auth_backend_http` whose value is a function that returns a proplist with all the credentials used
5657
%% on the first successful login.
57-
%% However, it may happen that the user was authenticated via rabbit_auth_backend_cache, in that case,
58+
%%
59+
%% When rabbit_auth_backend_cache is involved,
5860
%% the property `rabbit_auth_backend_cache` is a function which returns a proplist with all the credentials used
59-
%% on the first succcessful login.
61+
%% on the first successful login.
6062
resolve_using_persisted_credentials(AuthProps) ->
61-
case proplists:get_value(rabbit_auth_backend_http, AuthProps, none) of
62-
none -> case proplists:get_value(rabbit_auth_backend_cache, AuthProps, none) of
63-
none -> AuthProps;
64-
CacheAuthPropsFun -> AuthProps ++ CacheAuthPropsFun()
65-
end;
66-
HttpAuthPropsFun -> AuthProps ++ HttpAuthPropsFun()
63+
case proplists:get_value(rabbit_auth_backend_http, AuthProps, undefined) of
64+
undefined ->
65+
case proplists:get_value(rabbit_auth_backend_cache, AuthProps, undefined) of
66+
undefined -> AuthProps;
67+
CacheAuthPropsFun -> AuthProps ++ CacheAuthPropsFun()
68+
end;
69+
HttpAuthPropsFun -> AuthProps ++ HttpAuthPropsFun()
6770
end.
6871

6972

0 commit comments

Comments
 (0)