Skip to content

Conversation

@HuihuiWu-Microsoft
Copy link
Contributor

@HuihuiWu-Microsoft HuihuiWu-Microsoft commented Dec 5, 2025

Support authentication in broker for following flows:

  1. VSC m365 login
  2. CLI m365 interactive login
  3. CLI azure interactive login
    ADO: https://msazure.visualstudio.com/Microsoft%20Teams%20Extensibility/_workitems/edit/33871096/?view=edit

Screenshots:

Login success with broker auth

Details
1> Introduced @azure/msal-node-extension package to add NativeBrokerPlugin for broker authentication support for both VSC and CLI
2> Added a feature toggle to control whether it's applying browser or broker auth
3> Added package mocks for keytar since it's not needed but required by the @azure/msal-node-extension package. Also updated UT mocks to by pass keytar loading
4> Bundle native node modules for @azure/msal-node-extension package including .node and .dll files into VSC extension
5> Upgraded APIs for auth code flow since the legacy API doesn't support broker auth
6> Upgraded typescript and ts node packages for compatibility

@codecov
Copy link

codecov bot commented Dec 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.44%. Comparing base (c119326) to head (e729d60).
⚠️ Report is 30 commits behind head on dev.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##              dev   #14925    +/-   ##
========================================
  Coverage   89.44%   89.44%            
========================================
  Files         605      606     +1     
  Lines       37157    37210    +53     
  Branches     7449     7602   +153     
========================================
+ Hits        33236    33284    +48     
- Misses       1836     1838     +2     
- Partials     2085     2088     +3     
Files with missing lines Coverage Δ
...ckages/cli/src/commonlib/common/tokenCacheUtils.ts 100.00% <100.00%> (ø)
packages/fx-core/src/common/featureFlags.ts 96.92% <100.00%> (+0.09%) ⬆️

... and 6 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@HuihuiWu-Microsoft HuihuiWu-Microsoft marked this pull request as ready for review December 18, 2025 09:09
Copy link
Contributor

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 adds broker authentication support to enable more secure authentication flows for Microsoft 365 logins in VSCode extension and CLI. The changes implement Windows Authentication Broker (WAM) support using MSAL's native broker plugin for improved user authentication experience.

Key Changes

  • Integrated @azure/msal-node-extensions to enable broker-based authentication on Windows
  • Added fallback logic between broker and browser authentication flows
  • Implemented platform-specific native module handling for keytar and msal-node-runtime
  • Created utility functions for token cache management

Reviewed changes

Copilot reviewed 23 out of 41 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/vscode-extension/src/commonlib/m365Login.ts Added broker plugin configuration with Windows platform check
packages/vscode-extension/src/commonlib/codeFlowLogin.ts Implemented new loginWithBroker method and refactored token acquisition logic
packages/vscode-extension/src/commonlib/common/tokenCacheUtils.ts Added utility function for account lookup by homeAccountId
packages/vscode-extension/esbuild.mjs Added native module copying for Windows MSAL binaries
packages/vscode-extension/packageMocks/keytar/* Created mock keytar implementation to avoid native module issues
packages/vscode-extension/package.json Added msal-node-extensions dependency and enabled nativeWindowHandle API
packages/fx-core/src/common/featureFlags.ts Added BrokerAuth feature flag
pnpm-workspace.yaml Added keytar to onlyBuiltDependencies
Files not reviewed (2)
  • packages/api/pnpm-lock.yaml: Language not supported
  • packages/fx-core/pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Choose a reason for hiding this comment

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

Translation file changes should be removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants