OpenBao TOTP secrets engine as a code generator or provider

How to use OpenBao's TOTP secrets engine to generate codes for shared service accounts or to validate codes for your own applications, and what to plan before you build it.

On this page

When an OpenBao TOTP secrets engine fits your login and MFA design

The OpenBao TOTP secrets engine either generates time-based one-time passwords from a key stored in OpenBao, or creates keys and validates codes that your own applications submit. Teams usually reach for it when a shared service account must answer a one-time code prompt, such as a legacy tool or a vendor console that accepts only TOTP, and no single person should hold the authenticator. The code is produced on demand by a system you control, so the seed never has to be copied into a phone app. The same engine fits an application that must verify codes for its own users without building TOTP handling itself.

Do not use it as a substitute for per-person MFA on workforce sign-in. A shared TOTP key used by several people removes individual accountability, because anyone who can read the secret can produce valid codes. Custody is the other trade-off: when OpenBao stores the seed and also generates the code, whoever can read that secret path can impersonate the account's second factor, so the factor is only as strong as the policies around it. Check how OpenBao's login MFA and auth method options apply to your sign-in flow before deciding where the second factor should live.

Before you commit, confirm three things in your own environment: whether the TOTP engine is available in the OpenBao release you plan to run, which system will submit codes (an automation client or your application), and who your auditors expect to own the second factor. Write an explicit policy so that only named automation can read the key, and decide whether a person will ever type a code or whether a service will request one. If people sign in with personal authenticators, a standard identity provider with MFA is usually the better-fitting design, and OpenBao's role is to hold the secrets those signed-in workloads need.

Generator mode versus provider mode: which one you are building

OpenBao can hold a TOTP seed and produce codes for someone else to use, or it can create keys for your application and check codes that users submit. The right choice depends on who should hold the seed, where the code gets typed or checked, and what your audit trail must prove.

Generator mode: OpenBao holds the seed

In generator mode, OpenBao stores the TOTP key for a shared account and returns a current code when an authorized caller asks for one. The seed never leaves OpenBao in this design, so the caller only ever sees a six-digit value that expires. Confirm with the engine documentation whether the key can be read back in any form, since that determines whether the seed can be exported.

Provider mode: your application holds the check

In provider mode, OpenBao creates a key for each user or account, your application stores the enrollment result, and OpenBao validates codes that the application submits. Your app then decides what a valid code unlocks. Plan how enrollment material reaches the user, because the QR or key shown at setup is the moment the seed is most exposed.

Where generated codes are consumed

Generator codes usually feed a jump host login, a vendor portal, a legacy tool or an automation job that cannot receive a push or hardware factor. Provider codes are consumed inside your login flow through an API call made by your own service. Map each consumer before choosing a mode, because a generator code that is pasted into a chat or ticket has left the control point you designed.

Audit trail in generator mode

Each code request is a read of a secret, so OpenBao's audit log records who asked and when. For a shared service account, that record shows which identity fetched the code but not which human ultimately used it. Pair the request path with a per-person authentication method, and decide whether the downstream system needs its own login record to close that gap.

Audit trail in provider mode

Provider mode records key creation and validation calls, so you can show which accounts were enrolled and how many validation attempts failed. The record is only as complete as your application's logging, since OpenBao cannot see whether a validated user was then allowed into a system. Confirm which fields the validation response returns and forward those, along with your app's session events, to your central log store.

Configuration options and when each fits

This table compares the main TOTP engine choices for a shared service account against an application login, and shows which settings to confirm before building. Parameter names and defaults should be checked in the current OpenBao TOTP documentation before any configuration is written. The main takeaway is that generated keys suit people who scan a code, while imported keys and tight validation policies suit applications that must check codes themselves.

DecisionShared service accountApplication login (provider mode)
Key origin (generated or imported)Generate the key inside OpenBao so the secret never leaves the engine, then share the QR or setup key through a controlled channel.Import a key when an existing system already holds the seed, or generate one when OpenBao should be the only holder.
Issuer and account nameSet a clear issuer and an account name that names the shared account, so authenticator entries are traceable to the team.Set the issuer to the application and the account name to the user or tenant, so codes can be matched in logs and support cases.
Period, digits and algorithmKeep the defaults that the target service accepts, since a shared login must match what the remote system expects.Match these exactly to the relying party's requirements, because a mismatch causes every login to fail with no clear error.
Skew toleranceUse a small window and confirm clock sync on the people or devices that enter codes.Set skew to balance user clock drift against replay risk, and document the value for the security review.
Read path (retrieve current code)Restrict reads to a named group or a short-lived token so that only the team that logs in can see the current code.Usually the application does not read codes. Avoid granting read to the app role unless a workflow needs it.
Validate path (check a submitted code)Rarely used for shared accounts. Keep it off unless a relying system asks OpenBao to verify codes.The core provider use. Grant validate only to the application role that performs the login check.
Create and delete keysLimit to platform administrators, with changes recorded in audit logs.Limit to a provisioning role, separate from the role that validates codes.
Policy designWrite policies that name the key path and the team group, and test that other tokens are denied.Write one policy per application or tenant path, and confirm with a negative test that one app cannot validate another's codes.

