Entra ID Authentication#
Overview#
MicrosoftEntraIDProvider is the dedicated oauth2-proxy provider for Microsoft Entra ID (formerly Azure AD). It wraps OIDCProvider and adds Entra-specific behavior: multi-tenant allowed-tenant enforcement, group overage resolution via Microsoft Graph, and federated token (Workload Identity) authentication. The provider is fully OIDC-compliant β all standard OIDC parameters apply β but requires Entra-specific configuration for multi-tenant and advanced scenarios.
Entry point: providers/ms_entra_id.go
Note: This provider (
provider = "entra-id") is distinct from the legacyazureprovider, which is deprecated.
Configuration#
Full reference: Microsoft Entra ID provider docs
Provider-Specific Flags#
| Flag | TOML | Type | Default | Description |
|---|---|---|---|---|
--entra-id-allowed-tenant | entra_id_allowed_tenants | string list | (all allowed) | Tenant IDs permitted in multi-tenant apps. When empty, all tenants pass. Redundant for single-tenant apps. |
--entra-id-federated-token-auth | entra_id_federated_token_auth | bool | false | Use Workload Identity federated token instead of client_secret. |
Defined in MicrosoftEntraIDOptions.
Issuer URL Patterns#
| Scenario | oidc_issuer_url | Notes |
|---|---|---|
| Single-tenant | https://login.microsoftonline.com/<tenant-id>/v2.0 | Standard; issuer verification works normally. |
| Multi-tenant | https://login.microsoftonline.com/common/v2.0 | Requires insecure_oidc_skip_issuer_verification=true; provider re-validates issuer format internally. |
Scopes#
openidβ minimum for loginopenid User.Readβ required when users have 200+ group memberships (group overage)openid profile emailβ required for personal Microsoft accounts
Issuer Validation & Tenant ID Extraction#
Current Behavior#
getTenantFromToken() extracts the tenant ID from the ID token's iss claim using a hardcoded regex:
^https://login\.microsoftonline\.com/([a-zA-Z0-9-]+)/v2\.0$
This extracted tenant ID drives two behaviors:
- Multi-tenant validation β if
--entra-id-allowed-tenantis set, the tenant is checked against the allowlist inValidateSession(). - Issuer format check β for multi-tenant deployments, the provider re-validates the issuer claim matches the
https://login.microsoftonline.com/{tenant-id}/v2.0template even wheninsecure_oidc_skip_issuer_verification=true.
Known Limitation: CIAM and Sovereign Clouds#
The regex exclusively matches login.microsoftonline.com, causing getTenantFromToken() to return an error for:
- CIAM / External tenants β issuers in the form
https://<tenantId>.ciamlogin.com/<tenantId>/v2.0 - Sovereign clouds β national cloud deployments (Azure Government, Azure China, etc.) use different issuer host names
Tracking issue: #3476 | Pending fix: PR #3229
Pending Fix (PR #3229)#
PR #3229 proposes reading the tid claim from the ID token payload first, falling back to the iss regex only when tid is absent. Because Microsoft includes tid in all Entra ID tokens β including CIAM β this approach makes tenant extraction issuer-agnostic without requiring regex expansion or new configuration options.
Group Overage Handling#
Entra ID embeds group memberships in the ID token, but only up to 200 groups. When a user exceeds this limit, the token contains a _claim_names.groups key instead of a groups list β the "overage" signal .
Flow:
EnrichSession()callscheckGroupOverage(), which looks for_claim_names.groupsin the token.- If overage is detected,
addGraphGroupsToSession()fetches the full membership list from the Microsoft Graph API endpointGET /v1.0/me/transitiveMemberOf?$select=id&$top=100, paginating via@odata.nextLinkuntil all groups are collected. - Results are deduplicated and merged into
session.Groups.
Prerequisite: The User.Read delegated scope must be granted β either via user consent at first login or admin pre-consent β and the scope config must include User.Read .
Federated Token (Workload Identity) Authentication#
When entra_id_federated_token_auth = true, oauth2-proxy authenticates to Entra ID using a Workload Identity federated token instead of a client_secret. This is the recommended approach for Kubernetes-hosted deployments.
How it works:
redeemWithFederatedToken()reads the token from the file path inAZURE_FEDERATED_TOKEN_FILE(set by the Workload Identity mutating webhook).- The token is sent as
client_assertionwithclient_assertion_type: urn:ietf:params:oauth:client-assertion-type:jwt-bearerin the token exchange request . - Token refresh also uses the federated credential via
redeemRefreshTokenWithFederatedToken().
Requirements :
- App registration must have a federated identity credential configured with audience
api://AzureADTokenExchange. - The Pod must carry Workload Identity annotations (
azure.workload.identity/client-idandazure.workload.identity/use: "true"). - Set
entra_id_federated_token_auth = true;client_secretcan be omitted.