OpenBao dynamic database credentials

Dynamic credentials replace shared, long-lived database passwords with short-lived accounts that OpenBao issues per application and revokes automatically. This page covers the design decisions, build sequence, effort drivers and checks needed to run it in your own infrastructure.

On this page

Why teams replace static database passwords with OpenBao dynamic credentials

OpenBao dynamic secrets issue per-request database credentials with a lease and automatic revocation, so each application instance or job gets its own short-lived login instead of sharing one password stored in a config file, a vault entry or a CI variable. If your team cannot say which workload used a given database password last month, or when it was last rotated, the static model is the problem, and dynamic credentials are the usual fix. OpenBao documents dynamic secrets for SQL databases, so this pattern is supported by the product rather than something you would need to build around it.

The approach is harder than it looks. Applications must handle credentials that expire, which means renewing leases before they lapse or re-requesting credentials cleanly when they do, and many existing connection pools were not written with this in mind. Database roles need careful scoping: each role's creation statements and privileges should grant only what that workload needs, because an overly broad role multiplies the blast radius of every credential it issues. Revocation must also be planned. Revoking a lease removes access, so a running service that has not been moved to renewal logic can fail in production. Confirm your database engine's behavior for active sessions on revocation and test the failure path before you cut over.

Teams usually need this when one of three things happens. An auditor or internal control owner asks for evidence of credential lifecycle management, such as who received access, for how long, and how it was withdrawn. A breach or suspected leak forces a question about which credentials are exposed and how quickly they can be cut off, which is hard to answer when one password serves many services. Or many services share a single database account, so rotating it means coordinating dozens of deployments. Before committing, check with your security and database teams which of these drives the work, which database engines and versions are in scope, and whether your applications can accept short-lived credentials. The OpenBao documentation on dynamic secrets is the natural starting point for confirming the supported behavior for your engine.

Which OpenBao components make dynamic database credentials work

Dynamic database credentials depend on a small set of OpenBao components that work together: a secrets engine, a connection to your database, roles that define each account, leases that track each issued credential, policies that control who can ask, and a storage backend that keeps the lease records. Understanding how these pieces connect is the starting point for any design review.

Database secrets engine mount

The database secrets engine is mounted on the OpenBao cluster at a path you choose, and it is the component that creates and deletes database users on request. Each mount serves one or more database connections, so mount design shapes how teams and environments are separated. Confirm which database engine plugins your OpenBao version ships with and whether your database type is supported before you plan the mount layout.

Database connection configuration

The connection configuration stores the address of the database and the privileged account OpenBao uses to create and revoke users. This account is the most sensitive credential in the design, so it should have only the rights needed to manage users and should be rotated through OpenBao where your database supports it. Ask your database team which privileges are required for your engine and how the connection will be restricted at the network level.

Roles with creation and revocation statements

A role maps a name that applications request to the SQL statements that create a user, grant it privileges, and remove it later. Each role defines how long credentials live and what access they carry, so one role usually matches one application or one privilege level. The exact statement templates differ by database engine, so confirm them against the current OpenBao database secrets documentation for your engine before using them in production.

Leases, renewal and maximum durations

Every generated credential is issued with a lease that records its time to live and the longest period it can be renewed. When a lease expires or is revoked, OpenBao runs the revocation statement, which removes the database account automatically. Set short default durations for applications that restart often and longer ones only where renewal is reliable. Confirm the default and maximum lease settings for each role in the current documentation.

Policies for role paths

Policies decide which identities can read credentials from each role path, such as the path for one application's read-only role. Keeping one policy per role limits the blast radius if an application identity is compromised. Review policies whenever a new role is added, because a broad wildcard on the database path can grant access to every account a team is allowed to request.

Storage backend holding lease records

The storage backend holds the encrypted data OpenBao needs, including the lease records that link each generated account to its revocation schedule. If the backend loses lease records, OpenBao cannot revoke accounts it issued, so the database may keep users that should be gone. Choose integrated storage (Raft) or PostgreSQL based on your team's operating skills, and make backup and restore testing part of the plan.

Storage backend docs

Which decisions shape OpenBao dynamic database credentials