How to set up the TOTP engine in a running cluster

This sequence takes a running OpenBao cluster from a disabled TOTP engine to a tested setup where named identities can read or validate codes, with each step confirmed before the next one starts.

  1. Confirm the cluster and namespace target

    Before enabling anything, the platform engineer confirms the cluster is unsealed, healthy and reachable through the address the team will use, and decides which namespace will own the TOTP engine if the cluster uses namespaces for tenant isolation. Namespaces are documented as a way to isolate tenants within one cluster, so the choice affects which policies and paths apply later. Record the namespace path and the mount path in the change record. Done means a token with administrative rights in that namespace can list the existing mounts and the health endpoint returns a healthy status.

  2. Enable the TOTP engine on a dedicated path

    The platform engineer enables the TOTP secrets engine on a dedicated mount path, such as one named for the team or purpose, rather than a shared default. A dedicated path keeps policies narrow and makes audit entries easier to read. Confirm the exact enable command and plugin availability against the OpenBao version your cluster runs, since engine behavior is documented per release. Done means the mount appears in the list of enabled engines with the expected path and type.

  3. Create a key for one test account

    Using a single test account that is not yet in production use, the engineer creates a TOTP key on the mount and chooses whether the engine generates the key material or accepts an existing secret from the service's current provider. Generated-key mode suits cases where OpenBao is the code generator, while imported keys suit migration from another authenticator. Record the issuer, account name, digits, period and algorithm the key uses so the verification step can match them. Done means reading the key path returns the settings the engineer chose, with the secret field withheld from the read output as documented for the engine.

  4. Verify codes against an independent TOTP client

    The engineer adds the same key to an independent, standard TOTP app or command-line tool, then asks OpenBao for a current code and compares the two values for the same time window. Matching codes show the algorithm, digits and period agree with what the application expects. If they differ, check digits, period and algorithm first, then the clock on the host running the verification. Done means at least one generated code is accepted by the independent client and one code from the independent client is accepted by OpenBao's validate operation.

  5. Restrict reads and validation with policies

    The security engineer writes policies that grant the code-generation path only to the named identities that need it, and the validation path only to the application roles that check codes. Keep read access to key definitions separate from generate and validate rights, and check that the policy does not grant broad list or wildcard access across the mount. Attach the policies to the chosen auth method roles, not to the root token. Done means a test identity with the intended role can generate or validate, and a second identity without the role receives a permission-denied response for the same paths.

  6. Confirm audit entries and clock sync

    The operator confirms that an audit device is enabled and that each generate and validate request appears in the audit log without exposing the secret or the code in plain text, which should be checked against the audit settings the team chose. The operator also checks time synchronization on every node that validates codes, because TOTP codes depend on the clock matching within the accepted window. Document the time source each node uses and the drift check that runs. Done means a test request appears in the audit log with the expected identity and path, and every node reports synchronized time from the agreed source.

  7. Test failure behavior before go-live

    The engineer tests what happens when the expected failures occur: a sealed or unreachable cluster, a node with drifted time, a revoked test identity, and a code submitted after the window has passed. For each case, record the error the calling application receives and confirm the application fails closed rather than accepting a stale or missing code. Decide in advance whether the team will fall back to a second factor or a support procedure during outages and document it. Done means each failure case has a recorded result, a documented expected behavior, and an owner for the fallback process.

How OpenBao stores and uses TOTP keys

A TOTP seed held in OpenBao is only as protected as the storage layer and the access controls around it, so the first thing to plan is where the key lives and who can read it. OpenBao encrypts secret data before it is written to its storage backend, whether that is integrated storage (Raft), PostgreSQL, PebbleDB or in-memory, so the seed is not sitting in clear text in the database files. That general behavior applies to the TOTP engine as well as to key/value secrets. Confirm with the OpenBao TOTP engine documentation whether the engine ever returns the seed itself on read or at key creation, and whether it can be exported, because that answer decides how tightly you must restrict the read path.

