OpenBao secrets in GitLab CI/CD with ID tokens and JWT auth

Connect GitLab CI/CD jobs to OpenBao with short-lived JWT-based access, bound claims per project, branch or protected tag, and a clear view of which GitLab tiers support the secrets keyword.

On this page

How OpenBao gives GitLab CI/CD jobs short-lived secrets

GitLab job ID tokens authenticate CI/CD jobs to OpenBao's JWT/OIDC auth method, and roles bound to claims decide which jobs receive which secrets. The pattern replaces long-lived CI/CD variables holding passwords or API keys with credentials a job requests at run time and that expire with the lease. OpenBao checks the token against the GitLab instance's OIDC discovery URL, then matches the claims in the token against the role. A job that does not match a role gets no secret, whichever pipeline it runs in.

The GitLab side is gated by tier. The secrets keyword that pulls Vault-compatible secrets into a job is available on the Premium and Ultimate tiers, and GitLab's Vault secrets documentation describes the JWT auth configuration these jobs depend on. Confirm your tier before designing the pipeline, because a Free instance cannot use the keyword at all. Scripts on other tiers can still reach OpenBao directly, but they must request a job token and call the JWT login themselves, which moves the token handling and error paths into your own code and your own review process.

The decision that matters most is how tightly each role is bound. OpenBao's bound_claims map requires every listed claim to be present with a matching value, so a role bound only to the project path is broader than one also bound to the branch or a protected tag matching your release pattern. Decide which secrets belong to which environments before writing roles, then test each role with a job from an unapproved branch to confirm it is refused. Record the claim values, the role names and the mount path used, since the GitLab examples default the JWT mount to jwt, and check that your deployment matches.

What you need before configuring the GitLab and OpenBao link

The GitLab and OpenBao link depends on four things being true before any JWT role is written: a supported OpenBao cluster, a GitLab instance that OpenBao can reach, a GitLab tier that includes the secrets keyword, and a network path from the runners that execute jobs. Confirm each one in your own environment, because a gap in any of them shows up later as a failed login or a job that never receives its secrets.

OpenBao cluster and version

Identify the OpenBao minor version your cluster runs and compare it with the releases page before you rely on any JWT behavior. The JWT auth method, the bound_claims map and the login path are the parts this page depends on, so confirm they behave the same way on your version. If you are migrating from Vault, confirm the migration steps have been completed on every node, since a partially upgraded cluster can behave differently across nodes. Record the version so later upgrades can be checked against the same behavior.

OpenBao releases

GitLab OIDC discovery reachability

OpenBao must fetch the GitLab instance's OIDC discovery document to verify job tokens, so the GitLab URL has to resolve and respond from the OpenBao side. Check this from the OpenBao server itself, not from your workstation, because internal DNS, proxies and private certificate authorities often differ between the two. If GitLab uses a private certificate authority, confirm that OpenBao trusts that chain. Note the exact instance URL, since the issuer value in the JWT auth configuration must match it.

GitLab Vault secrets docs

GitLab tier for the secrets keyword

The secrets keyword for pulling Vault secrets into CI/CD jobs is documented on the Premium and Ultimate tiers, so a Free instance cannot use this pattern as documented. Confirm the tier of your self-managed instance or your GitLab.com group before designing the pipeline. Scripts can still read from OpenBao on other tiers, but that path uses direct API calls and needs its own design. Ask your GitLab account team or administrator to confirm the tier in writing.

GitLab pricing

Network path from runners to OpenBao

Runners must reach the OpenBao API endpoint over the network, and the job must present a token that OpenBao can validate. Map which runners execute the jobs (shared, group or project runners, including any self-managed runners in your own network) and confirm each one can open a connection to the OpenBao listener on the required port. Check egress rules, proxies and firewall policies for runners in separate network zones. Confirm that TLS certificates presented by OpenBao are trusted by every runner image, not only the host.

GitLab Runner docs

Identity and ownership of the link

Decide who owns the OpenBao JWT configuration, the bound claims and the roles, and who can change them. The bound claims for project path, branch and protected tag decide which jobs can read which secrets, so changes to them are changes to access control. Name a platform owner on the OpenBao side and a maintainer on the GitLab side, and agree how role changes are reviewed and logged. Without this, roles tend to be widened to fix a failing pipeline.

OpenBao JWT/OIDC docs