This table compares the five decisions that most affect a dynamic database credentials rollout: role design, lease duration, how applications receive credentials, namespace layout and the cluster storage backend. Read each row for the fit it suits and the operating cost it adds, then confirm the choices against your own audit and staffing constraints before you build.

DecisionOption and fitOperational cost
Role scopeOne role per application gives each consumer its own database identity, so audit logs name the caller directly. Best when apps have distinct privileges.More roles to define, review and rotate as applications change. Ask who owns role creation and removal.
Role scopeShared roles per privilege level (for example, read-only or migration) keep the role count small and simple to review.Audit logs show a privilege level, not a specific application, so attribution depends on other signals. Confirm your audit requirement first.
Lease durationShort leases shrink the window in which a leaked credential is valid and force revocation to happen quickly.Applications must renew more often, which adds load and failure points for long-running services. Test renewal under database restarts.
Lease durationLonger leases reduce renewal traffic and suit batch jobs or services with fragile renewal logic.A stolen credential stays usable longer. Pair longer leases with clear revocation procedures and monitoring of lease counts.
Credential deliveryApplication calls the OpenBao API directly and holds the credential in memory. Requires a code change but keeps secrets off disk.Developers must handle authentication, renewal and errors in each language or service. Budget time for library work and tests.
Credential deliveryA sidecar or agent authenticates and writes the credential to a file for the app to read. Fits legacy software that cannot change.Files on disk need permissions, rotation signaling and cleanup. Review who can read the file and where the agent runs.
Namespace layoutA dedicated namespace per team isolates policies, mounts and administrators, which suits multi-team clusters.Each namespace needs its own admin process, policy set and review cycle. Confirm who administers each namespace.
Namespace layoutOne shared mount for all teams is simpler to run with fewer moving parts.Policy mistakes affect more teams, and separation depends entirely on path-based policies. Review policies on every change.
Cluster storagePostgreSQL as the backend is described in the OpenBao docs as easier to operate safely than Raft, and suits teams already running PostgreSQL operations.Database backups, failover and version upgrades of PostgreSQL become part of OpenBao operations. Confirm DBA ownership.
Cluster storageIntegrated storage (Raft) keeps the cluster self-contained with no external database dependency.The docs describe Raft as harder to operate safely, so plan for member replacement, snapshots and failure drills by trained staff.

How to configure OpenBao dynamic database credentials step by step

This sequence takes a database from static shared passwords to OpenBao-issued, short-lived credentials, with each consumer limited to its own role and every step closed by a check you can run.

  1. Enable the database secrets engine at a path

    The platform team mounts the database secrets engine at a dedicated path, such as database/ for a single environment, or a separate path per environment so that policies and audit entries stay easy to read. Use a namespace if your cluster serves several tenants. Confirm the mount exists with the list-mounts command and check that the path appears with the database engine type. Keep the path name consistent across environments, since every later policy and role will reference it.

  2. Create a dedicated database account for OpenBao

    The database administrator creates a separate account that OpenBao uses only to manage other users. Grant it rights to create and revoke users and to change their passwords, and nothing else. It should not own application schemas or hold read access to business data. Confirm the account by logging in with it directly and checking that it cannot read application tables, and that it can create and drop a throwaway test user. The exact grants differ by engine, so confirm them against the official secrets engine documentation for your database.

  3. Configure the connection and its rotation plan

    Write the connection configuration with the connection string, the plugin for your database, and the dedicated account's credentials. Then decide how that account's own password will be rotated, since OpenBao can manage its root credential after configuration. Agree the rotation schedule and the owner of any manual step with the database team before go-live. Verify the connection by reading the connection configuration back and confirming that the password is not returned in plain text. Record who can rotate it and how that action is audited.

  4. Define one role per consumer

    Create a database role for each application or service, and write creation statements that grant only the privileges that consumer needs, such as read on specific schemas or write on specific tables. Avoid shared roles that serve several applications, because revocation and audit then become ambiguous. Keep a short register that maps each role to its application owner. Verify each role by requesting a credential and connecting with it, confirming that it can perform the intended queries and is refused on anything outside its grant.

  5. Set default and maximum lease durations

    Set a default lease duration and a maximum lease duration on each role. The default governs how long a fresh credential lasts, and the maximum caps how long renewals can extend it. Choose values with the application owner based on how long its connections and restarts realistically last, and document the reasoning in the role description. Confirm the settings by requesting a credential and checking that the lease TTL and maximum match the role configuration. Note that your chosen values are an organizational decision, not a fixed default from the product.

  6. Create policies that read only matching role paths

    Write one policy per consumer that allows the read capability on the credential path for its own role only, plus renew and revoke on its own leases where the application needs them. Do not grant list or wildcard access across the database mount. Attach each policy to the matching identity. Verify with the policy test tooling that the application identity can read its own role, and that it receives a permission denied response for any other role path.

  7. Configure the application's auth method

    Connect each workload to OpenBao with an auth method suited to where it runs. For servers, the documented recommendation is AppRole, with the role ID delivered by configuration management and the secret ID delivered by a trusted process with a limited use count. For Kubernetes workloads or identities issued by an OIDC provider, use the Kubernetes or JWT/OIDC method instead. Confirm the login by authenticating as the application and receiving a token bound to exactly the policy you created in the previous step.

  8. Test issuance, renewal and revocation before cutover

    Run a scripted test that requests a credential, connects with it, renews the lease, and then revokes it, confirming the database account disappears after revocation. Repeat the test for each role and check the audit device logs for each request. Also test a bulk revocation for one role in a non-production environment. Only switch the application to dynamic credentials when every test passes and the application has been tested to reconnect after a lease expires. Keep the old static password available for rollback until the cutover is accepted.

