105 Commits

Author SHA1 Message Date
Tyler James Leonhardt
d5c2817e69
Use email for label & use label to group results in Account menu (#193727)
So, when you make a new session in the Microsoft Identity stack, depending on the scopes you pass in you might get:
* A token with a name & email
* A token with just a name
Additionally, Microsoft has like 3-4 concepts of essentially an "id" but depending on what you're trying to access, you might get a different value.

This historical behavior leads to 2 awkward things:
1. The account menu shows two accounts, one with name & email, one with just email.
2. The account menu shows two of the same accounts, but their underlying id is different

So, to fix this, we're just gonna lean on the labels. In other words, if there are two accounts that share the same label, then they will be grouped together.

The previous behavior was hurting the Azure Account folks and the Q# folks and with this change, I believe they both should be happy.

Interestingly enough, when I inherited this code, it use to do this, but I changed it to use the id as that seemed "more correct"... so it a way, this is reverting a change I did a while back.

Fixes https://github.com/microsoft/vscode/issues/184218
2023-09-21 14:09:25 -07:00
Matt Bierner
2c52e4ca35
Alias Thenable to PromiseLike (#192456)
Fixes #192385

This fixes some typing issues with `Thenable` that were hiding potential bugs
2023-09-13 10:50:40 -07:00
Tyler James Leonhardt
379d31d162
Invoke session change emitter when session is created in getSession (#192828)
fixes https://github.com/microsoft/vscode/issues/192806
2023-09-12 09:13:33 -07: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
Tyler James Leonhardt
52f27e2e2f
Log a lot more of the Microsoft Auth extension (#192629)
This PR adds a ton more logging, a consistant format, and fixes the log levels of some.

Additionally, there are two small fixes that I have included:
* we were firing the `_sessionChangeEmitter` twice when a session was removed
* when processing updates from other windows, we returned instead of continued... thus were only processing the first account that was added in another window
2023-09-08 23:25:25 +02:00
Tyler James Leonhardt
9fbd538cb3
Revert back to 2/3rds (#192502)
It was higher for debugging purposes.
2023-09-08 02:23:16 +02:00
Tyler James Leonhardt
53d03d0742
Implement a "pending store" and only actually store the last one (#192488)
ref https://github.com/microsoft/vscode/issues/186693
2023-09-07 14:32:15 -07:00
Tyler James Leonhardt
cb38b1b567
Fire event when using non-localserver flow (#189493)
Fixes https://github.com/microsoft/vscode/issues/186558
2023-08-02 11:26:09 -07:00
Tyler James Leonhardt
dd2441f7ba
Polish Sovereign Cloud support (#184634)
* Use `@azure/ms-rest-azure-env` as official reference of endpoints
* Allow better configuration of custom clouds (these are new so it is ok to change the settings without migration)

Also clean up:

* querystring -> URLSearchParams (getting rid of a package dependency in the web)
* handle `workbench.getCodeExchangeProxyEndpoints` in one place
2023-06-08 12:39:29 -07:00
Benjamin Pasero
3a69e153f6
quick access - allow a Promise<FastAndSlowPicks<T>> and adopt for commands (#180664)
* quick access - allow a `Promise<FastAndSlowPicks<T>>` and adopt for commands

* fix telemetry
2023-04-24 06:41:25 +02:00
Tyler James Leonhardt
bede6ba243
Instrument Microsoft account type (#180573)
So we can see if folks are using MSA or AAD accounts. Also, this cleans up some dead code.

Fixes https://github.com/microsoft/vscode-internalbacklog/issues/3903
2023-04-21 14:23:34 -07:00
Tyler James Leonhardt
3a02bc9de1
Updates from the rename (#179901)
* Updates from the rename

Azure Cloud -> Microsoft Sovereign Cloud

* remove azure once more
2023-04-13 13:01:13 -07:00
Tyler James Leonhardt
b0d7acec38
Logger per auth provider (#179896)
So that we can have an output channel for each.
2023-04-13 19:26:36 +01:00
Brandon Waterloo [MSFT]
f9d14d68fb
Support sovereign/custom clouds in microsoft authentication provider (#178725) 2023-04-07 16:38:38 -07:00
Tyler James Leonhardt
71f619cbda
Ensure the original scopes requested are the scopes in the Session returned (#174645)
Fixes #174631
Fixes #167791
2023-02-17 03:34:39 +01:00
Tyler James Leonhardt
7fc1f6aacb
use better mechanism for base64 decoding with unicode characters (#172445)
Fixes #172441
2023-01-25 21:32:00 +01:00
Tyler James Leonhardt
dcb358a79f
Remove console.log (#171563)
This was for debugging. If it was legit I would have used the logger that's available.
2023-01-18 12:13:23 +11:00
Matt Bierner
c390a331c5
Switch to standard imports (#169451) 2022-12-17 00:22:53 +01:00
Tyler James Leonhardt
461b3f6184
Only have a single window store the session (#169356)
Before this change, every single window was writing to the same secret at basically the same time because they would all refresh the token and then attempt to store that refresh token.

I believe this was causing a few race condition bugs that users were seeing.

With this change we now so our best to have only 1 window store the session by relying on the window focused state.

If the window is focused or becomes focused, we will store the refresh token.

If the window detects that another window has stored something, we will not attempt to wait for focus to store something.

If nothing has happened, and it's been 5 hrs (+/- some seconds) go ahead and store it. This is the scenario of when a user has VS Code in the background for like ages but never goes to it.

ref #165115
ref #130893
ref #168485
2022-12-16 06:58:32 +01:00
Tyler James Leonhardt
ef415578d1
Take advantage of platform features in Microsoft Authentication extension (#166066) 2022-11-10 18:26:48 -08:00
Logan Ramos
bf1697d98c
Consume proposed telemetry API (#165862)
* Consume proposed telemetry API

* Update webpack
2022-11-08 21:58:28 -05:00
Tyler James Leonhardt
6684350a58
Onboard GitHub & Microsoft auth extensions to l10n (#163662)
* onboard github-auth completely to l10n

* onboard microsoft-authentication entirely on to l10n
2022-10-14 08:41:21 -07:00
Sandeep Somavarapu
35c7ee9d02
Support log output channels for extensions (#161249)
* introduce log api in extension context

* separate registering output vs log channel

* Separate extension log channels in show logs command

* add logging error to embedder logger

* show extension log in the extension editor

* configure log level per extension

* change the order of log entries

* introduce logger

* align with output chanel

* revert changes

* fixes
2022-09-19 09:03:41 -07:00
Tyler James Leonhardt
dc9336c303
make sure we add offline_access when creating sessions (#159116) 2022-08-25 08:48:01 -04:00
ChaseKnowlden
19d0675506
Add offline_access to list of default scopes (#157453)
Add a new scope to default scopes
2022-08-08 14:55:13 -07:00
Tyler James Leonhardt
d859b334cb
We only need to wait on the input box for un-supported environments (#157157)
we only need to wait on the input box for un-supported environments
2022-08-04 23:55:51 +02:00
Tyler James Leonhardt
4017fd126f
Show quick pick when redirect fails to complete redirect to be more robust (#156515)
* show quick pick when redirect fails to complete redirect to be more robust

* matt feedback
2022-07-28 10:26:18 -07:00
Johannes
0656d21d11
auto-fixed prefer-const violation 2022-06-08 17:49:21 +02:00
Tyler James Leonhardt
847629239b
add owner and comment to some telemetry events (#148752) 2022-05-05 17:30:51 -04:00
Tyler Leonhardt
9c15f4185a
add favicon and nonce enforcement in microsoft auth 2022-04-15 15:47:20 -07:00
Tyler Leonhardt
52a394bdea
Introduce removeSessionByIToken to remove sessions that aren't in this._tokens yet. Fixes #145189 2022-04-14 15:21:54 -07:00
Tyler Leonhardt
5919378269
don't surface error on gets and remove microsoft secret migration. Fixes #146553 2022-04-14 12:18:33 -07:00
Tyler Leonhardt
39c6779828
depend on stable vscode.dev for auth extensions 2022-03-21 09:35:34 -07:00
Tyler Leonhardt
f728c9289e
use global URLSearchParams 2022-03-18 14:52:18 -07:00
Tyler James Leonhardt
00888f774d
depend on redirect route within Microsoft auth (#145263)
* depend on redirect service

* better server query parameter handling
2022-03-16 13:41:44 -07:00
Tyler Leonhardt
739dfea8e6
try to use an existing refresh token to get a token with the specified scopes. Fixes #114003 2022-03-03 14:54:48 -08:00
Tyler Leonhardt
a0da9978b1
include profile for specific claims in idtoken. Fixes #143463 2022-02-20 16:58:07 -08:00
Tyler Leonhardt
ae8bacb9d3
ensure getSessions also asks for email and openid scopes and fix #142776 2022-02-17 10:27:36 -08:00
Tyler Leonhardt
6a01cda605
use 127.0.0.1 instead of localhost 2022-02-08 15:39:34 -08:00
Yash Goel
5ea92ff535
fixed settings sync has duplicate logins (#142340)
* added check and swaped logic

* improved label for usename

* fixed eslint issues

* updated text
2022-02-08 12:14:52 -08:00
Tyler Leonhardt
e485dc292f
improve logic around auth server 2022-02-06 14:56:22 -08:00
Tyler Leonhardt
eb295e4195
enable migration parts 2022-02-03 14:50:48 -08:00
Johannes Rieken
4a130c40ed
enable @typescript-eslint/member-delimiter-style, https://github.com/microsoft/vscode/issues/140391 2022-02-02 14:35:33 +01:00
Tyler Leonhardt
f498b374c0
large refactor including new secret storage wrapper and overall code clean up and organization 2022-02-01 18:14:31 -08:00
Tyler Leonhardt
9403de257a
proposed api for an idToken on AuthenticationSession. ref #140929 2022-01-24 20:02:31 -08:00
Logan Ramos
c047af40b2
Fix compilation 2022-01-19 16:18:14 -05:00
Tyler Leonhardt
12902bc7a1
allow overridding of client id and tenant for microsoft auth 2022-01-14 14:36:34 -08:00
Matt Bierner
e7b3724e0c
Enable no-case-declarations in codebase (#139243)
Fixes #139236

This can catch tricky programming mistakes that cause a runtime error. See 7e266b2c427222011a66486b2d7ac3e4a9953f11 as an example of the type of bug this can prevent
2021-12-15 17:15:35 -08:00
Tyler Leonhardt
53e8f2c26e
handle 4XX errors differently from others 2021-11-22 16:20:47 -08:00
Tyler Leonhardt
33a6ac6639
simplify polling when getting a network error 2021-11-22 15:28:13 -08:00