Docs · Deliver
CI
One read-only identity per pipeline, scoped to its folder, with its IDs in the CI's own secret settings.
GitHub Actions
# .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"Any CI, one value
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)Fail on a leak
# 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/nullMore in Secrets in CI and Leak checks.