Skip to content

Conversation

minhanh-phan
Copy link
Member

@minhanh-phan minhanh-phan commented Sep 4, 2025

Packages impacted by this PR

@azure/identity
@azure/identity-vscode
@azure/identity-broker

Describe the problem that is addressed by this PR

There's a scenario in which interactive authentication might show up for VisualStudioCodeCredential when the plugin is set but the broker is not available. This is because in MSAL implementation, a stub class instance is imported so that static imports won't throw.

The PR ensures:

  • disableAutomaticAuthentication is set internally for VisualStudioCodeCredential so no interactive authentication would be required
  • Our SDK only proceeds when the plugin is configured and the broker is available. We'll throw errors when either of those is not met with distinct error message for easier debugging.
  • Add additional troubleshooting and prerequisite for clearer doc

What are the possible designs available to address the problem? If there are more than one possible design, why was the one in this PR chosen?

Are there test cases added in this PR? (If not, why?)

Provide a list of related PRs (if any)

Command used to generate this PR:**(Applicable only to SDK release request PRs)

Checklists

  • Added impacted package name to the issue description
  • Does this PR needs any fixes in the SDK Generator?** (If so, create an Issue in the Autorest/typescript repository and link it here)
  • Added a changelog (if necessary)

@minhanh-phan minhanh-phan marked this pull request as ready for review September 4, 2025 22:21
@Copilot Copilot AI review requested due to automatic review settings September 4, 2025 22:21
Copy link
Contributor

@Copilot Copilot AI left a 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 addresses an issue where VisualStudioCodeCredential could trigger interactive authentication prompts when the VS Code plugin is configured but the broker is unavailable. The changes ensure proper error handling and prevent unwanted interactive flows.

Key changes:

  • Adds broker availability validation with clear error messages
  • Sets disableAutomaticAuthentication: true for VS Code credential to prevent interactive prompts
  • Updates documentation with clearer prerequisites and troubleshooting guidance

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
sdk/identity/identity/src/msal/nodeFlows/msalPlugins.ts Adds broker availability checks with descriptive error messages
sdk/identity/identity/src/credentials/visualStudioCodeCredential.ts Sets disableAutomaticAuthentication flag to prevent interactive auth
sdk/identity/identity/test/internal/node/visualStudioCodeCredential.spec.ts Adds test to verify disableAutomaticAuthentication behavior
sdk/identity/identity/TROUBLESHOOTING.md Updates troubleshooting with native dependency errors and platform support
sdk/identity/identity/CHANGELOG.md Documents the bug fix for VS Code credential interactive auth issue
sdk/identity/identity-vscode/README.md Adds prerequisites section with native dependency requirements
sdk/identity/identity-broker/README.md Updates platform support documentation

Co-authored-by: Scott Addie <[email protected]>
Co-authored-by: Scott Addie <[email protected]>
@@ -194,6 +194,18 @@ function generatePluginConfiguration(options: MsalClientOptions): PluginConfigur
].join(" "),
);
}
// There is a scenario where the VSCode plugin is configured but the broker is not available (e.g., missing native dependencies).
// This check ensures we throw an error and not proceed with an invalid configuration.
if (vsCodeBrokerInfo.broker.isBrokerAvailable === false) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: there's a lot of validation scenarios here, consider pulling them out into a separate function to ensures things are configured correctly, just for readbility

@@ -338,6 +338,9 @@ curl 'http://169.254.169.254/metadata/identity/oauth2/token?resource=https://man
| Error Message | Description | Mitigation |
| ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Visual Studio Code Authentication is not available. | No Visual Studio Code plugin configuration is set or no Azure authentication record information was found in the VS Code configuration. | <ul><li>Ensure the [Azure Resources extension](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azureresourcegroups) is properly installed.</li><li>Check that you have signed in through **Azure: Sign In** command. This command opens a browser window and displays a page that allows you to sign in to Azure.</li><li>Install the `@azure/identity-vscode` package with `npm install @azure/identity-vscode` command and set the plugin configuration with `useIdentityPlugin()`</li></ul> | |
| Cannot open shared object file with `ERR_DLOPEN_FAILED` error code| Native dependencies are not properly installed. | <ul><li>Ensure that you are running in a supported environment. Currently, the `vsCodePlugin` is only supported on Windows and Mac OS.</li><li>Ensure the native dependencies are properly installed. Refer to our README prerequisites section for `@azure/identity-vscode`.</li></ul> |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be

Suggested change
| Cannot open shared object file with `ERR_DLOPEN_FAILED` error code| Native dependencies are not properly installed. | <ul><li>Ensure that you are running in a supported environment. Currently, the `vsCodePlugin` is only supported on Windows and Mac OS.</li><li>Ensure the native dependencies are properly installed. Refer to our README prerequisites section for `@azure/identity-vscode`.</li></ul> |
| Cannot open shared object file with `ERR_DLOPEN_FAILED` error code| Native dependencies are not properly installed. | <ul><li>Ensure that you are running in a supported environment. Currently, the `vsCodePlugin` is only supported on Windows.</li><li>Ensure the native dependencies are properly installed. Refer to our README prerequisites section for `@azure/identity-vscode`.</li></ul> |

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Untriaged
Development

Successfully merging this pull request may close these issues.

4 participants