Skip to content
This repository was archived by the owner on Nov 17, 2020. It is now read-only.

Commit 28168f5

Browse files
committed
Propagate protocol-specific context to HTTP backend
Information like MQTT client ID is now propagated to the backend for all authentication and authorization functions. References rabbitmq/rabbitmq-server#1767
1 parent d53afdd commit 28168f5

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/rabbit_auth_backend_http.erl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
-export([description/0, p/1, q/1, join_tags/1]).
2525
-export([user_login_authentication/2, user_login_authorization/2,
26-
check_vhost_access/3, check_resource_access/3, check_topic_access/4]).
26+
check_vhost_access/3, check_resource_access/4, check_topic_access/4]).
2727

2828
%% If keepalive connection is closed, retry N times before failing.
2929
-define(RETRY_ON_KEEPALIVE_CLOSED, 3).
@@ -58,21 +58,25 @@ user_login_authorization(Username, AuthProps) ->
5858
Else -> Else
5959
end.
6060

61-
check_vhost_access(#auth_user{username = Username, tags = Tags}, VHost, #{peeraddr := PeerAddr}) ->
61+
check_vhost_access(#auth_user{username = Username, tags = Tags}, VHost, AuthzData = #{peeraddr := PeerAddr}) ->
62+
AuthzData1 = maps:remove(peeraddr, AuthzData),
63+
OptionsParameters = context_as_parameters(AuthzData1),
6264
bool_req(vhost_path, [{username, Username},
6365
{vhost, VHost},
6466
{ip, parse_peeraddr(PeerAddr)},
65-
{tags, join_tags(Tags)}]).
67+
{tags, join_tags(Tags)}] ++ OptionsParameters).
6668

6769
check_resource_access(#auth_user{username = Username, tags = Tags},
6870
#resource{virtual_host = VHost, kind = Type, name = Name},
69-
Permission) ->
71+
Permission,
72+
AuthzContext) ->
73+
OptionsParameters = context_as_parameters(AuthzContext),
7074
bool_req(resource_path, [{username, Username},
7175
{vhost, VHost},
7276
{resource, Type},
7377
{name, Name},
7478
{permission, Permission},
75-
{tags, join_tags(Tags)}]).
79+
{tags, join_tags(Tags)}] ++ OptionsParameters).
7680

7781
check_topic_access(#auth_user{username = Username, tags = Tags},
7882
#resource{virtual_host = VHost, kind = topic = Type, name = Name},

0 commit comments

Comments
 (0)