Encryption at rest does not limit who can ask OpenBao for the key. Any token or identity with a policy that permits reading the TOTP key path, or generating codes from it, can use the seed through the API. The practical control is therefore the policy layer: grant the generate-code capability to the application or the shared service account, and keep read and update capabilities on the key itself for a small administrative group. Review that split whenever a new consumer is added, and check that audit logging records each code request so a misuse pattern is visible. Namespaces can separate keys belonging to different tenants inside one cluster, which limits accidental cross-team access.

A code is trustworthy only if the seed behind it has not left the controlled path. If someone copies the seed once, every code they generate afterwards looks valid, and OpenBao cannot tell the difference between the legitimate holder and the copy. Treat a TOTP key like a credential: record who created it, limit who holds the admin policy that can read it, and plan a rotation procedure that issues a new key and retires the old one. Before go-live, test the read path with a non-admin token, confirm that the seed does not appear in responses or logs for ordinary code requests, and write down the steps for revoking access if a token or host is compromised.

Two flows share one TOTP engine, and the authenticator sits outside OpenBao

The diagram shows two flows that share one OpenBao TOTP engine. In generator mode, an automation job authenticates with its policy identity and receives a current code for a shared service account. In provider mode, the application submits a code a user read from their authenticator app, and OpenBao returns whether it validates. The OpenBao cluster is the trust boundary: the authenticator app sits outside it, so the shared key is enrolled out of band. Check which identities can read codes, who can create keys, and whether the application treats OpenBao's answer as the only check.

Generator and provider flows meet at the OpenBao policy check and TOTP engine.

Security risks in TOTP-backed service accounts

A TOTP generator changes the trust model: whoever can read a seed or ask for a code can act as the account holder. The cards below cover the failure modes that matter most when OpenBao holds the seed for shared service accounts or validates codes for your applications, along with the control to put in place for each.

Shared codes weaken the second factor

If OpenBao generates codes for a shared service account and many people or pipelines can request them, the code no longer proves that a specific person is present. Limit code generation to named workloads or a small approval group, and keep human users on their own enrolled factors. Use login MFA on the OpenBao side so that the people requesting codes must first pass a stronger check. Confirm which callers can reach the TOTP path before go-live.

Auth methods docs

Seed exposure through broad read policies

A TOTP seed is a long-lived secret. Any token whose policy can read the key path can copy it and generate codes outside OpenBao indefinitely. Write policies that grant the generate or validate capability on the TOTP path and deny read on the key itself, then review wildcard paths in every policy attached to CI roles and AppRole identities. Test the policy with a token that should fail to read the seed.

Clock drift causing lockouts

TOTP codes depend on the time of the generator and the validator. A host with a skewed clock can produce codes that the validating side rejects, which locks out the service account at the worst moment. Keep all OpenBao nodes and client hosts on synchronized time, and set an explicit skew allowance in the key configuration. Monitor failed validations so drift shows up before users report it.

Replay of a valid code

A code remains valid for a short window, so a captured code can be reused within that window if the validator accepts it more than once. Ask the team deploying the validation side whether used codes are tracked and rejected for reuse, and confirm the replay behavior in the version you run. Where your applications accept codes directly, store the last accepted time step per account and refuse any code that is not newer.

Audit gaps behind shared accounts

When a single service account generates every code, audit logs show the account name but not the person or pipeline that asked for the code. Require each caller to authenticate with its own identity, such as an AppRole, JWT or Kubernetes role, so that OpenBao audit entries link each request to one workload. Confirm that audit logging is enabled on every node and that log retention meets your review cycle.

Auth methods docs

Running TOTP keys after go-live

Day-two work for TOTP starts with a key inventory that names an owner for every key. Each TOTP key in OpenBao is tied to a purpose: a shared service account that a team logs into, or an application that validates codes for its own users. Record the key name, the mount path, the owning team, the consuming system, and whether the key generates codes or only validates them. Without this register, nobody can answer the questions that matter during an incident, such as which applications break if a key is deleted or re-issued, or who must confirm a new seed was loaded into an authenticator app. Review the inventory on a fixed schedule and remove keys for retired accounts, because an unused TOTP key is still a second factor that someone can read.

Rotation and re-issuance need their own runbook. Re-issuing a key for a shared account means generating a new seed, distributing it to the people or tools that display codes, and then retiring the old key, so plan the cutover window in advance. For provider mode, confirm with your application team how they handle the period when users hold codes from both the old and new keys. Monitor failed validations through the audit device and your metrics pipeline, and alert on sudden spikes, since they can indicate clock drift, a wrong key, or a credential-guessing attempt. Confirm which validation events and fields your chosen audit device records for the TOTP engine before you rely on them.

