Use case
Secrets in CI
CI systems collect long-lived keys. Give each pipeline a Lockwell identity instead: it reads one folder, for an hour, and every read is in the audit log under its name.
GitHub Actions
Make a read-only identity for ci/ in the console. Put its role_id and secret_id in the repository's secrets as LOCKWELL_ROLE_ID and LOCKWELL_SECRET_ID. Then:
# .github/workflows/deploy.yml: LOCKWELL_ROLE_ID and LOCKWELL_SECRET_ID in the repository's secrets
- name: Secrets from Lockwell
env:
VAULT_ADDR: https://vault.lunaor.com
ROLE_ID: ${{ secrets.LOCKWELL_ROLE_ID }}
SECRET_ID: ${{ secrets.LOCKWELL_SECRET_ID }}
run: |
TOKEN=$(curl -sf "$VAULT_ADDR/v1/auth/approle/login" \
-d "{\"role_id\":\"$ROLE_ID\",\"secret_id\":\"$SECRET_ID\"}" | jq -r .auth.client_token)
J=$(curl -sf -H "X-Vault-Token: $TOKEN" "$VAULT_ADDR/v1/lw-<team>/resolved/ci/?values=true&resolve=true")
# mask every value in the job's log, then hand each secret to the later steps
echo "$J" | jq -r '.data.secrets[].data // {} | .[] | tostring | "::add-mask::" + .'
echo "$J" | jq -r '.data.secrets[] | .name as $n | (.data // {}) | to_entries[]
| "\(if .key == "value" then $n else "\($n)_\(.key)" end | ascii_upcase | gsub("[^A-Z0-9_]"; "_"))=\(.value | tostring)"' >> "$GITHUB_ENV"GitLab CI and the rest
The same shape in any shell step. Keep the IDs in protected, masked CI variables:
# .gitlab-ci.yml
deploy:
image: alpine:3.20
script:
- apk add --no-cache curl jq
- export VAULT_ADDR=https://vault.lunaor.com
- export VAULT_TOKEN=$(curl -sf "$VAULT_ADDR/v1/auth/approle/login" -d "{\"role_id\":\"$LOCKWELL_ROLE_ID\",\"secret_id\":\"$LOCKWELL_SECRET_ID\"}" | jq -r .auth.client_token)
- export DEPLOY_KEY=$(curl -sf -H "X-Vault-Token: $VAULT_TOKEN" "$VAULT_ADDR/v1/lw-<team>/data/ci/DEPLOY_KEY" | jq -r .data.data.value)
- ./deploy.shFail the build on a leak
After the build, ask Vault whether its log, or the pull request's diff, holds any secret the job can read. The answer names which, never the value:
# fail the job if its log holds any secret this identity can read, naming which to rotate
jq -Rs --arg p lw-<team>/ci/ '{text: ., prefix: $p}' build.log > payload.json
curl -sf -H "X-Vault-Token: $VAULT_TOKEN" --data @payload.json "$VAULT_ADDR/v1/scan" > scan.json
jq -r '.data.leaks[] | "leaked: \(.path) \(.field) (version \(.version))"' scan.json
jq -e '.data.leaks == []' scan.json > /dev/nullFor a pull request, use git diff origin/main...HEAD in place of build.log. Texts are checked up to 1 MiB.
Good habits
- One identity per pipeline, read-only, for its folder. A deploy job that writes back gets its own write identity.
- The token lasts an hour, so a leaked job token stops working soon after.
- If a secret ID leaks, delete the identity in the console and make a new one. The old one's logins stop at once.
More use cases
Get secrets out of .env files
Move an app's .env into Lockwell and start it with its secrets as environment variables, with nothing on disk.
Hand a secret to someone once
A contractor or a vendor needs one API key. Send a link that opens once, not a message that stays forever.
Undo a bad change
A script overwrote production's secrets. See what changed and put the folder back as it was at 09:00.
Move your first app's secrets in an afternoon.
Free for up to 100 secrets and 2 machine identities. Every teammate is free on every plan.