Skip to content

WorkloadIdentityTokenProvider

Exchanges the projected service account token AKS’s workload identity webhook mounts into the pod for a Storage-scoped Azure AD access token, via the OAuth2 JWT-bearer client-assertion flow.

Needs no secret: the assertion is the federated token file, not a client secret.

WorkloadIdentityTokenProvider::fromEnvironment() reads the four variables the webhook injects (AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_FEDERATED_TOKEN_FILE, AZURE_AUTHORITY_HOST), the same ones the official Azure SDKs’ WorkloadIdentityCredential reads, so a pod annotated for workload identity needs no Quiote-specific configuration at all.

final class WorkloadIdentityTokenProvider implements AzureTokenProvider

ImplementsAzureTokenProvider
SourceWorkloadIdentityTokenProvider.php

public function __construct(ClientInterface $httpClient, string $tenantId, string $clientId, string $federatedTokenFile, string $authorityHost = 'https://login.microsoftonline.com/', Psr17Factory $psr17 = new Psr17Factory(…), string $scope = 'https://storage.azure.com/.default'): mixed

ParameterTypeDescription
$httpClientClientInterface
$tenantIdstring
$clientIdstring
$federatedTokenFilestring
$authorityHoststring
$psr17Psr17Factory
$scopestring

Returns mixed

MethodDescription
fromEnvironment(ClientInterface $httpClient, Psr17Factory $psr17 = new Psr17Factory(…), string $scope = 'https://storage.azure.com/.default'): WorkloadIdentityTokenProvider
getToken(): string

public static function fromEnvironment(ClientInterface $httpClient, Psr17Factory $psr17 = new Psr17Factory(…), string $scope = 'https://storage.azure.com/.default'): WorkloadIdentityTokenProvider

ParameterTypeDescription
$httpClientClientInterface
$psr17Psr17Factory
$scopestring

Returns WorkloadIdentityTokenProvider

ThrowsWhen
AzureStorageExceptionIf any of the four AKS workload identity variables is missing from the environment.

public function getToken(): string

Returns string