Time synchronization affects both sides of every TOTP exchange. Keep OpenBao nodes, generator hosts and client devices on a reliable time source, and check clock offset as part of node health monitoring, because code validation depends on the server and the authenticator agreeing on the current time window. Disaster recovery for keys follows the storage backend, not the engine: the seeds live in the encrypted storage that OpenBao writes, so backups, HA membership and restore tests must cover that data. The OpenBao high availability docs and the storage backend documentation describe the cluster side. Ask your team to confirm, in a restore test, that a restored cluster still validates codes for existing keys.

Limits to confirm in your environment before you build

The TOTP engine's behavior depends on the OpenBao version, the build you install, and how your cluster and applications are arranged. Treat each item below as a question to answer in a test environment, and check the release notes for the exact version you plan to run.

Engine availability in your build

Confirm that the TOTP secrets engine ships in the OpenBao version and build you plan to run, and that it is enabled in your environment rather than provided through a separate plugin. Check the release notes for the version you plan to run, since engine support can change between minor lines. Record the exact version in your build pipeline so the team can reproduce the same behavior later. Ask the vendor or project if the answer is unclear for your package format.

OpenBao releases

Algorithms and digit counts

Verify which HMAC algorithms and code lengths the engine accepts in your version, because the defaults your authenticator apps expect may not match the options the engine offers. Test each combination your users will need, including code length and period, before you create production keys. Write the supported set into your internal standard so that application teams do not assume a value the engine does not accept.

Behavior across HA nodes

Test code generation and validation against an active node and a standby, since requests on a standby are forwarded or redirected according to the HA design. Confirm how the engine handles failover during a time window and whether a code can be validated on more than one node. Document the expected behavior so that load balancer and client retry settings do not produce inconsistent results.

OpenBao HA docs

Namespace and policy isolation

Check how the TOTP engine mounts and scopes keys within namespaces, and confirm that policies restrict generate and validate operations to the intended identities. Verify that a key created for one team cannot be read or used by another team's tokens. Namespace support is documented for multi-tenant isolation, so test the boundary you intend to rely on.

OpenBao namespaces docs

Authenticator app and RFC compatibility

Confirm that codes generated by the engine match what your authenticator apps display for the same secret, digit count, period and algorithm. Compare the output against a reference implementation of the time-based standard and test clock skew on both sides. Plan for users whose apps only support a subset of options, and do not rely on a single app for acceptance testing.

Audit log content limits

Confirm what the audit device records for TOTP generate and validate calls, and whether the generated code or the key material appears in any log line. Check that your audit sink can store the event volume and retain it for the period your controls require. Verify how sensitive fields are hashed or redacted in your version, and test the output before you rely on it as evidence.

Questions buyers ask about OpenBao TOTP work

Does OpenBao TOTP replace our corporate MFA product?

No. An OpenBao TOTP setup generates or validates one-time codes for a defined set of accounts or applications, which is a narrower job than a corporate MFA product. Enterprise MFA usually covers workforce enrollment, device registration, push approval, help desk recovery, conditional access and reporting across many systems. OpenBao also documents login MFA as part of its auth methods, which covers people signing in to OpenBao itself. That is a separate question from using TOTP as a service for your applications. Before you scope the work, decide which accounts the codes protect, who enrolls them, how recovery works and whether your identity provider stays the authority for workforce sign-in. Confirm the TOTP engine behavior and its documented limits for your target version before you commit to a design.

What drives the cost and effort of a TOTP build?

The main drivers are how many keys you manage, how many applications read or validate codes, how much policy design the rules need, and how much testing and audit evidence your owners require. Costs split into one-time and recurring work. One-time work covers design, engine setup, integration with each application, negative testing and documentation of how codes are issued and revoked. Recurring work covers key lifecycle reviews, OpenBao upgrades and retesting after application changes. Each application adds its own effort because its login flow, error handling and fallback paths differ. Ask any provider for a quote that lists the key count, the integration list, the policy rules in scope, the test cases, the evidence package and post-handover support. The quote should also state which items are fixed and which depend on findings. DeployOpen quotes follow from a written scope, not from a price list.

How long does a TOTP pilot take, and what does it depend on?