How a database credential request flows through OpenBao

The flow starts with an application authenticating to OpenBao through its auth method, which returns a token bound to policies. OpenBao checks that policy against the database role path before it asks the database, over a privileged connection, to create a short-lived user. The application then connects with that user and must renew its lease before expiry. When the lease ends or is revoked, OpenBao drops the user, so the boundary between the OpenBao cluster and the database network is where you should check connectivity, privilege scope and revocation behavior.

Credential issuance, use, renewal and revocation across the trust boundary.

What drives effort in a dynamic database credentials rollout

This table lists the factors that change the size of a dynamic credentials project and, for each one, how to keep it under control. Read it as a checklist for scoping: the largest item is usually application change and testing, not OpenBao configuration.

DriverWhy it changes effortHow to keep it down
Number of databases and enginesEach engine or database version needs its own secrets engine connection, role templates, revocation statements and test cases.Start with the engines that hold the most sensitive data, and standardize role naming and grant templates across them.
Number of applicationsEvery application needs a path to request credentials, a policy that limits what it can request, and a test of its behavior when credentials change.Group applications by shared connection pattern and onboard one group at a time.
Application code changesApplications built around a static username and password usually need changes to fetch credentials at startup, renew leases and reconnect without downtime.Ask for an inventory of how each application reads its database password today, and prioritize those that already read it from configuration rather than hardcoded values.
Languages and drivers with weak credential refreshSome connection pools and drivers cache credentials for the life of the process or do not reconnect cleanly when a password changes, which forces restarts or custom code.Test each language and driver in a staging environment early, and record which ones need a pool rebuild or a restart on rotation.
Compliance evidence for credential lifecycleAssessors may ask for proof of who can request credentials, how long they last, how revocation works and where requests are logged, which adds documentation and log configuration work.Confirm the evidence list with your assessor before design starts, and collect audit device output from the first test environment.
Number of environmentsDevelopment, staging and production each need their own mounts, roles, policies and connection settings, and each needs its own verification.Keep configuration in version-controlled code so that environments differ only in variables.
Namespaces and multi-team administrationSeveral teams sharing one cluster need separate namespaces, delegated administration and clear ownership of each database role.Decide the namespace layout and administrator roles before building roles, since moving them later changes paths that applications depend on.
Privileged account rotationThe account OpenBao uses to create and revoke database users must itself be rotated and protected, and the rotation process has to be tested against live connections.Agree the rotation procedure and its owner during scoping, and test it in staging before the first production role is created.

How the design changes for single node, HA, Kubernetes and air-gapped setups

