Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

actions/deploy: authentication token may expire before wait timeout #229

Open
tronghn opened this issue Sep 27, 2024 · 1 comment
Open
Labels
bug Something isn't working

Comments

@tronghn
Copy link
Contributor

tronghn commented Sep 27, 2024

actions/deploy@v2 added support for using GitHub OIDC tokens to authenticate GitHub workflows for deployment:

# if no apikey is set, use use the id-token to get a jwt token for the deploy CLI
if [ -z "$APIKEY" ]; then
if [ -z "$ACTIONS_ID_TOKEN_REQUEST_TOKEN" ] || [ -z "$ACTIONS_ID_TOKEN_REQUEST_URL" ]; then
echo "Missing id-token permissions. This must be set either globally in the workflow, or for the specific job performing the deploy."
echo "For more info see https://doc.nais.io/build/how-to/build-and-deploy and/or https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs"
exit 1
fi
payload=$(curl -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=hookd")
jwt=$(echo "$payload" | jq -r '.value')
export GITHUB_TOKEN="$jwt"
fi

These JWTs acquired from GitHub have an expiry of 10 minutes. The expiry cannot be configured, as far as I can tell.

The token expiry takes precedence over the deployclient wait timeout which also defaults to 10 minutes, resulting in confusing error messages for end-users.

Ideally, we should continue fetching new OIDC tokens for as long as the configured deployment timeout is still valid:
https://docs.github.com/en/actions/security-for-github-actions/security-hardening-your-deployments/about-security-hardening-with-openid-connect#updating-your-actions-for-oidc
This assumes that ACTIONS_ID_TOKEN_REQUEST_TOKEN is valid for the entirety of the duration of the action or workflow.

@kimtore kimtore added the bug Something isn't working label Oct 8, 2024
@kimtore
Copy link
Contributor

kimtore commented Nov 5, 2024

This functionality could be added to the deploy client, so that it always pulls a new token before opening connections to hookd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants