From 896e332a088b2a55cc65f72f7b4cf0f44a5b34b6 Mon Sep 17 00:00:00 2001 From: unkin-agent Date: Sun, 25 Oct 2026 22:57:21 +1100 Subject: [PATCH] ci: authenticate artifactapi provider upload with a vault token (#5) artifactapi is about to enforce auth on file uploads (`ARTIFACTAPI_AUTH_UPLOADS`), and the release upload currently PUTs the provider zip to terraform-unkin anonymously. - mint an `artifactapi-writer` OIDC token via Vault k8s auth (role `woodpecker_artifactapi_writer`) using the step SA token - fail the step if minting fails (`set -o pipefail`) - send the token as `Authorization: Bearer` via a header file, never in argv or logs Reviewed-on: https://git.unkin.net/unkin/terraform-provider-vault-secrets-arrstack/pulls/5 Co-authored-by: unkin-agent Co-committed-by: unkin-agent --- .woodpecker/release.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.woodpecker/release.yml b/.woodpecker/release.yml index 68d71a4..11077cd 100644 --- a/.woodpecker/release.yml +++ b/.woodpecker/release.yml @@ -35,9 +35,16 @@ steps: - | VERSION=$$(echo ${CI_COMMIT_TAG} | sed 's/^v//') FILE="terraform-provider-vault-secrets-arrstack_$${VERSION}_linux_amd64.zip" + set -o pipefail + VAULT="https://vault.service.consul:8200" + AUTH=$$(mktemp) + VT=$$(jq -n --rawfile jwt /var/run/secrets/kubernetes.io/serviceaccount/token '{role:"woodpecker_artifactapi_writer",jwt:$$jwt}' \ + | curl -sf -d @- "$$VAULT/v1/auth/k8s/au/syd1/login" | jq -er .auth.client_token) || exit 1 + printf 'X-Vault-Token: %s\n' "$$VT" | curl -sf -H @- "$$VAULT/v1/identity/oidc/token/artifactapi-writer" \ + | jq -er '"Authorization: Bearer " + .data.token' > "$$AUTH" || exit 1 curl -f -X PUT \ "https://artifactapi.k8s.syd1.au.unkin.net/api/v2/remotes/terraform-unkin/files/terraform-unkin/vault-secrets-arrstack/$${FILE}" \ - -H "Content-Type: application/zip" \ + -H "Content-Type: application/zip" -H @"$$AUTH" \ --data-binary @"$${FILE}" depends_on: [package] backend_options: