-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[Identity] Make credentials and DAC list public #9274
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import { EnvironmentCredential } from "./environmentCredential"; | |
import { ManagedIdentityCredential } from "./managedIdentityCredential"; | ||
import { AzureCliCredential } from "./azureCliCredential"; | ||
import { VSCodeCredential } from "./vscodeCredential"; | ||
import { TokenCredential } from "@azure/core-http"; | ||
|
||
/** | ||
* Provides a default {@link ChainedTokenCredential} configuration for | ||
|
@@ -21,11 +22,11 @@ import { VSCodeCredential } from "./vscodeCredential"; | |
*/ | ||
export class DefaultAzureCredential extends ChainedTokenCredential { | ||
/** | ||
* Creates an instance of the DefaultAzureCredential class. | ||
* Returns the list of credentials DefaultAzureCredential will use to authenticate. | ||
* | ||
* @param options Options for configuring the client which makes the authentication request. | ||
*/ | ||
constructor(tokenCredentialOptions?: TokenCredentialOptions) { | ||
static credentials(tokenCredentialOptions?: TokenCredentialOptions): TokenCredential[] { | ||
let credentials = []; | ||
credentials.push(new EnvironmentCredential(tokenCredentialOptions)); | ||
credentials.push(new ManagedIdentityCredential(tokenCredentialOptions)); | ||
|
@@ -35,6 +36,15 @@ export class DefaultAzureCredential extends ChainedTokenCredential { | |
credentials.push(new AzureCliCredential()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't currently accept or use the settings. We can take on some work for the next preview to bring AzureCli to the same style that the other credentials are using. |
||
credentials.push(new VSCodeCredential(tokenCredentialOptions)); | ||
|
||
return credentials; | ||
} | ||
/** | ||
* Creates an instance of the DefaultAzureCredential class. | ||
* | ||
* @param options Options for configuring the client which makes the authentication request. | ||
*/ | ||
constructor(tokenCredentialOptions?: TokenCredentialOptions) { | ||
let credentials = DefaultAzureCredential.credentials(tokenCredentialOptions); | ||
super( | ||
...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.
Should this be refactored so it's not exposed?
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.
The mock will overwrite this. For that to work, it has to at least be protected. We can document that this isn't intended to be used publicly.
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.
Is there not another way to mock / test this? I'm not a big fan of adding public surface area for testing purposes. If we can't fix it for this preview could we file an issue to fix before GA?
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.
This is coming from the mocking that is used for testing, since we can't override that method if it's private.
Can look into a better approach for the next preview.