{Core} Proof-of-Concept: Support OIDC token refreshing on GitHub Actions#28778
Draft
{Core} Proof-of-Concept: Support OIDC token refreshing on GitHub Actions#28778
Conversation
️✔️AzureCLI-FullTest
|
|
Hi @jiasli, |
|
| rule | cmd_name | rule_message | suggest_message |
|---|---|---|---|
| login | cmd login added parameter federated_identity |
Collaborator
|
Support OIDC token refreshing on GitHub Actions |
jiasli
commented
Apr 22, 2024
Comment on lines
+147
to
+148
| token = os.environ['ACTIONS_ID_TOKEN_REQUEST_TOKEN'] | ||
| url = os.environ['ACTIONS_ID_TOKEN_REQUEST_URL'] |
Member
Author
There was a problem hiding this comment.
Use this workflow file to collect environment variables:
on: [push, workflow_dispatch]
name: AzureCLISample
permissions:
id-token: write
contents: read
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Azure CLI script
uses: azure/CLI@v1
with:
azcliversion: latest
inlineScript: |
set -ex
env | base64|
@jiasli any chance this could get some more love? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #28708
Related command
az loginDescription
MSAL reserved an undocumented interface which allows using a callback function to get
client_assertion, instead of supplying a raw OIDC token.https://github.com/AzureAD/microsoft-authentication-library-for-python/blob/a8476fbe665356aae60e65296337d9eff86d0d66/msal/oauth2cli/oauth2.py#L198-L201
As a Proof-of-Concept, this PR uses this interface to achieve OIDC token refreshing.
Some interesting finds:
When a task is run on 2024-04-18 10:35:31, the
ACTIONS_ID_TOKEN_REQUEST_TOKENhas below claims:This means the token starts 10min before the task and expires after 6h10min. After the token expires, no ID token can be retrieved. Therefore, even if we can refresh ID token, the maximum execution time of a task is around 6h.
References:
ACTIONS_ID_TOKEN_REQUEST_TOKENandACTIONS_RUNTIME_TOKENgithub/docs#32573Testing Guide
[Only for development and debugging]
env | base64to bypass GitHub Actions' credential redaction. Then decode it with VS Code.sleep 1800to keep the task alive, otherwise, the OIDC token request will be rejected after the task finishes.