-
Notifications
You must be signed in to change notification settings - Fork 5k
[Identity] Always include the Broker as part of DAC #52189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[Identity] Always include the Broker as part of DAC #52189
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR changes the DefaultAzureCredential (DAC) factory to always include the Broker credential in the credential chain, even when the Azure.Identity.Broker package is not installed. Instead of throwing an error during DAC construction, the error is now deferred until GetToken()
is called, matching the behavior of VisualStudioCodeCredential
.
Key changes:
- Introduces a new internal
BrokerCredential
type that handles broker availability checks at token request time - Updates the credential factory to unconditionally include broker credentials in the chain
- Modifies tests to account for the additional credential in the chain
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
DefaultAzureCredentialTests.cs |
Updates test assertions to expect 9/10 credentials instead of 8/9, adds broker credential exclusion option |
DefaultAzureCredentialFactoryTests.cs |
Adds broker credential to test matrices, removes broker package availability checks, updates credential count expectations |
DefaultAzureCredentialFactory.cs |
Simplifies broker credential creation by always including it in the chain, removes package availability checks |
BrokerCredential.cs |
New internal credential type that defers broker availability checking to token request time |
DevelopmentBrokerOptionsTests.cs |
Updates test to use simplified broker credential creation method |
DefaultAzureCredentialFactoryTests.cs (Broker package) |
Updates test assertion to expect BrokerCredential type instead of InteractiveBrowserCredential |
sdk/identity/Azure.Identity/src/Credentials/BrokerCredential.cs
Outdated
Show resolved
Hide resolved
sdk/identity/Azure.Identity/src/Credentials/BrokerCredential.cs
Outdated
Show resolved
Hide resolved
sdk/identity/Azure.Identity/src/Credentials/BrokerCredential.cs
Outdated
Show resolved
Hide resolved
sdk/identity/Azure.Identity/src/Credentials/BrokerCredential.cs
Outdated
Show resolved
Hide resolved
sdk/identity/Azure.Identity/src/Credentials/BrokerCredential.cs
Outdated
Show resolved
Hide resolved
sdk/identity/Azure.Identity/src/Credentials/BrokerCredential.cs
Outdated
Show resolved
Hide resolved
sdk/identity/Azure.Identity.Broker/tests/DefaultAzureCredentialFactoryTests.cs
Outdated
Show resolved
Hide resolved
Moved logic for mapping credential options to broker options from BrokerCredential to a new CredentialOptionsMapper class. This improves code organization and reusability by centralizing the mapping logic.
sdk/identity/Azure.Identity.Broker/tests/DevelopmentBrokerOptionsTests.cs
Outdated
Show resolved
Hide resolved
sdk/identity/Azure.Identity/src/Credentials/CredentialOptionsMapper.cs
Outdated
Show resolved
Hide resolved
sdk/identity/Azure.Identity/src/Credentials/CredentialOptionsMapper.cs
Outdated
Show resolved
Hide resolved
sdk/identity/Azure.Identity/src/Credentials/ISupportsTenantId.cs
Outdated
Show resolved
Hide resolved
@@ -343,22 +332,14 @@ public virtual TokenCredential CreateInteractiveBrowserCredential() | |||
Pipeline); | |||
} | |||
|
|||
public TokenCredential CreateBrokerCredential(InteractiveBrowserCredentialOptions brokerOptions) | |||
internal TokenCredential CreateBrokerCredential() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need this method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's used in this factory class to add the Broker into the chain
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I meant was all it does is return new BrokerCredential(options)
- can callers just do that themselves?
sdk/identity/Azure.Identity/tests/TokenCredentialOptionsTests.cs
Outdated
Show resolved
Hide resolved
sdk/identity/Azure.Identity/tests/TokenCredentialOptionsTests.cs
Outdated
Show resolved
Hide resolved
@@ -5,13 +5,14 @@ | |||
using System.Collections.Generic; | |||
using System.Threading; | |||
using System.Threading.Tasks; | |||
using Azure.Identity.Credentials; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All these added using statements can be removed.
Fixes #52138
This PR changes the DAC Factory to always include the Broker even if the Azure.Identity.Broker package is not installed. In order to do this, a new internal
BrokerCredential
type is used, so instead of throwing an error during the construction of DAC, an error will be thrown whenGetToken()
is called.This is the same Behaviour as
VisualStudioCodeCredential
.