Commit Graph

65 Commits

Author SHA1 Message Date
Tyler James Leonhardt
80ee2d8f15 Remove unused LoopbackAuthServer from microsoft-authentication (#295254)
The LoopbackAuthServer class in extensions/microsoft-authentication
is dead code with no references. The active loopback servers live in
extensions/github-authentication and src/vs/workbench/api/node.
2026-02-13 15:48:39 -06:00
Dmitriy Vasyura
aa19df565f Portable mode improvements and bug fixes (#287063)
Disabled protocol handlers and registry updates on Windows in portable mode.
Added API proposal to detect if VS Code is running in portable mode from extensions.
Skipped protocol redirect in GitHub authentication in portable mode.
2026-01-24 13:22:53 +01:00
Tyler James Leonhardt
8244c9f6b9 Add log statement to see environment (#285220) 2025-12-28 07:28:57 +01:00
Tyler James Leonhardt
e3bbd5bb1d Fix MSAL Runtime telemetry not firing (#282595)
We were too strict. This should actually yield telemtry.

Fixes https://github.com/microsoft/vscode/issues/282593
2025-12-10 23:48:55 +00:00
Tyler James Leonhardt
4c96903608 Support brokering from Linux x64 and Intel Macs (#278689)
* Support Linux & Intel Macs

This grabs the native files directly since the ones at the root are not expected to work in our cases, namely Intel Mac where we use arm machines to build the x64 build.

* actually include macOS intel bits
2025-11-21 01:42:11 +00:00
Tyler James Leonhardt
134826b979 Start sending ClientAuthError telemetry for microsoft auth (#278643)
To better bucketize MSAL broker errors.
2025-11-20 12:27:10 -08:00
Copilot
c6464f84b9 Remove classic Microsoft authentication implementation (#276787)
* Initial plan

* Remove classic Microsoft authentication implementation

Co-authored-by: TylerLeonhardt <2644648+TylerLeonhardt@users.noreply.github.com>

* Remove classic implementation

* extra space

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: TylerLeonhardt <2644648+TylerLeonhardt@users.noreply.github.com>
Co-authored-by: Tyler Leonhardt <tyleonha@microsoft.com>
2025-11-11 23:18:53 +00:00
Tyler James Leonhardt
a3fcd46091 Remove web worker support from microsoft-authentication extension (#276762)
* Initial plan

* Remove web worker support from microsoft-authentication extension

- Remove browser entry point from package.json
- Remove browser webpack configuration
- Remove browser-specific scripts (compile-web, watch-web)
- Remove src/browser/ directory with browser-specific implementations
- Remove ExtensionHost.WebWorker enum value
- Remove supportsWebWorkerExtensionHost flags from all flows
- Simplify authProvider.ts by removing web worker detection logic
- Remove web worker test case from flows.test.ts
- Successfully compiled with 0 errors

Co-authored-by: TylerLeonhardt <2644648+TylerLeonhardt@users.noreply.github.com>

* couple references

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
2025-11-11 11:09:39 -08:00
Tyler James Leonhardt
d751a3d55f Add device code flow when not brokered (#270453)
fixes https://github.com/microsoft/vscode/issues/270452
2025-10-08 16:49:23 -07:00
Tyler James Leonhardt
d8c3a3263d Add redirect URI and update MSAL packages (#268939)
* Bump MSAL packages further

To hopefully fix bugs

* add redirect uri
2025-09-29 19:57:44 +00:00
Tyler James Leonhardt
bf0108fb1e Re-enable MSAL broker on macOS (#267833)
Fixes https://github.com/microsoft/vscode/issues/260158
2025-09-22 13:36:31 -07:00
Tyler James Leonhardt
3e2f34ebe8 Address API sync feedback for challenges API (#265921)
* Address API sync feedback for challenges API

* use `fallbackScopes` instead of `scopes`
* `WWW`-> `Www`

ref https://github.com/microsoft/vscode/issues/260156

* adopt the change
2025-09-09 17:05:43 -04:00
Matt Bierner
46433f1a75 Fix ms auth compile error 2025-09-05 14:52:25 -07:00
Tyler James Leonhardt
7a4d034fc5 Disable macOS broker support due to blocking MSAL bug (#264954)
Sigh... Unfortunately, MSAL seems to fail for clients that don't have managed machines that have opted in to the broker... I have opened a blocking issue on them internally.

At least, when they fix it, it would just be a matter of updating the package version and the conditional here.
2025-09-03 17:30:49 +00:00
Tyler James Leonhardt
151a19f321 Only add the broker if it's available (#264785)
We shouldn't have to do this, but let's see if this resolves issues with users who don't have the broker installed.
2025-09-02 22:28:03 +00:00
Tyler James Leonhardt
70e7eae770 MSAL Redirect Funkiness (#264057)
Why do they do this to me...
2025-08-29 08:47:16 -10:00
Tyler James Leonhardt
7e8f8e9230 Add new msal-no-broker implementation option to allow for getting rid of classic soon (#263966)
Also, removes the redirectUri from acquireTokenSilent because MSAL was throwing because of it.
2025-08-29 09:01:02 +02:00
Tyler James Leonhardt
2e43a0c0d6 Handle authority & redirectUri in acquireTokenByRefreshToken (#263958)
Handle authority in acquireTokenByRefreshToken

This fixes the migration logic for clients that that moving from MSAL to MSAL+Broker
2025-08-29 04:27:54 +00:00
Tyler James Leonhardt
5b25d491ca Add a log statement for acquireTokenSilent (#263951)
* Add a log statement for acquireTokenSilent

* stringify
2025-08-29 06:09:28 +02:00
Tyler James Leonhardt
da3cf78129 Enable the broker in macOS (#261148)
* Enable the broker in macOS

Fixes https://github.com/microsoft/vscode/issues/260158

* for testing

* better globbing

* guh

* guh

* delete

* log it all

* let's just log everything

* Only do on supported OS/Arches

* Add a console.log

* look at VSCODE_ARCH

* add msal files

* add entitlement maybe here

* actually it's probably here

* build: bundle msal libs for x64 and arm64

* revert that

* try again

* try adding $(AppIdentifierPrefix)

* temp: add debuggee entitlements

* bump msal and pass in redirect uri on macOS

* revert entitlement files

* forgot the .helper

* Allow PII for the output channel only

* use unsigned option

---------

Co-authored-by: deepak1556 <hop2deep@gmail.com>
2025-08-27 14:31:09 -07:00
Tyler James Leonhardt
cf433b58e5 Ability to pass down WWW-Authenticate challenges down to Auth Providers (#261717)
* Initial plan

* Implement authentication challenges support for mandatory MFA

Co-authored-by: TylerLeonhardt <2644648+TylerLeonhardt@users.noreply.github.com>

* Add documentation and integration test for authentication challenges

Co-authored-by: TylerLeonhardt <2644648+TylerLeonhardt@users.noreply.github.com>

* Add validation script and finalize implementation

Co-authored-by: TylerLeonhardt <2644648+TylerLeonhardt@users.noreply.github.com>

* Update authentication challenges API to use AuthenticationConstraint interface

Co-authored-by: TylerLeonhardt <2644648+TylerLeonhardt@users.noreply.github.com>

* Get it compiling... who knows if it works

* New parseWWWAuthenticateHeader behavior

* works

* let's go with this for now

* Good shape

* bye

* final polish

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
2025-08-14 18:10:05 -07:00
Tyler James Leonhardt
86ff5cd43b Use the tenantId property instead (#260418)
since it _seems_ most of the time, the idTokenClaims are not present.
2025-08-07 22:02:13 +00:00
Matt Bierner
30b93b1217 Bump extensions to target es2024
I reviewed the various changes and library additions of es2024 and it seems they are widely supported across node and modern browsers
2025-08-05 10:40:33 -07:00
Tyler James Leonhardt
c235626145 issuer -> authorizationServer refactor (#250359)
* `issuer` -> `authorizationServer` refactor

Also:
* adds `authorizationServerGlobs` to the authentication contribution schema
* removes ugly MCP issuer hack and instead plumbs the authorizationServer down to the new auth providers
2025-06-02 17:38:21 -07:00
Tyler James Leonhardt
86efdcd2c1 Introduce Issuer handling in the Authentication stack (#248948)
Mostly plumbing... this enables:
```
vscode.authentication.getSession('microsoft', scopes, { issuer: "https://login.microsoftonline.com/common/v2.0" });
```
And the respective API for an auth providers to handle it being passed in.

This props up work in MCP land which needs a way to map an issuer to an auth provider... but I certainly see utility outside of that space.

Fixes https://github.com/microsoft/vscode/issues/248775#issuecomment-2876711396
2025-05-14 23:02:15 +02:00
Tyler James Leonhardt
b2224f2fc6 Improve logic for detection of node vs web worker extension host (#248534)
* Use `WorkerGlobalScope` instead of `navigator` since node defines `navigator` now

* microsoft auth too

* better logic
2025-05-09 19:37:27 +02:00
Tyler James Leonhardt
febbcf78c8 Add even more MSAL error telemetry (#246335) 2025-04-11 19:42:41 +02:00
Tyler James Leonhardt
0ab622083b Add error telemetry (#246262) 2025-04-10 23:46:53 -07:00
Tyler James Leonhardt
28c596a419 Use toLower for Microsoft auth labels (#245732)
Fixes https://github.com/microsoft/vscode/issues/242510
2025-04-04 23:43:08 +02:00
Tyler James Leonhardt
eab6f90c72 Better lifecycle handling (#242758)
I moved to a factory model because there was just so much that needed to be async.

I think the amount of async code will be reduced in the future as we remove some migration logic, but this makes sure we don't accidentally create instances without awaiting their initialization.
2025-03-06 02:50:14 +01:00
Tyler James Leonhardt
9e0461087b Make account access cross client ids (#242721)
The point here is that the user already allowed access to the account for one client id, so that should just apply to any client id that is being used since:
* If we don't actually _have_ an auth token, the user will be asked to log in - so they will see a prompt as expected
* If we _do_ have an auth token, then we rely on extension auth access to gate access to the account

Fixes https://github.com/microsoft/vscode/issues/241526
2025-03-05 20:58:49 +01:00
Tyler James Leonhardt
95ab795ff0 Detach authority/tenant from the PublicClientApp (#242719)
everything
2025-03-05 19:55:10 +01:00
Tyler James Leonhardt
5571308162 Force an update after acquiring a token interactively (#239539)
* Force an update after acquiring a token interactively

This will make sure the account cache is up-to-date before the acquireTokenInteractive ends.

A greater fix is maybe turning the accounts cache to be a promise... bit this is the candidate fix for now.

Fixes #235327

* also delete event
2025-02-03 23:56:45 +01:00
Tyler James Leonhardt
60230a46df Fix the booleans on the MSAL flows (#238148)
* Loopback does _not_ work in REH or WebWorker
* UrlHandler _does_ work in REH
2025-01-17 19:46:29 +01:00
Tyler James Leonhardt
e6cba379a4 Try asking for different claims in another request (#237531)
I'm hoping that this solution will be good enough until we stop depending on the id token for certain things.

Fixes https://github.com/microsoft/vscode/issues/237370
2025-01-08 23:55:18 +01:00
Tyler James Leonhardt
691eaea3bd Remove old code, simplify properties (#237512) 2025-01-08 19:11:01 +01:00
Tyler James Leonhardt
1410d77f6f reverse cancellation and sequencer (#237029)
When we cancel, then the promise should be cancelled. If we don't do this, we hang on the first interaction request until we timeout.

Fixes the 2nd point in https://github.com/microsoft/vscode/issues/236825#issuecomment-2563882150
2024-12-28 09:36:05 +01:00
Tyler James Leonhardt
0a66dc39ff Adopt concept of flows in Microsoft Auth (#237006)
And only use Loopback flow when not running in Remote Extension Host.
2024-12-27 11:31:53 -08:00
Tyler James Leonhardt
358e96ab1e Cancel if the user dismisses the modal (#236642)
Fixes https://github.com/microsoft/vscode/issues/235364
2024-12-19 21:40:19 +01:00
Tyler James Leonhardt
d55cb9a7a0 Use claims to force an idToken in Broker flow (#236623)
Looks like the Broker doesn't support `forceRefresh`... This is an alternative way of forcing a refresh.

Fixes https://github.com/microsoft/vscode/issues/229456
2024-12-19 19:25:37 +01:00
Tyler James Leonhardt
b425f4802f Check idtoken expiration (#236011)
and force expiration in a similar way to the way MSAL does it for access tokens.

Fixes https://github.com/microsoft/vscode/issues/229456
2024-12-13 02:45:44 +01:00
Tyler James Leonhardt
c0c6b07185 Disable MSAL for now (#235048)
Because of late breaking issues:

* https://github.com/microsoft/vscode/issues/234932
* https://github.com/microsoft/vscode/issues/234954

This also comments out the `_setupRefresh` logic since that is causing the high CPU load. I'd like to see what happens when we don't do this behavior.
2024-12-03 01:39:32 +00:00
Tyler James Leonhardt
893926f953 Always update refresh & sequencialize updates (#234716) 2024-11-27 05:38:53 -08:00
Tyler James Leonhardt
7ddb65bac8 Update logging & delete dead code (#234458)
* Update logging values so the logs aren't so noisy
* Delete a bunch of dead async code
2024-11-23 01:17:07 +01:00
Tyler James Leonhardt
f6dd987698 No need for memento hack (#234450)
MSAL node made `clearCache` synchronous 🎉 so we can safely depend on it for clearing the cache.

> Context: The default behavior of MSAL's internal cache is that it is a union with what's in the persistant cache (secret storage) but what _we_ want is that secret storage is the source of truth, so every time we receive an update to secret storage, we clear the in-memory cache to get the data from the persistant cache.

Also bumps msal-node-extensions while we're at it.
2024-11-22 22:35:49 +01:00
Tyler James Leonhardt
5cb3edbfc4 Move env.nativeHandle to window.nativeHandle (#234395) 2024-11-22 06:50:12 +05:30
Tyler James Leonhardt
d7ab35a98e handle: string to nativeHandle: UInt8Array based on feedback (#234378)
Feedback in https://github.com/microsoft/vscode/issues/229431
2024-11-21 11:58:49 -07:00
Tyler James Leonhardt
e5079d8a05 Migrate old accounts to MSAL (#234147)
Bascally, we reach into the old location in secret storage and if we find sessions (with a refresh token) we seed that in the MSAL world.

We do this one time... unless they switch back to the old world and then switch to the new world.

This has two different behaviors depending on if the Broker is used:
* If the broker is not used, this does what you might expect. It makes it seem totally transparent to the user that something has changed. All sessions get migrated over and the user is still logged in to what they were previously.
* If the broker is used... you don't get automatically logged in _unless_ you have already logged in to that account at the OS level. So this helps skip the "VS Code access layer" outlined in `accountAccess.ts`. Not as good as the previous bullet, but this is the best we can do in the broker world.

In time, we can remove this migration along with the old way of doing things.
2024-11-19 00:56:53 +01:00
Tyler James Leonhardt
305134296c Adopt the MSAL broker to talk to the OS for Microsoft auth (#233739)
This adopts the `NativeBrokerPlugin` provided by `@azure/msal-node-extensions` to provide the ability to use auth state from the OS, and show native auth dialogs instead of going to the browser.

This has several pieces:
* The adoption of the broker in the microsoft-authentication extension:
  * Adding `NativeBrokerPlugin` to our PCAs
  * Using the proposed handle API to pass the native window handle down to MSAL calls (btw, this API will change in a follow up PR)
  * Adopting an AccountAccess layer to handle:
    * giving the user control of which accounts VS Code uses
    * an eventing layer so that auth state can be updated across multiple windows
* Getting the extension to build properly and only build what it really needs. This required several package.json/webpack hacks:
  * Use a fake keytar since we don't use the feature in `@azure/msal-node-extensions` that uses keytar
  * Use a fake dpapi layer since we don't use the feature in  `@azure/msal-node-extensions` that uses it
  * Ensure the msal runtime `.node` and `.dll` files are included in the bundle
* Get the VS Code build to allow a native node module in an extension: by having a list of native extensions that will be built in the "ci" part of the build - in other words when VS Code is building on the target platform

There are a couple of followups:
* Refactor the `handle` API to handle (heh) Auxiliary Windows https://github.com/microsoft/vscode/issues/233106
* Separate the call to `acquireTokenSilent` and `acquireTokenInteractive` and all the usage of this native node module into a separate process or maybe in Core... we'll see. Something to experiment with after we have something working. NEEDS FOLLOW UP ISSUE

Fixes https://github.com/microsoft/vscode/issues/229431
2024-11-15 20:53:28 +09:00
Tyler James Leonhardt
4ae34118f2 Reinstate normal loopback flow for Gov clouds (#230541)
I finally managed to make changes to the Gov cloud configurations and we can now use the loopback flow for the Gov clouds.
2024-10-04 22:22:00 +02:00