Configuring JWT auth, roles and the CI job

This sequence connects GitLab to OpenBao so that a job can present its own short-lived token, receive a scoped OpenBao token and read only the secrets its project, branch or protected tag is allowed to use. Each step ends with a check you can run before any production secret is involved.

  1. Enable the JWT auth method

    A platform engineer with administrative rights in OpenBao enables the JWT auth method at its default mount path, jwt, unless the organization needs a different path. Keep the mount name in mind, because the CI job must reference the same path through its JWT auth mount setting. Confirm the method appears in the list of enabled auth methods and that the mount is reachable from the network segment where your GitLab Runners run. The step is complete when the auth method is listed and a status check from a runner host returns a response.

  2. Point OpenBao at the GitLab OIDC discovery URL

    Configure the JWT auth mount with the OIDC discovery URL of your GitLab instance, so OpenBao can fetch the signing keys it needs to verify job tokens. For a self-managed instance, this URL is based on your instance's external address, so use the exact hostname that GitLab issues tokens under. Confirm that OpenBao can reach that address over TLS, and that the certificate chain is trusted by OpenBao if your GitLab uses an internal certificate authority. The step is complete when the config read returns the discovery URL you set and a test token issued by GitLab can be validated.

  3. Create least-privilege policies for each secret group

    Write one policy per group of secrets that a set of jobs needs, granting read on specific KV paths and nothing broader. Keep production and non-production secrets under separate paths so that a policy for a test pipeline cannot reach release credentials. Store the policy files in version control and apply them through your normal change process. The step is complete when a policy read shows the expected paths, and a token created with that policy is denied on a path outside its scope.

  4. Create JWT roles bound to project, ref and tag claims

    Create a role for each trust boundary using bound_claims to limit which jobs can log in. Bind the project_path claim to the exact GitLab project, and bind ref or ref_type for branches, or the protected tag pattern for releases. OpenBao authorizes a token only when every listed claim matches, so add the claims you need together rather than relying on one. Attach the matching policy and set a short token lifetime. The step is complete when a role read shows every bound claim and the attached policy, and you have written down which projects can use each role.

  5. Add the secrets keyword and VAULT_SERVER_URL to the job

    In the .gitlab-ci.yml file of the project, add the secrets keyword to the job that needs credentials. Set VAULT_SERVER_URL to the address of your OpenBao cluster, and set the JWT auth mount path if it differs from the default. Map each secret to a variable name and the KV path and field it reads. Keep the job's other variables unchanged so that a failure is easy to trace. The step is complete when the pipeline configuration validates without errors in the CI lint view. Confirm with your GitLab administrator that your tier supports the secrets keyword, because GitLab documents it on the Premium and Ultimate tiers.

  6. Verify with a test job on a non-production secret

    Before any production secret is mapped, run a job on a protected branch that reads a non-production test secret through the new role. Print only the length or a masked value, never the secret itself, and check that the job log shows a successful login. Then run the same job from an unprotected branch and from a project not listed in the role, and confirm that both fail to authenticate. The step is complete when the allowed job reads the test value and both denied attempts are rejected, with the rejection visible in OpenBao's audit log.

  7. Confirm audit entries and document the trust boundary

    Check that OpenBao's audit log records the JWT login, the role used and the secret reads, and that the log is shipped to the store your security team reviews. Record which GitLab projects, branches and protected tags map to each role, along with the policy and token lifetime. Share this record with the team that owns the GitLab instance so that role changes are reviewed alongside project settings. The step is complete when a sample log entry for the test job is available to the reviewer and the trust boundary document is approved.

Mapping GitLab job claims to OpenBao roles and policies

This table compares the GitLab job claims you can bind in an OpenBao JWT role, what each one proves, and how broad each match becomes. Read it to choose which claims to require together, and remember that every listed claim must match before OpenBao issues a token.