A single OpenBao node is a reasonable shape for a lab or a small pilot where the goal is to prove the database secrets engine, policies and application onboarding. The design is simpler because there is one storage backend, one unseal process and no leader election to reason about. The trade-off is that a single node is a single point of failure for every application that now depends on it for database credentials, so it should not be treated as the production design.

  • Storage choice: Integrated storage (Raft) or PostgreSQL can both run with one node, but the pilot should use the backend you intend to operate in production.
  • Database role templates: Write the database connection and role definitions in a way that can be exported and reapplied on a larger cluster.
  • Lease tuning: Test short default and maximum lease durations early, because application renewal behavior is what the pilot is really validating.
  • Recovery path: Document how the unseal material is held and how the node is restored, even for a lab.
  • Promotion gap: Plan the move to HA as a separate step with its own testing, not as an afterthought.

Confirm with your team whether the pilot data and database accounts are isolated from production, and whether the single node is clearly labeled as non-production.

Access control and handling of generated database credentials

Dynamic credentials only reduce risk if the paths that create them are narrow, the privileged account behind them is guarded, and the generated values stay out of places they should never reach. The cards below cover the decisions and checks that connect issuance, policy, logging and handling for OpenBao dynamic database credentials.

Least-privilege creation statements

The creation_statements in a database role define exactly what each generated user can do, so they are the first place excess access appears. Grant only the schema objects and privileges the application needs, and avoid roles that inherit broad grants. Check: create a test credential from the role, connect with it, and confirm that writes to tables outside the application's schema are refused.

Namespaces docs

One policy per application path

Attach each application's policy to a single database role path, such as database/creds/<role>, and nothing wider. A policy that covers a glob of role paths lets one workload request credentials meant for another. Check: using the application's token, read the path for a sibling role and confirm the request is denied.

Protecting the privileged connection account

OpenBao uses a privileged database account to create and revoke the generated users, so this account is the highest-value target in the design. Keep it separate from any application login, restrict its network path to OpenBao, and rotate its password through OpenBao so no person knows the current value. Check: confirm that the rotated password is not present in configuration files, shell history or tickets.

Keeping credentials out of logs and code

Generated usernames and passwords tend to leak through application debug logs, crash dumps, environment listings and committed configuration. Have applications request credentials at runtime and hold them in memory, and keep secret paths, not values, in manifests. Check: search log storage, container environment output and the repository history for a sample generated username.

Audit logging of issuance and revocation

Enable an audit device so every credential issuance and revocation is recorded with the requesting identity and path. Without this record, a leaked credential cannot be traced to a workload or a lease. Confirm which fields your audit device records and where logs are shipped, and test that a revocation event appears in your log store. Check: issue and revoke one credential and find both events.

Namespaces docs

Restricting who changes role definitions

Anyone who can update a database role can change its grants or redirect its connection, which bypasses the application policies entirely. Limit write access on the database secrets engine configuration and role paths to a small platform group, and review those policies on a regular schedule. Check: log in as a developer token and confirm that updates to a role definition are refused while reads of approved paths still work.

How to test that dynamic credentials work and fail safely

Test the happy path first, but test it end to end. Request a credential from the database secrets engine for one role, then log in to the database with exactly the username and password OpenBao returned, from the same network path and runtime your application uses. Next, check what that account can actually do. Run the statements the role was meant to allow and a few it was not, such as writes from a read-only role or access to schemas outside the grant. The generated account should carry only the privileges in the role's creation statements, so a failed denied action is a passing test. Then renew the lease and confirm the database user still exists and still authenticates, so you know renewal does not silently create a second account or drop the first one.

Next, test the ends of the lifecycle. Let a lease expire without renewal and confirm the database user is removed, not just disabled, by attempting a login with the old credential and querying the database's user catalog. Then revoke one lease explicitly through the lease revoke path and confirm that only that user disappears. Finally, revoke everything issued under a role with bulk revocation and confirm every matching account is gone while the role definition and the privileged connection remain intact. Set all waiting periods from your own configured default and maximum lease TTLs rather than from any example value, and record the exact times so you can match them to audit entries.

The most important tests are the failure ones, and they are not assumed to work. Make OpenBao unreachable from the application host and confirm what the application does: whether it keeps using its cached credential until that lease approaches expiry, how it retries, and whether it fails closed or opens a connection with stale data. Then rotate or break the privileged connection that OpenBao uses to create database users, and confirm that issuance fails with a clear error and that existing leases keep working until they expire. In audit records, expect a request entry and a response entry for each issuance, renewal and revocation, with the requesting entity and the role name, and a failure entry when the database call is rejected. Confirm that the database password does not appear in plaintext in those logs, and that your audit device is writing before you trust the results.

