RabbitMQ user permission format

John Simmons picture John Simmons · Apr 30, 2013 · Viewed 22.6k times · Source

I am trying to configure user permissions in RabbitMQ using rabbitmqctl. The RabbitMQ documentation http://www.rabbitmq.com/man/rabbitmqctl.1.man.html gives a basic example of setting configure, write, and read permissions:

rabbitmqctl set_permissions -p /myvhost tonyg "^tonyg-.*" ".*" ".*"

but does not give any more detailed examples. I have looked at several posts on this topic but have not found answers to my specific questions.

First question: Is it necessary to grant permissions to both exchanges and queues to which a user can write, or just the exchanges? Similarly for reading, is it enough to specify the queues? The documentation just talks about granting access to "resources".

Second question: The example above uses a caret to mark the beginning of the resource name. If I omit this, and just use "tonyg-.*", would that allow the specified text to appear anywhere in the resource name? Similarly, if I wanted to specify the entire resource name, must I bracket it with ^ and $, as in "^myqueue$"?

Third question: Say I want to specify more than one pattern for a given permission. Can I just separate the patterns with commas, something like

rabbitmqctl set_permissions -p /myvhost tonyg "^tonyg-.*,^test-.*" ".*" ".*"

Is this the correct syntax for this? If not, what is?

Fourth question: What is the required syntax for vhost names? The other examples on the cited man page do not use a leading slash, as in

rabbitmqctl add_vhost test

Are the vhost names in some way structured, or is the slash just another character in the name?

Thanks for any suggestions!

Answer

z900collector picture z900collector · Jan 8, 2014

I hit the same issue but after some simple experiments I came up with the following:

I added a vhost called "/ASX" first, then added the "guest" user to it successfully using the following format:

rabbitmqctl set_permissions -p /ASX guest ".*" ".*" "."
Setting permissions for user "guest" in vhost "/ASX" ...
...done.

I also had to perform a restart of rabbitmq-server for the change to take effect.