Claim or settingWhat it identifiesTypical bindingRisk if left broad
project_pathThe GitLab project that issued the job tokenExact project path, such as group/projectAny project in the group can reach the role if the value is a prefix or wildcard
refThe branch or tag name the pipeline ran againstExact branch name, such as mainA feature branch with the same name pattern can request secrets if ref_type is not also bound
ref_typeWhether the ref is a branch or a tagbranch or tag, paired with refOmitting it lets a branch named like a release tag match a tag-based rule
ref_protectedWhether the branch or tag is protected in GitLabtrue for production rolesUnprotected refs can run jobs that read production secrets
Protected tag patternRelease tags that match a naming ruleExact tag or a narrow pattern tied to your release processA loose pattern can match tags that anyone with push rights can create
user_login or pipeline_sourceWho or what started the pipelineAdd only if your workflow needs it, and confirm the claim name in your GitLab versionScheduled or web-triggered pipelines may run with different trust than merge request pipelines
Role token policyThe OpenBao policy the issued token receivesOne policy per role, read-only paths for each job groupA shared wildcard policy lets any matching job read unrelated secrets
JWT mount pathThe auth mount that verifies GitLab tokensDefault jwt unless you mounted it elsewhere, matched to the CI variableA mismatch causes login failures, and a reused mount can serve roles you did not intend

Reading secrets on the Premium, Ultimate and other tiers

On the Premium and Ultimate tiers, GitLab documents a secrets keyword in the job definition that fetches values from Vault-compatible servers during the job. You define the server URL and the JWT auth mount path as CI/CD variables, such as VAULT_SERVER_URL and the default jwt mount, and GitLab exchanges the job's ID token for an OpenBao token before the script runs. Because the platform handles the exchange, the pipeline stays short and the role binding does most of the access control work.

  • Keyword configuration: Map each secret path and field to a CI/CD variable in the secrets block so job scripts read ordinary environment variables.
  • Role binding: Scope the OpenBao role with bound claims for project, branch or protected tag so only matching jobs receive a token.
  • Masking behavior: Confirm how GitLab masks fetched values in job logs, and test with a deliberate echo in a non-production project.
  • Lower scripting load: Teams avoid writing HTTP calls and token handling in every pipeline, which reduces copy-paste errors across projects.
  • Shared responsibility: The tier does not change the OpenBao policy work, so the role and policy reviews still apply.

Before you rely on this path, confirm on the GitLab pricing page that your installation's tier includes the secrets keyword, since availability is tied to the tier you license.

Hardening the trust boundary between GitLab and OpenBao

Once a GitLab job can authenticate to OpenBao, the security of production secrets depends on which jobs are trusted to ask. The cards below cover the controls that narrow that trust: the claims a role accepts, the lifetime of the token it issues, the policy it grants, and the logs and runners around each job. Confirm each setting against the current OpenBao and GitLab documentation before you rely on it.

Gate production secrets on protected refs

Bind production roles to claims that only protected branches and protected tags can produce, so a feature branch pushed by a developer cannot receive production credentials. Check the ref_protected and ref_type values that GitLab places in the job token, and test with an unprotected branch that the login is refused. Protection rules are set in GitLab, so anyone who can change them effectively changes who can read these secrets. Review that permission list as part of this control.

GitLab Vault secrets docs

Narrow bound claims per role

OpenBao only authorizes a JWT when every listed bound_claims entry matches, so each role should list the project path, the ref and the ref type at minimum. Avoid wildcard or broad patterns on the project claim, because a pattern that matches a sibling project grants it the same access. Add separate roles for each environment rather than reusing one role across staging and production. Verify the claim names against the token your instance issues before you deploy the role.

OpenBao JWT/OIDC docs

Keep token lifetimes short

Set the token TTL and maximum TTL on each JWT role to the length a job needs, so a token captured from one job cannot be reused long after that job ends. Use the OpenBao lease and token settings to confirm that a token expires at the configured time. Long-lived or renewable tokens defeat the purpose of job-scoped access. Ask your team to document the TTL chosen for each role and the reason for it.

Grant least-privilege policies per role

Write one policy for each role that allows reads only on the exact secret paths that job needs, with no list or wildcard access to the wider mount. Make sure a role for a deployment job cannot read the paths used by test or build jobs. Review policy files in version control with the same rigor as application code. Confirm the behavior with a test login that attempts to read a path outside the policy and is denied.

OpenBao auth methods

Mask secret values in job logs

Secrets fetched through the secrets keyword become CI/CD variables, but a script that echoes or prints them can still expose the values in the job log. Enable masking for each variable where your GitLab tier supports it, and avoid printing secrets in debug output or set -x traces. Review job logs after a test run to confirm no values appear. Masking is a safety net, not a replacement for keeping secrets out of commands and files that persist.

