Manage Users, Virtual Hosts, and Permissions
Use RabbitMQ users, virtual hosts, and permissions to isolate applications and reduce the impact of leaked credentials. A production workload should not share the platform-generated administrator account with application clients.
This guide shows how to create a virtual host, create an application user, and grant least-privilege permissions.
TOC
PrerequisitesPermission ModelProcedure1. Create a virtual host2. Create an application user3. Grant application permissions4. Grant topic permissions when required5. Verify accessRecommended PracticesRelated InformationPrerequisites
Before you manage users and permissions, make sure that the following conditions are met:
- You have the management endpoint or
kubectl execaccess to a RabbitMQ Pod. - You have administrator credentials. For the platform-generated default account, see User Management.
- You know the virtual host name, application username, and exchange or queue naming pattern that the application requires.
Permission Model
RabbitMQ permissions are scoped to a virtual host and include three regular expressions:
Use narrow regular expressions for application users. Grant administrator tags only to operational users that need management privileges across the instance.
Procedure
1. Create a virtual host
Create a virtual host for the application:
For commands executed inside a RabbitMQ Pod, you can also use rabbitmqctl:
2. Create an application user
Create a user for the application. Do not reuse this user for administration.
If you use rabbitmqctl, run:
Store the application password in a Kubernetes Secret or in your approved secret manager. Do not store it in application manifests as plain text.
3. Grant application permissions
The following example allows the payments-app user to configure, publish to, and consume from resources that start with payments. in the payments virtual host:
The equivalent rabbitmqctl command is:
4. Grant topic permissions when required
If the application uses topic authorization, define topic permissions separately from resource permissions:
Only configure topic permissions when your authorization model requires them.
5. Verify access
List virtual hosts, users, and permissions:
Verify application connectivity with the application user, not with the administrator account.
Recommended Practices
- Create a dedicated virtual host for each application or tenant boundary.
- Create one RabbitMQ user for each application runtime identity.
- Use narrow permission regular expressions instead of
.*for application users. - Keep administrator users separate from producer and consumer users.
- Rotate application passwords through Kubernetes
Secretupdates or your approved secret manager. - Remove users and permissions when an application is decommissioned.