A pilot's length depends on the number of target applications, the state of your OpenBao cluster, how many identities need codes and how quickly your owners approve the design. A single-application pilot on an existing, well-run OpenBao cluster is shorter than a pilot that also needs cluster hardening, identity mapping and evidence collection. No duration is given here because the written scope decides it. Plan the pilot in phases: confirm the use case and owners, stand up a test engine, validate codes against one application using test accounts, exercise failure paths such as clock drift and retries, then decide on production rollout. Ask for a timeline that names each phase, the client dependencies in each phase and the sign-off points. A pilot that cannot name its dependencies usually runs longer than its quote implies.

What does our team need to provide before the build starts?

Expect to provide four things: identities, clocks, owners and test accounts. Identities means a clear list of the shared service accounts or application users that will receive codes, with their owning teams and the systems they sign into. Clocks means reliable time synchronization on OpenBao nodes and on any application that validates codes, because one-time codes depend on time. Owners means named people who approve the policy, accept the recovery procedure and receive alerts. Test accounts means non-production users and applications where codes can be issued, validated and revoked without touching live access. You also need change management access for each application integration and a place to store audit evidence. Agree these inputs in writing before design starts so that a missing item does not stall the build.

Can our own team build TOTP on OpenBao without a partner?

Often yes, if your team already runs OpenBao and owns the applications involved, but the work is more than configuration. A team that can deploy and operate OpenBao, read its API documentation, write integration code and test negative cases can build a limited setup internally. The risks sit at the edges: deciding which accounts receive codes, delivering seeds safely to enrolling users, recovering access when a device is lost, producing audit trails that assessors accept and running regression tests after upgrades. Assess your team against those tasks, not only against the installation. If a partner is involved, its written scope should state which tasks it owns, which it hands over and what documentation you receive at the end. DeployOpen implements, tests and documents open-source platforms in your infrastructure, so the same scope questions apply to us.

Do generated TOTP codes count as strong MFA under our policy?

It depends on your policy and on how the factor is used, so the answer has to come from your policy owner and, where relevant, your assessor. A time-based code is a possession factor, but its strength depends on how the seed is stored, who can read or copy it, whether a code can be replayed and whether the user behind the code is identifiable. A code generated for a shared service account can support a control for that account, yet it may not satisfy a requirement that each individual authenticate with a factor only they hold. Ask your policy owner which requirement the factor must meet, which identity it binds to and what evidence proves it. DeployOpen prepares systems and evidence for compliance assessments, but independent auditors and certification bodies issue audit reports, attestations and certifications.

What breaks when clocks drift or seeds leak?

Clock drift makes valid codes fail, and a leaked seed lets someone generate valid codes, so both need checks before go-live. Time-based codes are calculated from the current time, so a node or application with a drifted clock may reject good codes or accept codes outside the intended window. Test the skew your validators allow against your synchronization setup, and monitor time sources on every node. Seeds leak through logs, templates, backups, error messages and developer tooling. Keep seeds out of application logs, restrict who can read or export them and confirm that backups and snapshots are protected to the same standard. Also test replay handling, so a code cannot be reused within its window if your design requires single use. Confirm the exact parameters and read-back behavior in the OpenBao documentation for your version, and write these tests into the pilot before rollout.

How DeployOpen scopes and delivers TOTP work on OpenBao

DeployOpen approaches TOTP on OpenBao as a scoped engineering task: first agreeing which accounts or applications generate or validate codes, then building, testing and documenting the setup inside your infrastructure. Engagements are fixed-scope, with the deliverables and timelines agreed in writing before work starts.

How we scope

  • Inventory which shared service accounts or applications need generated codes, and which need OpenBao to act as the TOTP provider.
  • Confirm the OpenBao version and deployment model, and check the TOTP engine's availability and behavior in that release.
  • Agree in writing who owns seed keys, who may read generated codes, and how validation results reach each application.

How we build

  • Configure TOTP key roles with issuer, period, digit and algorithm settings matched to each target system's requirements.
  • Test generation and validation paths against the systems that will consume them, including clock skew and replay handling.
  • Set access policies so that only named identities can create keys, read codes or validate them, and enable audit logging for each path.

How we hand over

  • Deliver the written configuration, policy files, and runbooks for creating, rotating and retiring TOTP keys.
  • Document the verification steps and test evidence so your security and compliance teams can review the setup.
  • Walk your operators through key lifecycle tasks, incident steps for a compromised seed, and where logs are stored.

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers after handover.
  • Re-verify TOTP paths when OpenBao is upgraded, since engine behavior should be checked against each new release.
  • Confirm with your team the support boundaries, response expectations and change process before the retainer begins.

Sources and further reading

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.