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

Commit

Permalink
Use exchange instead of name in topic permission
Browse files Browse the repository at this point in the history
  • Loading branch information
acogoluegnes committed Jan 3, 2017
1 parent b40ce04 commit e5264f2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion priv/www/api/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ <h2>Reference</h2>
<td></td>
<td class="path">/api/topic-permissions/<i>vhost</i>/<i>user</i></td>
<td>Topic permissions for a user and virtual host. To PUT a topic permission, you will need a body looking something like this:
<pre>{"name":"amp.topic","pattern":"^a"}</pre>
<pre>{"exchange":"amp.topic","pattern":"^a"}</pre>
All keys are mandatory.</td>
</tr>
<tr>
Expand Down
4 changes: 2 additions & 2 deletions src/rabbit_mgmt_wm_definitions.erl
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ rw_state() ->
[{users, [name, password_hash, hashing_algorithm, tags]},
{vhosts, [name]},
{permissions, [user, vhost, configure, write, read]},
{topic_permissions, [user, vhost, name, pattern]},
{topic_permissions, [user, vhost, exchange, pattern]},
{parameters, [vhost, component, name, value]},
{global_parameters, [name, value]},
{policies, [vhost, name, pattern, definition, priority, 'apply-to']},
Expand Down Expand Up @@ -353,7 +353,7 @@ add_topic_permission(TopicPermission) ->
rabbit_auth_backend_internal:set_topic_permissions(
maps:get(user, TopicPermission, undefined),
maps:get(vhost, TopicPermission, undefined),
maps:get(name, TopicPermission, undefined),
maps:get(exchange, TopicPermission, undefined),
maps:get(pattern, TopicPermission, undefined)).

add_queue(Queue) ->
Expand Down
2 changes: 1 addition & 1 deletion src/rabbit_mgmt_wm_topic_permission.erl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ accept_content(ReqData, Context) ->
User = rabbit_mgmt_util:id(user, ReqData),
VHost = rabbit_mgmt_util:id(vhost, ReqData),
rabbit_mgmt_util:with_decode(
[name, pattern], ReqData, Context,
[exchange, pattern], ReqData, Context,
fun([Exchange, Pattern], _) ->
rabbit_auth_backend_internal:set_topic_permissions(
User, VHost, Exchange, Pattern),
Expand Down
12 changes: 6 additions & 6 deletions test/rabbit_mgmt_http_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ topic_permissions_list_test(Config) ->
http_put(Config, "/vhosts/myvhost1", none, {group, '2xx'}),
http_put(Config, "/vhosts/myvhost2", none, {group, '2xx'}),

TopicPerms = [{name, <<"amq.topic">>}, {pattern, <<"^a">>}],
TopicPerms = [{exchange, <<"amq.topic">>}, {pattern, <<"^a">>}],
http_put(Config, "/topic-permissions/myvhost1/myuser1", TopicPerms, {group, '2xx'}),
http_put(Config, "/topic-permissions/myvhost2/myuser1", TopicPerms, {group, '2xx'}),
http_put(Config, "/topic-permissions/myvhost1/myuser2", TopicPerms, {group, '2xx'}),
Expand Down Expand Up @@ -488,7 +488,7 @@ topic_permissions_test(Config) ->
http_put(Config, "/vhosts/myvhost1", none, {group, '2xx'}),
http_put(Config, "/vhosts/myvhost2", none, {group, '2xx'}),

TopicPerms = [{name, <<"amq.topic">>}, {pattern, <<"^a">>}],
TopicPerms = [{exchange, <<"amq.topic">>}, {pattern, <<"^a">>}],
http_put(Config, "/topic-permissions/myvhost1/myuser1", TopicPerms, {group, '2xx'}),
http_put(Config, "/topic-permissions/myvhost2/myuser1", TopicPerms, {group, '2xx'}),
http_put(Config, "/topic-permissions/myvhost1/myuser2", TopicPerms, {group, '2xx'}),
Expand Down Expand Up @@ -1039,10 +1039,10 @@ definitions_test(Config) ->
write => <<"w">>,
read => <<"r">>}),
defs(Config, topic_permissions, "/topic-permissions/%2f/guest", put,
#{user => <<"guest">>,
vhost => <<"/">>,
name => <<"amq.topic">>,
pattern => <<"^a">>}),
#{user => <<"guest">>,
vhost => <<"/">>,
exchange => <<"amq.topic">>,
pattern => <<"^a">>}),

%% We just messed with guest's permissions
http_put(Config, "/permissions/%2f/guest",
Expand Down

0 comments on commit e5264f2

Please sign in to comment.