Skip to content

Feature/OIDC token refresh - #1

Open
MaddyMicrosoft wants to merge 103 commits into
devfrom
feature/oidc-token-refresh
Open

Feature/OIDC token refresh#1
MaddyMicrosoft wants to merge 103 commits into
devfrom
feature/oidc-token-refresh

Conversation

@MaddyMicrosoft

Copy link
Copy Markdown
Owner

Related command

Description

Testing Guide

History Notes

[Component Name 1] BREAKING CHANGE: az command a: Make some customer-facing breaking change
[Component Name 2] az command b: Add some customer-facing feature


This checklist is used to make sure that common guidelines for a pull request are followed.

saanikaguptamicrosoft and others added 30 commits July 24, 2026 15:42
…lti-label sovereign suffixes (Azure#33754)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6daaab37-9f50-49e2-bbba-9dd6ff4b3727
…Fabric Mirroring (Azure#33774)

Co-authored-by: Laveena Fulwani <lfulwani@microsoft.com>
…date (Azure#33768)

Co-authored-by: Copilot <copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: f9c96871-4d63-4a60-9622-70bfffb3cc7a
Co-authored-by: Zubair <zubairabid1999+github@gmail.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
… NVA to ILB architecture (Azure#33766)

Co-authored-by: Jordan Graves <jordangraves@microsoft.com>
Co-authored-by: Ethan Yang <necusjz@gmail.com>
…o` to enable writable behavior for cache repositories within a registry (Azure#33772)
Co-authored-by: Yabo Hu <yabhu@microsoft.com>
Co-authored-by: Yu Chen <16348853+jsntcy@users.noreply.github.com>
)

Co-authored-by: Mansoor Sarfraz <msarfraz+microsoft@microsoft.com>
…zure#33831)

Co-authored-by: Mansoor Sarfraz <msarfraz+microsoft@microsoft.com>
…le-cluster-autoscaler`: Add CAS support for VMS agent pools (Azure#33801)

Co-authored-by: reneeli <reneeli@microsoft.com>
Copilot AI and others added 30 commits August 21, 2026 15:49
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: a0x1ab <59631311+a0x1ab@users.noreply.github.com>
…torage redundancy on target (Azure#33814)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Rambabu Yalla <ramyal@microsoft.com>
Co-authored-by: Mansoor Sarfraz <msarfraz+microsoft@microsoft.com>
…o avoid content-encoding decode failures (Azure#33730)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: a0x1ab <59631311+a0x1ab@users.noreply.github.com>
Co-authored-by: azure-client-tools-agent[bot] <299377795+azure-client-tools-agent[bot]@users.noreply.github.com>
… for all regions (Azure#33747)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: azure-client-tools-agent[bot] <299377795+azure-client-tools-agent[bot]@users.noreply.github.com>
Co-authored-by: a0x1ab <59631311+a0x1ab@users.noreply.github.com>
…les to include `--is-linux false` (Azure#33828)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
…#33958)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ently ignores camelCase properties like `webJobsEnabled` (Azure#33826)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: a0x1ab <59631311+a0x1ab@users.noreply.github.com>
Co-authored-by: azure-client-tools-agent[bot] <299377795+azure-client-tools-agent[bot]@users.noreply.github.com>
Co-authored-by: Ethan Yang <ethanyang@microsoft.com>
…u (SCM) container in addition to the main application container (Azure#33954)
Co-authored-by: Cooper Cox <coopercox@microsoft.com>
Co-authored-by: mansoor sarfraz <msarfraz@microsoft.com>
… federated tokens

Static `--federated-token` values expire in ~10 minutes and cannot be refreshed,
so long-running CI/CD tasks fail with `AADSTS700024: Client assertion is not
within its valid time range`.

This registers a callable client_assertion with MSAL (the documented, recommended
interface) so an expired OIDC ID token is transparently re-fetched on every token
acquisition, including in later `az` processes. Wiring:

- New `FEDERATED_IDENTITY` sentinel persisted as the SP entry's client_assertion.
- `ServicePrincipalAuth.get_msal_client_credential()` resolves that sentinel to a
  provider dispatcher, `get_federated_id_token()`, instead of a static string.
- Dispatcher implements GitHub Actions; other environments raise a clear error
  pointing at `--federated-token`. Azure DevOps is a planned follow-up (Azure#28708).
- New `az login --federated-identity` flag, mutually exclusive with
  `--federated-token` and only valid with `--service-principal`.

Adds unit tests covering the sentinel-to-callable resolution, the GitHub fetch
(success and HTTP error), and the unsupported/no-provider branches.

Partially addresses Azure#28708

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…token refresh

Extends `--federated-identity` (GitHub Actions only) to also refresh OIDC federated
tokens on Azure DevOps Pipelines, so long-running pipeline tasks no longer fail with
`AADSTS700024`.

The provider dispatcher now detects Azure DevOps and POSTs to the pipeline oidctoken
API, following the documented Azure DevOps / azure-identity `AzurePipelinesCredential`
contract. Because the refresh runs in a later `az` process, the three required inputs
are read from the environment:

- request URL:  ARM_OIDC_REQUEST_URL, else SYSTEM_OIDCREQUESTURI
- access token: ARM_OIDC_REQUEST_TOKEN, else SYSTEM_ACCESSTOKEN (System.AccessToken)
- service conn: ARM_OIDC_AZURE_SERVICE_CONNECTION_ID

Missing variables produce a clear, actionable error. Adds unit tests for the Azure
DevOps success path, missing-environment handling, and updates the help text.

Partially addresses Azure#28708

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…oken refresh

Adds a provider-agnostic escape hatch alongside the built-in `--federated-identity`
providers. `--federated-token-callback <command>` takes any command that prints a
fresh OIDC token to stdout; Azure CLI wraps it as the MSAL client_assertion callable
and re-runs it on demand, so token refresh works with any CI/CD system (not just the
built-in GitHub Actions / Azure DevOps providers) without platform-specific logic in
the CLI.

- The command is persisted (client_assertion_callback) so later `az` processes rebuild
  the callable and refresh independently.
- Mutually exclusive with --federated-token and --federated-identity; service principal
  only. Clear errors on non-zero exit or empty output. The token value is never logged.

The three flags now cover the full spectrum: static token (--federated-token),
built-in providers (--federated-identity), and universal callback
(--federated-token-callback).

Partially addresses Azure#28708

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Harden --federated-token-callback: parse the command into an argv list and run it
  without a shell (shell=False), so a tampered token cache cannot become arbitrary
  code execution. Users needing pipes/redirection use a script or wrap in bash -c.
- Reject combining --federated-token/--federated-identity/--federated-token-callback
  with --password or --certificate (previously the secret silently won and refresh
  was silently disabled).
- Fix the GitHub OIDC request URL to append the audience with the correct separator
  when the URL has no existing query string.
- Correct the misleading --service-principal usage error to list all credential modes.
- Align --federated-identity help text with the actual mutual-exclusion validation.
- Add tests for the no-shell argv behavior and the query-less GitHub URL case.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…on-length linter

The --federated-token-callback option (26 chars) exceeds azure-cli's 22-char
option-length threshold, so add the shorter --federated-token-cmd alias.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.