Isolate runners for sensitive jobs

Run jobs that read production secrets on dedicated runners that are restricted to protected branches and tags, so shared or untrusted runners never hold those values. Decide whether runners are ephemeral and whether each job gets a clean environment. Confirm the runner configuration and executor type in the GitLab Runner documentation before you assign them to production projects. Record which runners are approved for secret access.

GitLab Runner docs

Audit logins and secret reads

Enable and review OpenBao audit devices so each JWT login and each secret read is recorded with the role and the requesting identity. Send audit logs to a store that engineers cannot silently edit, and alert on logins from unexpected roles or refs. Confirm your audit device type and retention in the OpenBao docs. Test the pipeline by running a job and finding its login event in the audit trail.

OpenBao namespaces docs

How a GitLab job obtains an OpenBao secret

The flow starts when a CI/CD job asks GitLab for an ID token and hands it to the job's runner. The runner sends that token to OpenBao's JWT login endpoint. OpenBao checks the token signature against the GitLab OIDC discovery URL, then tests the role's bound claims (project, branch or protected tag). Only if every claim matches does OpenBao return a short-lived token that can read the secret. The trust boundary sits between GitLab and the OpenBao cluster, so the bound claims are the control you set.

Trust flow from a GitLab job token to a short-lived OpenBao read.

Why GitLab jobs fail to authenticate to OpenBao

This table lists the failures teams hit most often when a GitLab CI/CD job tries to log in to OpenBao with its ID token. Each row gives the likely cause and the first check to make, so you can work through the symptoms in order. Most failures come down to a URL, a claim value or a tier setting that does not match what the job actually presents.

FailureLikely causeFix
Login fails with a discovery or key fetch errorOpenBao cannot reach the GitLab OIDC discovery URL, often because of network egress, a private CA or a DNS name that resolves differently inside the clusterConfirm OpenBao can fetch the discovery document from its own host, add the internal CA to OpenBao's trust store, and check the configured issuer matches the GitLab instance URL exactly
Login rejected with a claim mismatchA bound_claims entry, such as a protected ref or ref_type, does not match the value in the job token, for example a branch job presenting a tag claimDecode a job token from a test pipeline, compare each claim with the role, and adjust the bound claim or the role used by that job
Protected tag jobs are deniedThe role binds a release pattern but the tag is not protected in GitLab, or the pattern does not match the tag nameProtect the tag pattern in GitLab project settings, then test the pattern against the exact tag name the pipeline runs on
Login call reaches the wrong endpointThe job sets the JWT auth mount path incorrectly, or the auth method was enabled at a different path than the default jwtCheck the mount path in OpenBao, set the matching path in the CI/CD variables, and keep the path consistent across environments
Secrets keyword is ignored or rejectedThe project runs on a GitLab tier without the secrets keyword, which GitLab documents for Premium and UltimateConfirm the tier of the instance or group, move the job to a supported tier, or read secrets from the script on other tiers as described in the next section
Login succeeds but secret read is deniedThe role's token policy does not grant read on the secret path, or the path in the job does not match the path in the policyCompare the secret path in the job with the policy attached to the role, then grant read on that exact path and test again
Token expires mid-jobThe job runs longer than the token TTL set on the roleReview the role's token TTL against typical job duration and keep the TTL short but long enough to cover the job

Questions teams ask before connecting GitLab CI/CD to OpenBao

What drives the cost of connecting GitLab CI/CD to OpenBao?

The cost comes from the hours needed to design roles, configure JWT auth and test pipelines, and it depends on how many projects, branches and environments need access. Your own staff are paid for their time, and a partner is paid under a written, fixed scope. Costs rise with the number of distinct trust boundaries (projects, protected tags, production versus non-production jobs), with the number of secrets engines involved, and with any work needed to bring an existing OpenBao or GitLab instance up to standard. Ask any quote to itemize discovery, JWT auth and role design, pipeline changes, testing, documentation and handover, and to state which items are one-time and which recur, such as role reviews after new projects are added.

Can our team set up GitLab CI/CD with OpenBao on its own?

Yes, if you have people who understand both platforms. The core steps are configuring a JWT auth method in OpenBao using your GitLab instance's OIDC discovery URL, creating roles bound to project, branch or protected-tag claims, and changing pipelines to use the secrets keyword. The GitLab documentation covers the pipeline side, and the OpenBao JWT/OIDC documentation covers role configuration. Teams without prior experience tend to underestimate the testing needed to confirm that a role accepts only the jobs it should, so plan for a review of bound claims before production use.

