Commit Graph

247 Commits

Author SHA1 Message Date
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
846dae676c Fix telemetry event name (#248569)
* Fix telemetry event name

* fix more
2025-05-09 22:28:59 +00:00
Tyler James Leonhardt
1c8271a135 Fix telemetry event name (#248557)
rip
2025-05-09 23:00:08 +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
Robo
12326f9906 chore: update to Electron 35 (#245423)
* chore: bump electron@35.0.1

* chore: update types/node@22.x

* chore: update web types for node v22.x

* chore: bump electron@35.1.2

* chore: update node.js build

* chore: update app.dock usage

Refs 71f3ff6bf2

* chore: bump electron@35.1.4

* chore: bump electron@35.1.5

* ci: bump sysroot to glibc 2.28 and gcc 10.5.0

* ci: enable timeout for smoketests

* chore: bump min glibcxx to 3.4.26 for server

* Revert "ci: enable timeout for smoketests"

This reverts commit afb637e85d.

* chore: update debian dependencies

* fix: workaround npm.ps1 argument parsing with powershell

* chore: update rpm dependencies

* test: partially revert changes from 242535

* test: remove redudant keybinding dispatch for selectTab

* test: fix test failure from running configured tasks

* test: focus settings editor for preferences.test.ts

* node - adopt compile cache (#246835)

* node - adopt compile cache

* adopt for utility process

* tweaks

* log state of compilation cache

* Revert "log state of compilation cache"

This reverts commit f3840387a583013834762e2c44f6e8424929297f.

* Revert "node - adopt compile cache (#246835)"

This reverts commit 673a00cab66c9bac87f3cd27b80efa41c80150f1.

* chore: update builds

* chore: bump electron@35.2.0

* chore: bump electron@35.2.1

* chore: bump electron@35.2.2

---------

Co-authored-by: Benjamin Pasero <benjamin.pasero@microsoft.com>
2025-05-09 19:03:36 +09:00
Tyler James Leonhardt
690d2be258 Clean up some dead code and add a telemetry even to track classic microsoft auth usage (#248256)
So we can see how many people disable MSAL.
2025-05-06 15:36:17 -07:00
Tyler James Leonhardt
445bb01935 Bump @azure/msal-node-runtime to 0.18.2 (#247301) 2025-04-24 12:56:59 +02:00
Tyler James Leonhardt
4293d3771a Revert "Bump msal-runtime (#244321)" (#246336)
This reverts commit bdb7cc4f0c.
2025-04-11 19:52:38 +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
Matt Bierner
4a1dff2d44 Fix never-null error 2025-03-24 16:08:24 -07:00
Matt Bierner
8225b496b1 Updating @types/node
Needs some minor code changes too to support the new typings
2025-03-24 13:02:28 -07:00
Tyler James Leonhardt
bdb7cc4f0c Bump msal-runtime (#244321)
Fixes https://github.com/microsoft/vscode/issues/240307
2025-03-21 20:56:33 -07:00
Tyler James Leonhardt
739de723a5 Fix ScopeData so that tenantId truly is only a GUID (#242929)
Fixes https://github.com/microsoft/vscode/issues/242839
2025-03-07 14:46:25 -08:00
Tyler James Leonhardt
14324bbbc2 Remove old client id versioning code (#242760)
We're not doing this anymore and our default client id will be "upgraded" by the identity team.
2025-03-06 11:56:44 +09: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
4c32889faf Show InputBox for unsupported clients (#239389)
* Show InputBox for unsupported clients

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

* comment

* Add 127.0.0.1 for good measure
2025-02-01 05:26:18 +00:00
Tyler James Leonhardt
a9ce0b5556 Include an ability to change the default client id (#238736)
Include an ability to change the client id

So our migration is easy to test
2025-01-24 16:46:50 -08: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
8eddff6613 Default to MSAL authentication 🚀 (#237920)
Here we go. Ref https://github.com/microsoft/vscode/issues/178740
2025-01-14 21:23:14 +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
Logan Ramos
e689b912ba Update telemetry package (#236378) 2024-12-17 20:12:49 +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
68cd78865a Remove msal-node-extensions workaround (#234456)
We needed this workaround because MSAL was always trying to require a native module we never use.

I sent a PR to MSAL to rework their behavior and that has now been released and we pulled that in in https://github.com/microsoft/vscode/pull/234450

With the updated msal-node-extensions library, we no longer need to do this webpack logic.
2024-11-23 00:39:17 +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
d12854f6ba Default MSAL to true (#234290)
Using new `microsoft-authentication.implementation` setting
2024-11-20 13:15:09 -08: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
b278635434 predictable keytar resolution (#233948)
In a couple of builds [like this one](https://dev.azure.com/monacotools/Monaco/_build/results?buildId=305323&view=results) we have seen bad comparisons of `extension.js` in the Microsoft Auth extension:

> 2024-11-15T19:16:07.080Z electron-universal SHA for file Contents/Resources/app/extensions/microsoft-authentication/dist/extension.js does not match across builds a4db653e84d42a8cb4681a2274dffd34e0d7729cf14c0c4228b668778aa81c18!=6ff1bd8b8b51db2bff1d5f000625f0efe490a92eb282d0559aa904325d6cad68

Which is odd, considering there is no native dependencies used on macOS. The suspicion is that this is because of `keytar` which we have in the package.json using an odd `file:./path...`syntax to prevent it from installing normally since we don't use it.

The solution: additionally alias keytar in the webpack config so that the resolution is predictable.
2024-11-15 21:47:48 +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
Raymond Zhao
fcae80e2df fix: useMsal setting doesn't have tags (#232534) 2024-10-29 15:26:18 -07: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
Robo
9494a89080 chore: add npmrc to extensions folder (#230214) 2024-10-01 12:43:01 +02:00
Tyler James Leonhardt
35183efe58 Revert "Rename MSAL setting" (#230164)
Revert "Rename MSAL setting (#230142)"

This reverts commit 2a677c686b.
2024-09-30 14:38:38 -07:00
Tyler James Leonhardt
2a677c686b Rename MSAL setting (#230142) 2024-09-30 19:25:47 +02:00
Tyler James Leonhardt
eef6488c2c Use select_account prompt when no account is specified (#229778)
Fixes https://github.com/microsoft/vscode/issues/226892
2024-09-25 21:44:09 -07:00
Tyler James Leonhardt
3b1cb3b155 Bring back refresher (#229246)
Now we will refresh tokens over time so extensions can cache auth sessions in memory and just need to listen to the event to decide when to refresh their caches.
2024-09-21 01:26:53 +02:00