azure-oss/identity
A PHP identity library for acquiring Microsoft Entra ID access tokens via client secret, client certificate, workload identity, managed identity, chained, and default credential flows. Uses PSR-18/17 HTTP implementations. Community-maintained and not affiliated with Microsoft.
azure-oss/identity package provides PHP bindings for Azure Identity SDK, enabling authentication with Azure Active Directory (AAD) via OAuth2, client credentials, managed identities, and other Azure-specific flows. This is a strong fit for Laravel applications requiring Azure integration (e.g., Azure Blob Storage, Cosmos DB, Key Vault, or Azure Functions).AzureIdentityClient can be bound as a singleton). The package’s focus on HTTP-based auth (PSR-18 compliant) ensures seamless integration with Laravel’s HTTP stack (Guzzle, Symfony HTTP Client).azure-oss/storage-blob-php).InMemoryTokenCache or custom PSR-16 caches (e.g., Laravel’s cache drivers).azure/identity (Python) and azure-core (JavaScript) for core logic, introducing indirect risk if upstream changes break PHP bindings.client_id, client_secret) violates Laravel best practices; requires integration with Laravel Forge, Envoyer, or Azure Key Vault.AzureIdentityException) need custom Laravel exception handlers or middleware.client_secret/tenant_id be stored? (Laravel Env, Key Vault, or another system?)AzureIdentityClient as a singleton in AppServiceProvider:
$this->app->singleton(AzureIdentityClient::class, function ($app) {
return new AzureIdentityClient(
new ClientSecretCredential(
config('azure.tenant_id'),
config('azure.client_id'),
config('azure.client_secret')
),
new InMemoryTokenCache() // or PSR-16 cache
);
});
config/azure.php for credentials:
'azure' => [
'tenant_id' => env('AZURE_TENANT_ID'),
'client_id' => env('AZURE_CLIENT_ID'),
'client_secret' => env('AZURE_CLIENT_SECRET'),
],
$token = app(AzureIdentityClient::class)->getToken('https://storage.azure.com/.default');
$response = Http::withHeaders(['Authorization' => 'Bearer ' . $token->accessToken())->get('...');
azure-oss/storage-blob-php for signed requests.azure-oss/keyvault-secrets-php for secret retrieval.azure-oss/cosmos-php for auth.composer require azure-oss/identity.AzureIdentityClient binding and config.AzureRetryPolicy).AzureIdentityLogger).azure/identity (Python) and azure-core (JavaScript) versions.https://storage.azure.com/.default)..env or Key Vault).AzureIdentityClient binding.azure-oss/identity for updates (low frequency but critical for security/feature parity).client_secret rotation via Laravel Forge/Envoyer or Azure Key Vault.$client = new AzureIdentityClient(..., new AzureIdentityLogger());
TokenCredentialCache with appropriate TTL (e.g., 55 minutes for 1-hour tokens).| Failure Scenario | Impact | Mitigation |
|---|---|---|
Invalid client_secret |
All auth requests fail (401). | Use Azure Key Vault + secret rotation. |
| Network partition (Azure AD) | Token acquisition timeouts. | Implement retries with exponential backoff. |
| Token cache corruption | Stale tokens cause 401s. | Use short-lived cache or distributed cache. |
| Azure AD outage | Auth unavailable. | Implement fallback (e.g., local dev tokens). |
| Credential rotation misconfiguration | Broken auth post-rotation. | Automate rotation via CI/CD. |
How can I help you explore Laravel packages today?