Conversation
Adds AzureAuth, a DelegatedTokenProvider that exchanges a Microsoft Entra ID (Azure) access token for a Datadog delegated token, mirroring the existing AWSAuth and the delegated-token contract. The access token is sourced from (in order): the AzureAuth.AccessToken field, the DD_AZURE_ACCESS_TOKEN environment variable (or its ContextAzureVariables context override), or minted via 'az account get-access-token' (optionally scoped with the Resource field). Org routing follows the delegated-token servicer contract: the proof is '<access-token>:<org-uuid>' - the servicer splits on the last colon (JWTs contain no colons) and treats the suffix as the org UUID. Also mirrors the provider into the code generator: azure.j2 (extra file), configuration.j2 (ContextAzureVariables + DD_AZURE_ACCESS_TOKEN env pickup), and example_azure.j2 (examples/datadog/azure/main.go) so the provider survives regeneration. Co-authored-by: Nathan Spring <nathan.spring@datadoghq.com>
The inline delegatedTokenTestContext copy in azure_test.go collides with the identically-named helper added by the GCP delegated auth PR (#4590) - whichever PR merges second would break the tests module compile on master. Restore the shared provider-generic helper file from the GCP branch instead: identical content on both branches means the second merge is a no-op for this path. Co-authored-by: Nathan Spring <nathan.spring@datadoghq.com>
- The new no-token error case empties PATH in the test loop so
exec.LookPath("az") fails deterministically on machines with the
Azure CLI installed (dev boxes and CI alike); previously the case
would shell out to a real, logged-in az.
- exec.ExitError.Error() renders only 'exit status N', dropping the
stderr Output() captured (e.g. login-required diagnostics). Surface
the trimmed stderr in the wrapped error so mint failures are
diagnosable.
Co-authored-by: Nathan Spring <nathan.spring@datadoghq.com>
Tests a fake az executable on PATH exercising the real mintAccessToken path hermetically: pins JSON output mode (token extracted without depending on JMESPath behavior across az versions), the --resource passthrough, token parsing, and the error path surfacing CLI stderr. Works on machines with and without the Azure CLI installed. Co-authored-by: Nathan Spring <nathan.spring@datadoghq.com>
The helpers are unexported in package datadog and the tests module cannot call them directly; the mint paths are covered end to end by the PATH-shim tests instead. Co-authored-by: Nathan Spring <nathan.spring@datadoghq.com>
The stderr-fix commit updated azure.go but not its generator template, and the factored-out-for-testing comment cleanup also missed the template - the next regeneration would have reverted both changes. Rebuilt azure.j2 from the checked-in body; render parity verified. Co-authored-by: Nathan Spring <nathan.spring@datadoghq.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds Azure support for delegated authentication through a new
AzureAuthprovider.Applications can provide a pre-minted Microsoft Entra ID access token or inject a
TokenSourcethat acquires and renews tokens. The client does not invoke the Azure CLI or add an Azure SDK dependency.Review guide
The change is split into four parts:
api/datadog/azure.godefinesAzureAuth, token resolution, and proof construction.api/datadog/configuration.goloadsDD_AZURE_ACCESS_TOKENinto the default context..generator/contains the matching templates so regeneration preserves the feature.tests/api/azure_test.gocovers token precedence, failures, and the authentication proof.Token resolution
AzureAuthresolves an access token in this order:AzureAuth.AccessTokenContextAzureVariablesorDD_AZURE_ACCESS_TOKENAzureAuth.TokenSourceTokenSourcehas this signature:The application owns credential selection, tenant selection, audience or scope, and token renewal. This lets applications adapt Managed Identity, Workload Identity, or an explicitly selected developer credential without making those choices inside the API client.
Authentication flow
After resolving the access token,
AzureAuthincludes the Datadog organization UUID in the Azure delegated authentication proof and exchanges it for a Datadog delegated token through the existingDelegatedTokenProviderinterface.Usage
Using a pre-minted token from
DD_AZURE_ACCESS_TOKEN:Using application-managed token acquisition:
applicationAzureTokenSourceis anyfunc(context.Context) (string, error)that returns a current Microsoft Entra ID access token.Testing
tests/api/azure_test.gocovers:TokenSourceVerified with:
go test ./api -run '^TestAzure'from thetestsmodulego test ./api/datadoggo test ./examples/datadog/azureRelated change
PR #4590 adds the corresponding GCP provider. The two PRs may have small mechanical conflicts in shared generator and configuration maps if merged out of order.