II RabbitMQ User Management, Role Management and Permission Setting

Because RabbitMQ is installed using docker, you need to enter RabbitMQ in the docker environment first.

1
2
3
4
# Enter the docker environment
sudo docker exec -it [container name ps.rabbitmq] /bin/bash
# Check the status
rabbitmqctl status

2023-07-23_070848.png

一 user management

  1. View User List
    1
    rabbitmqctl list_users

    2023-07-23_071011.png

  2. New User
    1
    rabbitmqctl add_user developer 456789

    2023-07-23_071316.png

  3. delete user
    1
    rabbitmqctl delete_user developer

    2023-07-23_071444.png

  4. chagne password
    1
    rabbitmqctl change_password developer developer123456

    2023-07-23_071701.png

二 characterization

  1. In RabbitMQ, there are several roles: administrator, monitoring, policymaker, management, impersonator, and none.

    The default user guest is in the administrator role, and the new developer user has no role set, i.e., none, if we want to set the developer user to the administrator role

  2. 1
    rabbitmqctl set_user_tags developer administrator

    2023-07-23_071855.png

    It is also possible to set multiple roles for a user, such as administrator, monitoring for the user developer:

    1
    rabbitmqctl set_user_tags developer administrator monitoring

    2023-07-23_072002.png

III Privilege Configuration

Now this developer account doesn’t have the privileges to manage configure, write, and read, so we need to add them.

  1. Setting Up Permissions

    1
    rabbitmqctl set_permissions -p / developer ".*" ".*" ".*"

  2. View the permissions of all users on the specified vhostpath.

    1
    rabbitmqctl  list_permissions

    View all user permissions for virtual host as /

    1
    rabbitmqctl  list_permissions -p /

  3. To view the privileges of a specified user

    1
    rabbitmqctl  list_user_permissions developer

    2023-07-23_073300.png

  4. Clearing User Privileges

    1
    rabbitmqctl  clear_permissions developer

    2023-07-23_073404.png

consultation : https://www.cnblogs.com/ericli-ericli/p/5902270.html