What to monitor, back up, upgrade and document after go-live

Once applications pull credentials from OpenBao instead of holding static passwords, the database role definitions, lease behavior and ownership records become the things that keep the system working. The cards below cover what to watch, what to back up, how to upgrade without losing role configuration, and what to write down so the next team can operate it.

Monitor lease counts and revocation errors

Track the number of active leases per database role, the rate of renewal failures, and any revocation errors that leave database users behind. A rising lease count with flat application traffic often points to clients that request credentials but never release them, or to lease durations set longer than needed. Revocation errors matter most, because a failed revocation leaves a live database account that nothing in OpenBao is tracking as expired. Confirm your audit and telemetry pipeline captures these events and alerts on them.

HA docs

Back up storage with role definitions

Backups of the cluster storage hold the secrets engine mount and database role definitions, so a restore must bring back both the data and the configuration that tells OpenBao how to create users. Test a restore into a separate environment and confirm that roles, connection settings and policies come back intact and that a new credential can be issued. Store the database connection details and privileged account handling in the same recovery plan, since a restored role without a working connection will fail on its first request.

Upgrade while keeping roles intact

Upgrades should preserve the database secrets engine configuration and every role, but confirm this on a staging copy before touching production. Follow the OpenBao release lines and read the release notes for changes to the database plugin behavior, lease handling and configuration keys. Check that the database plugin you rely on still loads and that a test role issues and revokes credentials after each upgrade. General cluster upgrade mechanics are covered in the upgrades and support topic.

Latest patch cited
2.7.1
OpenBao releases

Rotate the privileged database account

OpenBao connects to the database with a privileged account that creates and drops every dynamic user, so that account is the most sensitive credential in the design. Set a rotation schedule, have OpenBao rotate its own root credential where your database engine supports it, and confirm that applications never see this account. Record who may trigger a manual rotation and what the team checks afterward, including that existing dynamic credentials still work.

Document role-to-application ownership

Each database role should map to a named application, a named owning team and a stated reason for its privileges. Keep this record current as services are added, renamed or retired, because an orphaned role is hard to justify in an access review. Include the onboarding procedure for new services: the approval step, the role request, the lease duration chosen and the test that proves the application can renew and recover. Ask your compliance lead which evidence format your assessors expect for access records.

Inventory applications that support credential refresh

Dynamic credentials only reduce risk if applications can fetch new credentials and handle expiry without a restart. Keep an inventory listing each application, whether it re-reads credentials at runtime, how it reacts when a lease expires, and who tested that behavior. Applications without refresh support need a planned exception, such as a shorter restart cycle or a documented interim use of a static account, and that exception should carry an owner and a review date.

What buyers and engineers ask before adding OpenBao dynamic database credentials

How much effort does moving database access to OpenBao dynamic credentials take?

Effort depends mainly on how many databases, applications and credential consumers are involved, not on the OpenBao configuration itself. Each database needs a secrets engine connection and a role that defines the SQL statements used to create and revoke users. Each application then needs a way to authenticate to OpenBao, read credentials at runtime and handle lease renewal and expiry. The largest share of work is usually in the applications: connection pool handling, restart behavior and testing. A quote should break the work into database connections, role design, auth method setup per consumer, application changes, test runs and handover, with each item tied to a named system. Ask for the assumptions behind each line so you can see what would change the total.

How long does a dynamic database credentials rollout take?

The timeline is set by the number of applications that must change and by the change windows available to each owner, rather than by the OpenBao setup. The platform work, including the database secrets engine and role design, can proceed in parallel with application teams preparing their code. Each application then moves through test, staging and production cutover on its own schedule. Dependencies that commonly extend the timeline include database administrators who must approve a dedicated account for OpenBao, applications with long-running jobs that cannot restart during business hours, and compliance reviews of the new access path. Ask any partner to show the timeline as a list of per-application milestones with the client-side dependencies marked.

What does the client need to provide for this work?