What do GitLab administrators and OpenBao operators each need to provide?

Both sides need to agree on the work before configuration starts. GitLab administrators need to confirm the instance's external URL and the OIDC discovery endpoint the OpenBao server can reach, confirm the tier that provides the secrets keyword, and decide which groups and projects may request secrets. OpenBao operators need to enable a JWT auth mount (the GitLab documentation uses the default path jwt), define policies for the secrets each role may read, and control who can change roles. Network reachability between the OpenBao cluster and GitLab, and an agreed change process for roles, are usually the points that delay setup.

How long does setup take, and what changes it?

No duration is fixed in this page. The timeline depends on the number of projects and environments, whether OpenBao is already running in a production-grade configuration, how GitLab is deployed and reached over the network, and how many approval steps your change process requires. A single project with one non-production secret can be validated quickly, while an organization-wide model with protected-tag release roles, separate production paths and audit review takes longer. Ask for a timeline that lists the milestones and the decisions your team must make before each one.

What changes when moving from GitLab Free to Premium for this?

According to the GitLab pricing page, GitLab Free costs 0 dollars, Premium costs 29 US dollars per user per month billed annually, and Ultimate is custom priced. The secrets keyword for Vault secrets is documented for the Premium and Ultimate tiers, so a Free instance cannot use this pattern as described in the GitLab documentation. Premium also lists advanced CI/CD and priority support. The license cost recurs per user, so count the users who will run or maintain pipelines, and confirm the tier with GitLab before budgeting, since list prices can differ from negotiated terms.

Which GitLab job tokens and claims should roles check?

Roles should bind to claims that identify the source of the job, such as the project path, the branch name for branch pipelines, or the protected tag for release jobs. OpenBao JWT roles accept a bound_claims map, and a token is authorized only if every listed claim is present and matches. Restrict releases to protected tags matching a defined pattern, and avoid broad patterns that allow any branch to read production secrets. Test each role with a job from an unauthorized branch and confirm it is refused, because a role that looks correct in configuration can still match more jobs than intended.

Does DeployOpen handle this work, and what does it cover?

DeployOpen implements open-source platforms inside your own infrastructure under a written, fixed scope, and this topic is one area that can be scoped that way. A typical written scope would list the GitLab and OpenBao versions in use, the projects and environments in scope, the roles and policies to create, the pipeline changes, test evidence and handover documentation. Ask for the scope, deliverables and timeline in writing before work starts, and confirm which parts your staff will own afterward. Ongoing support and upgrades are available as retainers.

How DeployOpen works on this

DeployOpen plans, implements, hardens, documents and supports self-hosted open-source platforms inside the client's own infrastructure. For OpenBao secrets in GitLab CI/CD, that means agreeing the GitLab and OpenBao trust boundaries in writing first, then building and testing the JWT roles, then handing over a system your own teams can run.

How we scope

  • Inventory which GitLab projects, groups and protected tags need OpenBao secrets, and which jobs run on which tier.
  • Agree in writing which GitLab instance, OpenBao cluster and JWT auth mount are in scope, and who owns each.
  • Confirm with your team whether the GitLab edition and tier needed for the secrets keyword are already licensed.

How we build

  • Configure the JWT auth method against your GitLab instance's OIDC discovery URL and verify the server can validate job tokens.
  • Write roles bound to project, branch or protected-tag claims, with least-privilege policies per pipeline and environment.
  • Test that a job on an unauthorized branch or unprotected tag is refused, and that secrets are short-lived and not written to job logs.

How we hand over

  • Deliver a written record of auth mounts, roles, bound claims, policies and the CI/CD variables each project uses.
  • Walk your platform and security teams through the pipeline pattern for reading secrets from scripts on tiers without the secrets keyword.
  • Provide runbooks for adding a project, rotating the JWT configuration and revoking access during an incident.

How we support

  • Review role changes and new projects against the bound-claim rules before they reach production pipelines.
  • Plan OpenBao and GitLab upgrades with the version and upgrade-stop checks each product requires, tested before rollout.
  • Offer ongoing support, upgrades and continuous testing as a retainer, separate from the fixed-scope build.

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.