Add chained credential login mode implementing Azure DefaultAzureCredential #707
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.
This PR implements a new
chainedlogin mode that uses Azure SDK'sDefaultAzureCredentialto provide automatic credential chaining functionality. The chained credential automatically tries multiple authentication methods in a predefined order until one succeeds, providing a seamless authentication experience across different environments.What's Changed
Core Implementation
ChainedLoginconstant to supported login methods inpkg/internal/token/options.goChainedCredentialinpkg/internal/token/chainedcredential.gousing Azure SDK'sDefaultAzureCredentialpkg/internal/token/chainedcredential_test.gopkg/internal/token/provider.goto handle the new login modeChainedLoginin public API atpkg/token/options.goDocumentation
docs/book/src/concepts/login-modes/chained.mddocs/book/src/cli/get-token.mdanddocs/book/src/cli/convert-kubeconfig.mddocs/book/src/SUMMARY.mdHow It Works
The chained credential uses Azure SDK's
DefaultAzureCredentialwhich tries authentication methods in this order:AZURE_CLIENT_ID,AZURE_CLIENT_SECRET,AZURE_TENANT_IDenvironment variablesaz loginThe first successful method is used, and subsequent methods are not attempted.
Usage Examples
CLI Usage
Programmatic Usage
Benefits
Testing
This implementation follows the established patterns from PR #703 and provides the credential chaining functionality as documented in the Microsoft Azure SDK authentication documentation.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
invalid-url/tmp/go-build2930695131/b679/token.test -test.paniconexit0 -test.gocoverdir=/tmp/go-build2930695131/b679/gocoverdir -test.timeout=10m0s -test.coverprofile=/tmp/go-build2930695131/b679/_cover_.out(dns block)/tmp/go-build3193955741/b001/token.test -test.testlogfile=/tmp/go-build3193955741/b001/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true(dns block)/tmp/go-build4037732779/b679/token.test -test.paniconexit0 -test.gocoverdir=/tmp/go-build4037732779/b679/gocoverdir -test.timeout=10m0s -test.coverprofile=/tmp/go-build4037732779/b679/_cover_.out(dns block)login.microsoftonline.com./bin/linux_amd64/kubelogin get-token --login chained --server-id dummy-server-id(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.