rabbitmqrabbitmqctl

Rabbitmq create a new user and set permission to access only specific queues under a vhost


I found the steps online to add/create a new user on rabbitmq, example doc

But my internal team has got a special requirement to allow that user access only some specific services/queues under the virtual host /

Right, now, the user I created has access to all queues under virtual host /

Suppose, if we need to change their permission to access only specific queues/services say cart-order1, cart-order2, cart-order3 under virtual host /, how do we do that?.


Solution

  • You can grant a user config, write, read permissions to queues using regex to match the queues. This can be done in the web management interface or using the cli rabbitmqctl. For example, something like this:

    rabbitmqctl set_permissions -p "/" "username" "^cart-order.*" "^cart-order.*" "^cart-order.*"
    

    See documentation here: https://www.rabbitmq.com/access-control.html