How OpenBao dynamic RabbitMQ credentials per service work
Most RabbitMQ estates start with a handful of shared logins, one per environment or one per team, copied into several services' configuration files. When something misbehaves on the broker, the only identifier in the logs is that shared username, so tracing activity back to one service instance, let alone one deployment, becomes guesswork. OpenBao's RabbitMQ secrets engine replaces the shared login with a unique RabbitMQ user for each request, created when an application asks for credentials and tied to a lease. Each role defines the permission set, the tags and the virtual host that user receives, so a service that only publishes to one exchange never holds a login that can reach the rest of the broker. When the lease ends, OpenBao revokes the user, so stale accounts do not accumulate.
Teams need this pattern when several services or short-lived workers share a broker, when auditors or incident responders need activity attributed to a single instance, or when a credential leak must be contained to one service without rotating a password everywhere. Ask your team to inventory which services connect, which queues and exchanges each one uses, and whether they can reconnect cleanly after a lease renewal or expiry. A static role or a per-service password is usually enough when there are only a few long-running consumers, when the client library cannot re-read credentials without a restart, or when the broker's own user policies are not in place yet. In those cases, confirm the rotation period and who can read the current password before committing to the simpler option.
Before building, confirm three things in your own environment: the RabbitMQ version and management plugin you run, the exact permission syntax your broker expects for each virtual host, and the lease length your applications can tolerate without interrupting consumers. The exact RabbitMQ plugin requirements and configuration keys should be checked against the OpenBao secrets engine documentation for your release, since this page does not supply them. Plan the role model first, one role per service and per access pattern, because the role is what determines the blast radius of a leaked credential and what your logs will later show. The OpenBao documentation is the natural next read for the exact configuration fields.
How a service gets its RabbitMQ user from OpenBao
The flow starts when a service authenticates to OpenBao and requests a RabbitMQ role. OpenBao then calls the RabbitMQ management API to create a user with the permissions and virtual host defined for that role, and returns the username, password and a lease to the service. The trust boundary sits between the application, OpenBao and the broker: only OpenBao holds the broker administrator credential. When the lease expires or is revoked, OpenBao removes the user, so check that the management API path and the revocation path are both reachable from OpenBao.
Dynamic user creation and lease-based revocation between a service, OpenBao and RabbitMQ.
Choosing role design: per service, per instance or per environment
Mapping one OpenBao role to each application or service is the most common starting point. The role carries the messaging permissions that service needs, such as which exchanges it may publish to and which queues it may read, and every credential issued from that role belongs to the same logical owner. Tracing becomes straightforward because a username such as the one the role template generates points to a service name, and an incident review can start from the broker's connection list. The cost is that all replicas of that service share the same permission set and the same policy, so a change for one deployment target applies everywhere the role is used. Lease volume depends on how often each replica or job requests credentials, not on the number of services alone.
- Tracing: A username identifies the service, but not the specific pod, VM or job that opened the connection.
- Permissions: Each service role sets its own
configure,writeandreadpatterns and its virtual host. - Broker user count: The user count grows with the number of services, which is usually modest.
- Change impact: Editing a role changes access for every instance of that service in every environment that uses it.
- Ownership: Application owners can be named on the role, which helps with access reviews.
Before adopting this model, confirm with your RabbitMQ and OpenBao administrators how the role name and username template will appear in broker logs and audit records.
Splitting roles by deployment environment, such as development, staging and production, keeps permission scopes apart at the broker level. A production role can be restricted to production virtual hosts and reviewed separately, while a development role can carry broader rights that are never valid against production data. This model suits teams that want environment isolation enforced by the credential itself rather than by application configuration. The trade-off is that the role does not say which service is connecting, so the username alone is weaker evidence for attribution. Teams usually combine this model with a service identifier in the role or path name, or they accept that service attribution comes from another log source.
- Tracing: Usernames reveal the environment but may not reveal the service unless the naming convention adds it.
- Permissions: Each environment role maps to its own virtual host, which keeps production and test traffic apart.
- Broker user count: The count is small, but services sharing a role cannot be separated in the broker's user list.
- Lease volume: Lease counts still scale with replicas and job runs, since each consumer requests its own credential.
- Blast radius: A leaked production role affects every production service that shares it, so rotation must be planned carefully.
Confirm whether your policy requires service-level attribution in addition to environment separation, because this model usually does not satisfy that requirement on its own.
Defining a role per workload identity, such as each Kubernetes service account or each deployment unit, gives the finest attribution. The role is bound to one identity that OpenBao's auth method can verify, so a credential can be traced to a specific workload. Permissions can be narrowed to exactly what that workload needs, which reduces the reach of a stolen credential. The cost is operational: the number of roles, policies and broker users grows with the number of workloads, and each new workload requires a role and an auth binding. Teams often reserve this model for sensitive workloads and use a coarser model for low-risk ones.
- Tracing: Usernames can map to a single workload identity, which is the strongest attribution this design offers.
- Permissions: Permissions and virtual host assignments are set per workload, with the narrowest scope of the three models.
- Broker user count: Expect the largest number of broker users, which increases the work for review and cleanup.
- Lease volume: Lease counts depend on how often each identity requests credentials, so short TTLs multiply activity quickly.
- Automation: Role creation is best handled through declarative configuration so that the number of roles does not drift from the number of workloads.
Ask your team to estimate the number of workloads and the lease TTL they will use, then confirm the broker and OpenBao capacity for that count with the vendors and your own test environment.
Whichever granularity you choose, each OpenBao RabbitMQ role defines its broker access in the role configuration. The role sets the virtual host the user can enter, the RabbitMQ tags that grant management or monitoring capabilities, and the permission patterns for configure, write and read on exchanges and queues. Keeping these settings explicit in the role, rather than granting broad rights and narrowing later, makes reviews simpler. Tags should stay minimal, because a management tag changes what the user can see and do beyond messaging. Virtual host assignments are the main isolation boundary, so each role should name one virtual host unless there is a clear reason to share.
- Virtual host: Assign one virtual host per role where possible, and confirm the vhost name matches the environment.
- Tags: Grant the smallest set of tags, and avoid administrator tags for application roles.
- Permission patterns: Use specific regular expressions for configure, write and read so that each service touches only its own queues and exchanges.
- Naming: Agree on a naming convention for queues and exchanges so patterns stay short and reviewable.
- Testing: Verify each role by connecting with a generated credential and attempting actions outside its scope.
Before finalizing patterns, check the current RabbitMQ permission and tag documentation for your broker version, since behavior can differ between releases.
Configuration options and when each fits
This table compares the main configuration choices for OpenBao-issued RabbitMQ users, from connection and root rotation to lease settings and username conventions. Read each row as a decision: the option, when it fits your services, and what it costs you in operational effort or tracing precision.
| Choice | When it fits | Trade-off |
|---|---|---|
| Root credential rotation for the RabbitMQ connection | Use when OpenBao should own the management account and no person knows its password after setup | Rotation depends on the management account having rights to create and delete users, so a broken grant stops all issuance |
| Dedicated management user for OpenBao | Use when you want OpenBao's administrative account limited to user and permission management on the target broker | Scoping it tightly requires testing each role creation statement, which adds work during initial build |
| Role creation statements per service | Use when each application needs its own user with a distinct set of tags and permissions | More roles mean more statements to review and maintain as services change |
| Permissions by virtual host and resource pattern | Use when services share a broker but must write only to their own exchanges and queues | Narrow regular expressions are easy to get wrong, and a too-broad pattern silently grants access to other teams' resources |
| Separate virtual host per tenant or environment | Use when production, staging or unrelated business units share one cluster and must not see each other's queues | Each virtual host adds policy and monitoring surface, and cross-host messaging needs explicit design |
| Lease TTL | Use when short leases fit how the application reconnects and renews credentials | Short leases raise renewal traffic and create outages if a client fails to renew before expiry |
| Maximum TTL | Use when you want a hard ceiling on how long any single user can exist, regardless of renewal | Reaching the ceiling forces re-issuance, so clients must handle a new username and password cleanly |
| Username conventions for tracing | Use when logs or broker management views must map a connection back to one service instance | Long or embedded identifiers make usernames harder to read, and the name is visible to anyone with broker access |
Setup sequence for RabbitMQ dynamic credentials in OpenBao
This sequence takes OpenBao from an unconfigured RabbitMQ connection to per-service users that are issued on request, scoped to their own virtual hosts and permissions, and removed automatically when their leases end.
Create a dedicated RabbitMQ management account
Your broker administrator creates a separate RabbitMQ user for OpenBao, with only the management and tag permissions the RabbitMQ secrets engine needs to create users, set permissions and delete them. This account is not a person's login and is not reused by any application. Confirm the account can authenticate to the management API and list existing users, but cannot publish or consume messages on production queues. Record who holds its password and where it is stored, because OpenBao will need it in the next step.
Enable the RabbitMQ secrets engine
An operator enables the RabbitMQ secrets engine at a path such as
rabbitmq/using the OpenBao CLI or API, with the mount options your team has agreed. Check that the mount appears in the list of enabled secrets engines and that the engine's configuration endpoint responds. Engine enablement does not connect to the broker yet, so nothing changes on RabbitMQ at this point. Confirm the mount path matches the naming convention your application teams will use in their policies.Configure the connection and root credential rotation
Write the broker connection settings to the engine's configuration endpoint, including the management API URL, the TLS trust material for the broker, and the dedicated management account. Enable root credential rotation so OpenBao replaces the management account's password on a schedule that you set, and so that no person needs to know the stored value. Read the configuration back to confirm the connection fields are saved, then check that OpenBao can reach the broker by running a connection test and reviewing the audit log entry for it.
Define roles with permissions and virtual hosts
Create one role per application or service instance type, setting the RabbitMQ tags, the virtual host, and the configure, write and read permission patterns that the service needs. Keep each role narrow, so a service that publishes to one exchange cannot read queues belonging to another team. Set the default lease TTL and maximum TTL for each role according to how long its processes run. Read each role back and confirm the permission patterns and virtual host match the design document before any application uses it.
Grant applications read access to their own role only
Write a policy for each application that allows the read capability on the credentials path for its own role, and nothing else. Bind that policy to the application's authentication method, such as AppRole or Kubernetes auth, so the application can only request credentials for the role it was designed for. Test with each application identity that it can read its own credentials path and receives denial for a neighboring role. The check is the audit log showing the denied request, not just the absence of an error in the application.
Verify issuance, use and revocation
Request credentials for one role and confirm that a user with the expected name and permissions appears in the RabbitMQ management interface or user list. Connect a test client with those credentials, publish and consume a message within the permitted virtual host, and confirm that an attempt outside the permissions fails. Revoke the lease with the lease revoke command, then confirm the user is removed from the broker and the test connection is closed. Record the lease ID and the broker username together, since that pair is what your team will use later to trace activity to one service instance.
How to trace broker activity back to one service instance
The link between a RabbitMQ log line and an OpenBao lease is the generated username, so the naming template is the most important trace decision you make. Each dynamic credential is created with a username that OpenBao builds from the template you configure for the database connection, and that name is what RabbitMQ records in its connection and management events. Confirm the exact username format your RabbitMQ setup produces by creating a test lease and reading the user it returns, and confirm that the template includes enough of the role name, the application identifier and a unique suffix to separate one instance from another. A name that includes only the role will collide across replicas of the same service and cannot point to one instance.
Correlation then works in both directions. From a broker event, take the username and search the lease list for that name, or use the lease ID that OpenBao records when it issued the credential, to find the role, the requesting entity and the lease expiry. In the other direction, have each application log its lease ID at startup and whenever it renews, so that a connection in RabbitMQ can be matched to a log entry that names the same lease. Write this mapping down as a runbook step and test it with a deliberately short lease TTL, because a stale lease that no longer appears in OpenBao's list leaves you with a broker user you cannot explain.
What the broker keeps is the part you must verify yourself. Check which of RabbitMQ's connection, authentication and management events are enabled in your version, whether the username is included in each record, and how long those records are retained before rotation or shipping to your log platform. Ask whether connection tracking shows the client's address and client name so that the username can be paired with a host or pod. If retention is shorter than your longest lease, an investigation may find a credential in OpenBao with no surviving broker evidence, so set the log retention for the broker and the lease TTL together.
Security considerations for RabbitMQ credentials issued by OpenBao
Dynamic RabbitMQ credentials only reduce risk if the OpenBao cluster that issues them is well protected. The cards below cover the controls that connect the management credential, the role definitions, the broker connection, the application login, revocation and the audit trail.
Protect the root management credential
The OpenBao identity that creates RabbitMQ roles and connection settings can issue credentials for every service, so it is the most valuable target in this design. Keep the broker administrator password out of Git and out of role definitions where possible, store it in a restricted OpenBao path, and rotate it on a schedule your team can run. Confirm with your RabbitMQ and OpenBao documentation which account the plugin needs and whether its password can be rotated by OpenBao itself.
Limit who reads role definitions
A role definition shows which vhosts and permission patterns a service receives, which helps an attacker plan lateral movement. Use ACL policies so that each service identity can request credentials only from its own role path, and only platform administrators can read or change the role definitions. Review these policies whenever a new service is onboarded.
Encrypt traffic between OpenBao and the broker
OpenBao logs into RabbitMQ with the management credential and then creates users, so that traffic carries reusable secrets. Configure TLS on the RabbitMQ management interface and verify the certificate chain from the OpenBao host before the plugin is pointed at it. Ask your team to confirm how the plugin handles certificate validation settings and whether any setting disables verification.
Secure the application login method
An application needs a credential to ask OpenBao for its RabbitMQ user, and that first credential, often called secret-zero, is the weakest point if it is copied into a file or image. Prefer a platform-bound login method such as the Kubernetes or cloud identity options documented under OpenBao auth methods, or AppRole with a secret ID that is delivered once and expires. Test that a stolen secret ID cannot be reused outside the service's host.
Auth methods docsPlan revocation for incidents
When a service is compromised or an employee leaves, you need to revoke every active RabbitMQ user for that service quickly, not wait for leases to expire. Write a runbook that uses OpenBao's lease revocation for a specific role or path, and confirm that the RabbitMQ users are removed on the broker and that existing connections are closed. Rehearse this once before go-live.
Audit every credential issuance
Dynamic credentials are only traceable if each issuance is recorded with the requesting identity, the role and the lease. Enable an OpenBao audit device, send its logs to a store the platform team cannot silently edit, and map each generated RabbitMQ username back to the requesting service identity. Confirm that the audit output includes the lease ID so that broker logs and OpenBao logs can be matched during an investigation.
Questions teams ask before dynamic RabbitMQ credentials
What does dynamic RabbitMQ credential work cost, and what drives it up?
The cost comes from the people doing the work: the planning of roles and permissions, the OpenBao configuration, the changes to each application's connection code, and the testing against your broker. Most of the cost is one-time. Recurring cost is the operation of OpenBao and the broker, plus any retainer you add for upgrades. Effort rises with the number of services, the number of distinct permission sets, how many applications hold hard-coded broker passwords today, and whether your brokers already have a naming or virtual host model. Ask any partner for a quote that lists each service, each role, each virtual host and each deliverable separately, so you can compare scope rather than headline totals.
How long does a rollout take, and what sets the duration?
Duration depends on factors you can measure in your own environment rather than on a fixed number. The main ones are how many services need their own RabbitMQ user, how many virtual hosts and permission patterns you have, how many applications must change their connection code and deploy on their own release cycles, and how far your broker's current authentication setup is from the model you want. Rollouts usually move one service at a time, so the number of teams that must test and sign off also matters. Ask for a timeline in the written scope that ties each phase to these inputs.
What must our team provide before the work starts?
You need to provide three things at minimum: administrative access to the RabbitMQ brokers that will issue credentials, a current inventory of services that connect to them with the permissions each one uses, and a running OpenBao cluster that the engagement can reach over your network. Useful additions are the existing RabbitMQ user list, the queues and exchanges each service touches, a test environment that mirrors production broker configuration, and a named owner for each application team. Gaps in the inventory are the most common reason permissions turn out too broad or too narrow after go-live.
Can our own platform team do this without a partner?
Yes, if your team already runs OpenBao and RabbitMQ in production and has engineers who can write permission policies and change application connection logic. The work is not exotic, but it is cross-cutting: it touches the broker, the secrets platform, every consuming application and your audit process. Teams that do it alone usually underestimate the inventory step and the application changes. A partner can take on part of the work, such as the role design, the test harness or the documentation, while your team keeps ownership of the broker and the services. Decide the split in writing before you start.
How do application code changes look for dynamic RabbitMQ credentials?
Applications stop reading a fixed username and password from configuration and instead request a credential from OpenBao, or receive one through an agent that writes it to a file or environment variable. The application then opens its broker connection with that username. The code path that connects to RabbitMQ and handles reconnects must be able to fetch a new credential when the old one is revoked or expires. Reconnect logic, connection pooling and any health checks that reuse a cached connection are the parts that most often need attention. Test each service against a broker where leases are short to confirm that reconnects work before you shorten lease periods in production.
What happens to in-flight messages when a lease ends?
A lease ending revokes the RabbitMQ user that was created for it, which closes connections authenticated with that user. Messages already acknowledged by the broker are not affected by the revocation, but messages delivered and not yet acknowledged may be redelivered when the consumer reconnects. Your consumers must therefore be idempotent, and your publishers should handle connection drops by retrying. Plan lease lengths around your longest normal processing time and your renewal behavior, and confirm with your RabbitMQ and OpenBao documentation exactly how revocation treats open channels in your version before you rely on it.
How do we trace broker activity back to one service instance?
Because each dynamic credential is a separate RabbitMQ user, broker logs and connection listings show the username of the instance that connected, and OpenBao records which lease issued that username. You can therefore correlate a broker event with a lease and then with the service that requested it. Whether the username carries the service name or instance identifier depends on the role naming template you define, so decide that before rollout. Confirm the exact log fields your RabbitMQ version emits and how long your log and audit retention keeps them.
Limits to confirm in your RabbitMQ and OpenBao environment
Dynamic RabbitMQ credentials depend on three moving parts: the RabbitMQ management API, the OpenBao release and the account OpenBao uses to create users. Each one sets limits that the design must respect. Confirm them in writing with the vendor documentation and in a test environment before any service depends on generated users.
RabbitMQ version and management API support
The engine calls the RabbitMQ management API to create users, set permissions and revoke them. Confirm which RabbitMQ versions and management plugin behavior your OpenBao release supports, including how the plugin is enabled and which endpoints it uses. Test user creation, permission grants and deletion on the exact RabbitMQ version you run, not on a newer one from the documentation.
OpenBao docsPermissions for the management account
OpenBao needs a RabbitMQ account with enough rights to create users, set permissions per virtual host and delete users. Ask which tags and permissions that account requires in your RabbitMQ version, and whether a narrower account can do the job. Keep this account separate from human administrators, store its password in OpenBao, and plan rotation of its own credential.
Behavior of connections on lease revocation
Revoking a lease removes the generated user, but it does not automatically explain what happens to sockets that are already open. Test whether RabbitMQ closes existing connections for a deleted user, or whether they stay up until the client disconnects. Your applications need a reconnect path that fetches a fresh credential, and your runbooks need to state whether a revoke cuts traffic immediately.
Compatibility with the OpenBao release
Confirm the OpenBao release you plan to run supports the RabbitMQ engine and the features your design uses, such as per-role virtual hosts and tag handling. Check the release notes for changes in each minor line before upgrading. Pin the OpenBao version in your change process and retest the RabbitMQ role after each upgrade of either product.
OpenBao releasesUsername and tag limits
Check the maximum username length, the characters RabbitMQ accepts, and how the generated name is composed from the role and token metadata. Confirm which user tags can be assigned through the engine, since tags such as administrator grant broad access and should stay out of service roles. Long generated names can break log parsing or tracing, so verify them against your logging pipeline before rollout.
Lease TTLs and cleanup under load
Lease duration and the number of active leases determine how many RabbitMQ users exist at one time. Ask the vendor and test whether a large number of users slows the management API or the broker, and whether the cleanup of expired leases keeps pace with creation. Set maximum TTLs per role based on the longest-running consumer you expect, and record how cleanup failures surface in OpenBao logs.
Moving existing services off shared RabbitMQ logins
Start by building an inventory of every consumer and publisher that connects to RabbitMQ with a shared or hard-coded account, because you cannot retire a shared login safely until you know which services use it. For each service, record the username, the virtual hosts it touches, the exchanges and queues it declares, whether it publishes, consumes or both, and where its password lives today (a configuration file, a container image, a CI variable or a vault entry). Ask the teams that own each service to confirm the list, since queues are often used by a consumer nobody lists in the architecture diagram. Confirm with your RabbitMQ administrators which permission grants the shared account holds, so you know what each replacement role must match and where it is broader than necessary.
Pick one low-risk service as the pilot. Create a dynamic role in OpenBao for that service with the narrowest conf, write and read patterns that its inventory supports, then point the service at a leased user while the shared account keeps working for everyone else. During the dual-running period, both the old and new credentials are valid, so you can move services one at a time and roll back a single service without affecting the rest. Watch connection counts and authentication failures per username in RabbitMQ and in your logs. Keep the shared account active until every service in the inventory has cut over and you have seen a full business cycle without it being used. Confirm with your own team how long that observation window should be for your workloads.
Application changes are mostly about how credentials reach the process. A service that reads a static username and password from a file or environment variable must learn to fetch a new lease, and it must reconnect when the lease is renewed or replaced. Decide whether the application reads the secret at startup and restarts on rotation, or whether an agent or template renders the credential and signals a reload. Test what happens when a lease expires while a connection is open, when the broker restarts, and when OpenBao is unreachable at startup. Before you retire the shared account, run a test that confirms no service still authenticates with it, revoke it, then restart a sample of services and confirm they reconnect on leased users alone.
How DeployOpen scopes and delivers RabbitMQ credential work
RabbitMQ credential work touches broker permissions, OpenBao policy and every application that consumes a generated user, so it is scoped in writing before anything is built. The cards below follow the path from agreed scope through implementation, verification and handover to optional ongoing support.
Written scope and role model
Before work starts, the scope document names the RabbitMQ clusters, virtual hosts, applications and OpenBao roles in play, along with who approves new roles and who can read or rotate root credentials. Ask for the role model to list each permission pattern per service, since that list becomes the basis for testing later. Confirm whether your broker is in scope for configuration changes or only for the OpenBao side.
Storage docsImplementation in your infrastructure
The build runs in the cloud accounts, data centers or air-gapped networks you control, using your existing OpenBao cluster or one planned with you. Work covers the RabbitMQ database plugin configuration, the root connection that OpenBao uses to create users, and the network paths between OpenBao and the broker. Confirm who holds the root credential at handover and where it is stored.
Verification with your team
Your platform and security engineers review each generated role against the agreed permission model, and the work includes checks that a credential for one service cannot publish to or read from another service's queues. Lease expiry and revocation are tested with real connections, so cleanup is proven rather than assumed. Ask for the test list to be shared before it runs.
Documentation and handover
The handover package covers the role catalogue, how a new application requests a role, the lease TTLs chosen, and the username format used for tracing activity to a single instance. Your operators receive runbooks for rotating the root credential and for revoking a leaked lease. Ask for documentation written for your team's tooling, not generic instructions.
Optional retainer support
Once the system is live, a retainer can cover plugin and OpenBao upgrades, periodic permission reviews as new services join, and re-testing after broker changes. Cost has a one-time part (the build) and a recurring part (support hours and upgrade work), so ask for each to be quoted separately. The retainer scope should name which versions and which clusters it covers.