The client needs to provide access and people, and the work cannot proceed without them. Typical requirements are:

  • An administrative account on each target database, or a DBA who can create the OpenBao management user and grant it the privileges needed to create and drop roles.
  • Named owners for each application who can confirm connection behavior, restart procedures and rollback options.
  • Test environments that mirror production database engines and versions, so lease behavior can be verified before cutover.
  • Change windows for each production cutover and for any database configuration change.
  • A decision on which identity source applications will use to authenticate to OpenBao.

Confirm these items early, because access requests are often the longest lead item in a scope.

Can our own team implement OpenBao dynamic database credentials without a partner?

Yes, a capable internal team can implement this using OpenBao's documented steps, provided it has database administration skills and secrets administration skills. The database side needs someone who understands least-privilege grants, role creation and how the chosen engine handles user creation and revocation. The secrets side needs someone who can configure auth methods, policies and leases, and who can design the lease durations that match each application's behavior. The harder part is usually application change work, which requires developers who can handle credential rotation without dropping connections. A partner is most useful when the team lacks one of these skill sets, when the number of applications is large, or when the work must produce evidence for a compliance assessment. DeployOpen does not issue audit reports, so evidence preparation is a separate scope item to define in writing.

Can existing static database passwords be replaced without downtime?

Usually yes, but only if the cutover is staged application by application and each application can reload credentials without a full outage. The common pattern is to create the dynamic role first, have the application read from OpenBao in a test environment, then move production traffic while the old static account stays valid for a defined overlap period. Once an application has been confirmed on dynamic credentials, the static password can be rotated or removed. Downtime risk comes from applications that cache connection strings, pools that do not refresh, and scheduled jobs that hold connections for long periods. Each application needs its own rollback plan, and the static account should not be deleted until all consumers have moved. Ask for the cutover plan per application in any written scope.

Which databases and applications need the most change?

The most change usually falls on applications that hard-code connection strings, keep long-lived connection pools, or run as scheduled or batch jobs that expect a fixed password. These need code or configuration changes to fetch credentials at startup or per connection, and to handle expiry. Databases differ in how they create and revoke users, how they name roles and how they handle active sessions when a lease ends, so the role definitions must be tested against each engine and version in use. Legacy systems that cannot be restarted or that authenticate through shared accounts often need the longest analysis. Start with an inventory that lists every consumer of each static account, because the consumers you do not know about are the ones most likely to break at cutover.

What should we ask a partner to include in a written scope?

A written scope should state exactly what is delivered, what the client provides and how each item is verified. Ask the partner to list the databases in scope by engine and version, the applications and their owners, and the auth method each consumer will use. The scope should include role and lease design with the reasoning for each duration, the cutover plan per application with rollback steps, the test evidence required before production, and the handover documents for the operations team. Ask how lease renewal failures and database outages are handled in the design, which changes are excluded, and how post-cutover support is provided. DeployOpen works from fixed-scope written agreements with deliverables and timelines agreed before work starts, and quotes follow from that scope. Ask the partner to show the assumptions behind each estimate.

How DeployOpen scopes, builds and hands over OpenBao dynamic database credentials

DeployOpen plans and implements OpenBao dynamic database credentials inside your own infrastructure, so the secrets engine, database roles and application onboarding are reviewed by your security and platform teams. Each engagement starts from a written scope, and the work is documented so your team can run it after handover.

How we scope

  • Inventory which databases and applications currently rely on static passwords, and who owns each credential.
  • Agree the database engines, role definitions and maximum lease durations in the written scope before work starts.
  • Confirm the auth methods applications will use to request credentials, such as AppRole for servers or Kubernetes for workloads.

How we build

  • Configure the database secrets engine and creation statements per role, so each request gets a unique, least-privilege account.
  • Set lease and renewal behavior, then test automatic revocation and bulk revocation against a non-production database first.
  • Onboard applications one at a time, replacing static passwords and confirming each service reconnects on its own.

How we hand over

  • Deliver configuration, policy files and runbooks for issuing, renewing and revoking database credentials.
  • Document the audit logging and lease monitoring your security team needs to review the setup independently.
  • Walk your platform and application teams through rotation of the root database credential and what to do on lease failures.

How we support

  • Ongoing support, upgrades and continuous testing are available as a retainer after handover.
  • Retesting covers role definitions, lease settings and application onboarding whenever your database estate changes.
  • Confirm with DeployOpen which support level and response terms apply before the scope is signed.

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.