Skip to content

CICD-366 · HashiCorp Vault authentication ​

Encyclopedia · Advanced security and compliance · All snippets

Previous · CICD-365 · Next · CICD-367

1. Where it fits ​

  • Placement CI run step or authorized lab terminal.
  • Prerequisites reviewed policies, a short-lived CI identity, and synthetic or approved test inputs.
  • Platforms local-linux, github-actions, gitea-actions.
  • Parameters CI_OIDC_JWT.

2. Copy the snippet ​

bash
export VAULT_TOKEN="$(vault write -field=token auth/jwt/login role=ci jwt="${CI_OIDC_JWT:?}")"
vault token lookup -format=json | jq -e '.data.ttl > 0' >/dev/null

3. How it works ​

Vault evaluates the configured role, policy and lease. Limit what is printed and keep credentials scoped to the trusted step. The expression filters or transforms the input JSON. Where jq -e is used, a false or empty result can fail the gate.

4. Verify the result ​

Supply the CI OIDC assertion securely and bind the Vault JWT role to the repository claims. Disable shell tracing and keep tokens only in this process.

Watch for. Use the intended trusted execution context. Keep secret values out of traces, artifacts and debug output.

Validation syntax-validated (Bash parse). Status definitions.