Skip to content

fix: prefer AZURE_FEDERATED_TOKEN_FILE over hardcoded OIDC token path - #1281

Merged
jonasz-lasut merged 1 commit into
crossplane-contrib:mainfrom
gravufo:fix/oidc-token-file-path-env
Aug 4, 2026
Merged

fix: prefer AZURE_FEDERATED_TOKEN_FILE over hardcoded OIDC token path#1281
jonasz-lasut merged 1 commit into
crossplane-contrib:mainfrom
gravufo:fix/oidc-token-file-path-env

Conversation

@gravufo

@gravufo gravufo commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Description of your changes

oidcAuth() hardcoded the OIDC token file path to /var/run/secrets/azure/tokens/azure-identity-token whenever oidcTokenFilePath was left unset on the ProviderConfig/ClusterProviderConfig. That path is owned and versioned by the AKS azure-workload-identity webhook, which moved it as a documented breaking change in v1.6.0:

https://github.com/Azure/azure-workload-identity/releases/tag/v1.6.0

Never hardcode the token file path. Always read AZURE_FEDERATED_TOKEN_FILE — the webhook owns this path and it may change again in future releases.

The webhook already sets AZURE_FEDERATED_TOKEN_FILE in the container to wherever it actually projected the token. This change reads that env var when no explicit oidcTokenFilePath is configured, and only falls back to the historical hardcoded constant if the env var is also unset (preserving current behavior for anyone relying on it, e.g. clusters still on pre-v1.6.0 webhook builds).

Precedence, in order:

  1. spec.oidcTokenFilePath if explicitly set (unchanged, still wins).
  2. AZURE_FEDERATED_TOKEN_FILE env var (new).
  3. Hardcoded default path (unchanged fallback).

Fixes #1280

I have:

  • Read and followed Crossplane's contribution process.
  • Run make reviewable to ensure this PR is ready for review.
  • Added backport release-x.y labels to auto-backport this PR if necessary.

How has this code been tested

  • Added Test_oidcAuth_tokenFilePath covering all four precedence cases (explicit path wins over env, env used when no explicit path, falls back to default when env unset, falls back to default when env set but empty).
  • Ran go build, go vet, go test ./internal/clients/..., and golangci-lint run internal/clients/... locally.

All pass.

Note

I did this change with backward compatibility in mind. Personally, I would prefer entirely removing the hardcoded path, since it is not even correct anymore and just rely on the env var or the parameter.
Please let me know if you prefer I do that!

oidcAuth() defaulted the OIDC token file path to a hardcoded constant
matching the azure-workload-identity webhook's old mount location. The
webhook moved that path in v1.6.0 (a documented breaking change) and
now sets AZURE_FEDERATED_TOKEN_FILE to the current location instead.

Read AZURE_FEDERATED_TOKEN_FILE when no explicit oidcTokenFilePath is
set, falling back to the historical hardcoded default only if the env
var is also unset, so the provider isn't tied to one specific webhook
mount path.

Fixes crossplane-contrib#1280

Signed-off-by: Christian Artin <gravufo@gmail.com>
@gravufo
gravufo force-pushed the fix/oidc-token-file-path-env branch from 9c24697 to 710de15 Compare August 4, 2026 01:24

@jonasz-lasut jonasz-lasut left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @gravufo LGTM!

@jonasz-lasut
jonasz-lasut merged commit 2245922 into crossplane-contrib:main Aug 4, 2026
8 checks passed
@gravufo
gravufo deleted the fix/oidc-token-file-path-env branch August 4, 2026 12:47
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.

[Bug]: oidcAuth() hardcodes OIDC token file path instead of reading AZURE_FEDERATED_TOKEN_FILE

2 participants