The RabbitMQ secrets engine generates RabbitMQ user credentials dynamically based on configured roles. For every request, Stronghold creates a separate RabbitMQ user with the virtual host (vhost) permissions and tags defined in the role, and deletes the user when the lease expires.
Stronghold manages users through the RabbitMQ management HTTP API, so the rabbitmq_management plugin must be enabled in RabbitMQ.
The RabbitMQ secrets engine is available in all Stronghold editions.
Capabilities
| Capability | Supported |
|---|---|
| Dynamic credentials | Yes |
Virtual host permissions (vhosts) | Yes |
Topic exchange permissions (vhost_topics) | Yes |
User tags (tags) | Yes |
Username customization (username_template) | Yes |
Password policy (password_policy) | Yes |
Setup
Setup is usually performed by a Stronghold administrator or a configuration management tool.
Enable the RabbitMQ secrets engine:
d8 stronghold secrets enable rabbitmqBy default, the engine is mounted at
rabbitmq/. To mount it at a different path, use the-pathargument.Configure the connection to the RabbitMQ management HTTP API. Specify a RabbitMQ user with administrator rights (the
administratortag): Stronghold uses it to create and delete users.d8 stronghold write rabbitmq/config/connection connection_uri="https://rabbitmq.example.com:15672" username="stronghold-admin" password="<ADMIN_PASSWORD>"Where
<ADMIN_PASSWORD>is the password of thestronghold-adminRabbitMQ user.Parameters of the
config/connectionendpoint:Parameter Description connection_uriRabbitMQ management HTTP API URI. usernameRabbitMQ administrator username. passwordRabbitMQ administrator password. verify_connectionWhether to verify connection_uriby actually connecting to the management API. Defaults totrue.username_templateTemplate used to generate dynamic usernames. password_policyName of the password policy used to generate passwords for dynamic users. Create a dedicated RabbitMQ user for Stronghold and do not use it for anything else.
Configure the lease settings for issued credentials:
d8 stronghold write rabbitmq/config/lease ttl=1800 max_ttl=3600ttl: how long the credentials are valid without renewal, in seconds;max_ttl: the maximum lifetime after which the credentials cannot be renewed, in seconds.
The value
0(default) means that system TTL values are used.To read the current lease settings:
d8 stronghold read rabbitmq/config/leaseCreate a role that describes the permissions of the generated users:
d8 stronghold write rabbitmq/roles/my-role vhosts='{"/":{"configure":".*","write":".*","read":".*"}}' tags="management"Role parameters:
Parameter Description vhostsJSON map of virtual hosts to configure,write, andreadpermissions (RabbitMQ regular expressions).vhost_topicsNested JSON map: virtual host → exchange → writeandreadtopic permissions.tagsComma-separated list of RabbitMQ user tags, for example managementormonitoring.A role with topic permissions on the
amq.topicexchange:d8 stronghold write rabbitmq/roles/topic-role vhosts='{"/":{"configure":"","write":".*","read":".*"}}' vhost_topics='{"/":{"amq.topic":{"write":"^orders\\..*","read":".*"}}}'
Usage
Once the secrets engine is configured, a user or application with a Stronghold token and an appropriate policy can request credentials.
Request credentials for a role:
d8 stronghold read rabbitmq/creds/my-roleExample output:
Key Value --- ----- lease_id rabbitmq/creds/my-role/I39Hu8XXOombof4wiK5bKMn9 lease_duration 30m lease_renewable true password 3yNDBikgQvrkx2VA2zhq5IdSM7IWk1RyMYJr username root-39669250-3894-8032-c420-3d58483ebfc4Stronghold creates a RabbitMQ user with the role permissions and returns its username and password together with the lease ID.
If needed, renew the lease before
lease_durationexpires:d8 stronghold lease renew rabbitmq/creds/my-role/I39Hu8XXOombof4wiK5bKMn9When the credentials are no longer needed, revoke the lease. Stronghold deletes the RabbitMQ user:
d8 stronghold lease revoke rabbitmq/creds/my-role/I39Hu8XXOombof4wiK5bKMn9
Managing roles
List roles:
d8 stronghold list rabbitmq/rolesRead a role:
d8 stronghold read rabbitmq/roles/my-roleDelete a role:
d8 stronghold delete rabbitmq/roles/my-role
Policy example
A policy that only allows requesting credentials for the my-role role:
path "rabbitmq/creds/my-role" {
capabilities = ["read"]
}For the full list of endpoints and parameters, see the secrets engines API reference.