Skip to content

Commit

Permalink
Don't leak (revoked) VAULT_TOKEN environment variable
Browse files Browse the repository at this point in the history
Made possible by [hashicorp/vault-action][1] now making its token
available as an _output_.

[1]: https://github.com/hashicorp/vault-action
  • Loading branch information
andreaso committed Jun 21, 2023
1 parent e76d708 commit a736b6a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Generate SSH client certificate
if: github.ref == 'refs/heads/main'
id: ssh_cert
uses: andreaso/vault-oidc-ssh-cert-action@v0.6
uses: andreaso/vault-oidc-ssh-cert-action@v0.7
with:
vault_server: https://vault.example.com:8200
oidc_backend: github-oidc
Expand Down
7 changes: 4 additions & 3 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ runs:
shell: python

- name: Authenticate towards Vault
id: vault_auth
uses: hashicorp/vault-action@v2.7.0
with:
method: jwt
Expand All @@ -58,20 +59,20 @@ runs:
url: ${{ inputs.vault_server }}
path: ${{ inputs.oidc_backend }}
role: ${{ inputs.oidc_role }}
exportToken: true
outputToken: true

- name: Generate and sign SSH client certificate
id: generator
shell: bash
run: ${{ github.action_path }}/generate-and-sign
env:
VAULT_SERVER: ${{ inputs.vault_server }}
VAULT_TOKEN: ${{ steps.vault_auth.outputs.vault_token }}
SSH_BACKEND: ${{ inputs.ssh_backend }}
SSH_ROLE: ${{ inputs.ssh_role }}
RUNNER_TEMP: ${{ runner.temp }}

- name: Revoke Vault token
shell: bash
run: |
curl --fail --silent --show-error --header "X-Vault-Token: $VAULT_TOKEN" --data "" "${{ inputs.vault_server }}/v1/auth/token/revoke-self"
echo "VAULT_TOKEN=revoked" >> "$GITHUB_ENV"
curl --fail --silent --show-error --header "X-Vault-Token: ${{ steps.vault_auth.outputs.vault_token }}" --data "" "${{ inputs.vault_server }}/v1/auth/token/revoke-self"

0 comments on commit a736b6a

Please sign in to comment.