Commit Graph

41 Commits

Author SHA1 Message Date
Benjamin Pasero
7027856936 sessions - allow callback scheme in auth (#298270) 2026-02-27 15:27:08 +00: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
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
bcbd0b4a98 Remove quick pick flow for protocol handler (#270455)
Remove quick pick flow

Since we have device code flow, that's better.

ref https://github.com/microsoft/vscode/issues/270452
2025-10-08 18:20:16 -07: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
8845fc4b5c Remove any casts in auth extensions (#270089) 2025-10-06 12:28:27 -07:00
Matt Bierner
360c9fd134 Add lint rule for as any and bulk ignore all existing breaks
For #269213

This adds a new eslint rule for `as any` and `<any>({... })`. We'd like to remove almost all of these, however right now the first goal is to prevent them in new code. That's why with this first PR I simply add `eslint-disable` comments for all breaks

Trying to get this change in soon after branching off for release to hopefully minimize disruption during debt week work
2025-10-02 23:38:33 -07:00
Tyler James Leonhardt
54b39dc336 Typo in telemetry (#264041) 2025-08-29 16:50:45 +00:00
Copilot
f14ccecb1e Add support for Entra ID v1.0 authorization servers in VSCode MCP Client (#262603)
* Initial plan

* Add v1.0 Entra ID support and optimize MCP discovery for Microsoft endpoints

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

* Add tests for v1.0 authorization server support

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

* Address code review feedback: remove redundant tests and Microsoft-specific logic

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

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: TylerLeonhardt <2644648+TylerLeonhardt@users.noreply.github.com>
2025-08-29 12:21:53 +02: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
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
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
1c8271a135 Fix telemetry event name (#248557)
rip
2025-05-09 23:00:08 +02: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
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
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
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
691eaea3bd Remove old code, simplify properties (#237512) 2025-01-08 19:11:01 +01: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
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
6bd8e90fb7 Misc fixes for Sovereign Clouds (#228591)
* Misc fixes for Sovereign Clouds

* For now, use the URL handler since the main flow doesn't work right now because the localhost redirect url needs to be in those environments
* Includes the name of the cloud in the PCAs so that we have separation between the auth providers
* extra logging for the URL Handler

* fix tests
2024-09-13 21:57:12 +02:00
Tyler James Leonhardt
db2a1df708 Use an EventBufferer to ensure only one event across PCAs (#228400) 2024-09-13 01:24:41 +02:00
Tyler James Leonhardt
b8be82f239 Workaround MSAL behavior (#228289)
* Workaround MSAL behavior

The main change this makes is around what scopes are being requested.

Due to an MSAL or Identity issue, if you request a resource like `FOO/user_impersonation` and then `email`... the 2nd call does not use Graph and instead uses FOO and FOO may not have an `email` scope available. To work around this, if we detect that all scopes being requested are [OIDC scopes](https://learn.microsoft.com/en-us/entra/identity-platform/scopes-oidc#openid-connect-scopes) then we tack on `User.Read` to make sure that what gets returned is in fact from Graph. This prevents an infinite loop that was happening before. MSAL/Identity should fix this behavior, but this works for now.

Additionally, MSAL does already tack on OIDC scopes to all requests so I removed the logic that adds those.

Couple small things:
* Make sure MSAL logs get logged (trace)
* Use a Sequencer to make sure acquireToken calls are done sequentially just in case.

* more comment
2024-09-12 02:29:29 +02:00
Tyler James Leonhardt
533d8ec6a5 Rework eventing for PCAs and fix a few bugs along the way (#227854)
A big change, but a good one... This addresses some core issues around how we manage multiple PublicClientApplications (which are an object that should be created for each set of clientId,authority). Previously, we were doing some pretty nasty things to detect when a new PCA was created/deleted and as a result it would cause infinite loops and the likes...

Now we've focused on managing that in SecretStorage by looking for a `publicClientApplications` key. This is all encapsulated in the new `PublicClientApplicationsSecretStorage`.

Since we no longer relied on that hack, we still needed some way to have a PCA inform that:
* accounts have changed
* the last account was removed (signaling that this PCA could be disposed of in `PublicClientApplicationsSecretStorage`)

Both of these events have been added to `CachedPublicClientApplication` (now in its own file) and are being used. (replacing the old `_accountChangeHandler` which was hacky... true events are cleaner).

Last thing in the eventing space is that I try to minimize calls to `_storePublicClientApplications` so to not spam events across SecretStorage. You can see this in my usage of `_doCreatePublicClientApplication` over `getOrCreate`.

Couple random other things:
* `changed` accounts are properly bubbled up in `_onDidChangeSessionsEmitter` which is needed when a token is refreshed
* `getSessions` when no scopes are passed in no longer causes new tokens to be minted
* we use to only remove the first account we found but in some cases there may be the same account across different PCAs, so there's a `return` that's removed in `authProvider.ts` that fixes this bug
* Logging is clearer and more verbose (in a good way)
2024-09-06 21:03:25 -07:00
Tyler James Leonhardt
c125b90d41 Add experimentation to Microsoft auth (#226107)
* Add experimentation to Microsoft auth

So that we can gradually roll out MSAL support.

* correct order
2024-08-20 17:17:15 -07:00
Tyler James Leonhardt
b2d6860308 Improve refresh and scope handling (#225832)
* Moves the `setupRefresh` stuff into the CachedPublicClientApp simplifying things a bit
* Uses a ScopeData class to handle all scope operations fixing an issue where we were passing in the wrong array into the `acquireTokenInteractive`
2024-08-17 07:55:33 +02:00
Tyler James Leonhardt
9d49135f49 LoopbackClientAndOpener Tests (#225458)
(first tests in this extension!)
2024-08-12 18:42:44 -07:00
Tyler James Leonhardt
70d27743ac Ability to use MSAL in the Desktop (#225272)
* Ability to use MSAL in the Desktop

* add comment about MSAL workaround
2024-08-09 12:18:34 -07:00
Tyler James Leonhardt
1357fca0f7 Add cancellable promise to Microsoft auth flows (#211495)
Fixes #211406
2024-04-27 01:06:58 +02:00
Tyler James Leonhardt
41e940f76f Use SequencerByKey to sequence operations of the same set of scopes (#192638)
The idea here is... if a token is currently being refreshed, well then getting a token of those scopes should wait for that to finish.

Core has a really nice `SequencerByKey` for exactly this kind of thing, and so I've stolen that and started to organize the code with a `common` folder.

Oh, I also noticed we were sorting twice and fixed that to only sort once.

ref https://github.com/microsoft/vscode/issues/186693
2023-09-09 07:09:20 +02:00