Skip to content

Commit b129227

Browse files
move to APPLICATION for all auth usages (microsoft#153381)
move to APPLICATION for all auth since auth is really done machine wide. ref microsoft#152679
1 parent 0a3ca02 commit b129227

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/vs/workbench/api/browser/mainThreadAuthentication.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export class MainThreadAuthenticationProvider extends Disposable implements IAut
7070
quickPick.onDidAccept(() => {
7171
const updatedAllowedList = quickPick.items
7272
.map(i => (i as TrustedExtensionsQuickPickItem).extension);
73-
this.storageService.store(`${this.id}-${accountName}`, JSON.stringify(updatedAllowedList), StorageScope.PROFILE, StorageTarget.USER);
73+
this.storageService.store(`${this.id}-${accountName}`, JSON.stringify(updatedAllowedList), StorageScope.APPLICATION, StorageTarget.USER);
7474

7575
quickPick.dispose();
7676
});
@@ -116,7 +116,7 @@ export class MainThreadAuthenticationProvider extends Disposable implements IAut
116116
const removeSessionPromises = sessions.map(session => this.removeSession(session.id));
117117
await Promise.all(removeSessionPromises);
118118
removeAccountUsage(this.storageService, this.id, accountName);
119-
this.storageService.remove(`${this.id}-${accountName}`, StorageScope.PROFILE);
119+
this.storageService.remove(`${this.id}-${accountName}`, StorageScope.APPLICATION);
120120
}
121121
}
122122

@@ -201,7 +201,7 @@ export class MainThreadAuthentication extends Disposable implements MainThreadAu
201201

202202
private async setTrustedExtensionAndAccountPreference(providerId: string, accountName: string, extensionId: string, extensionName: string, sessionId: string): Promise<void> {
203203
this.authenticationService.updatedAllowedExtension(providerId, accountName, extensionId, extensionName, true);
204-
this.storageService.store(`${extensionName}-${providerId}`, sessionId, StorageScope.PROFILE, StorageTarget.MACHINE);
204+
this.storageService.store(`${extensionName}-${providerId}`, sessionId, StorageScope.APPLICATION, StorageTarget.MACHINE);
205205

206206
}
207207

@@ -224,9 +224,9 @@ export class MainThreadAuthentication extends Disposable implements MainThreadAu
224224
if (!options.forceNewSession && sessions.length) {
225225
if (supportsMultipleAccounts) {
226226
if (options.clearSessionPreference) {
227-
this.storageService.remove(`${extensionName}-${providerId}`, StorageScope.PROFILE);
227+
this.storageService.remove(`${extensionName}-${providerId}`, StorageScope.APPLICATION);
228228
} else {
229-
const existingSessionPreference = this.storageService.get(`${extensionName}-${providerId}`, StorageScope.PROFILE);
229+
const existingSessionPreference = this.storageService.get(`${extensionName}-${providerId}`, StorageScope.APPLICATION);
230230
if (existingSessionPreference) {
231231
const matchingSession = sessions.find(session => session.id === existingSessionPreference);
232232
if (matchingSession && this.authenticationService.isAccessAllowed(providerId, matchingSession.account.label, extensionId)) {

src/vs/workbench/services/authentication/browser/authenticationService.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const FIRST_PARTY_ALLOWED_EXTENSIONS = [
4747

4848
export function readAccountUsages(storageService: IStorageService, providerId: string, accountName: string,): IAccountUsage[] {
4949
const accountKey = `${providerId}-${accountName}-usages`;
50-
const storedUsages = storageService.get(accountKey, StorageScope.PROFILE);
50+
const storedUsages = storageService.get(accountKey, StorageScope.APPLICATION);
5151
let usages: IAccountUsage[] = [];
5252
if (storedUsages) {
5353
try {
@@ -62,7 +62,7 @@ export function readAccountUsages(storageService: IStorageService, providerId: s
6262

6363
export function removeAccountUsage(storageService: IStorageService, providerId: string, accountName: string): void {
6464
const accountKey = `${providerId}-${accountName}-usages`;
65-
storageService.remove(accountKey, StorageScope.PROFILE);
65+
storageService.remove(accountKey, StorageScope.APPLICATION);
6666
}
6767

6868
export function addAccountUsage(storageService: IStorageService, providerId: string, accountName: string, extensionId: string, extensionName: string) {
@@ -84,7 +84,7 @@ export function addAccountUsage(storageService: IStorageService, providerId: str
8484
});
8585
}
8686

87-
storageService.store(accountKey, JSON.stringify(usages), StorageScope.PROFILE, StorageTarget.MACHINE);
87+
storageService.store(accountKey, JSON.stringify(usages), StorageScope.APPLICATION, StorageTarget.MACHINE);
8888
}
8989

9090
export type AuthenticationSessionInfo = { readonly id: string; readonly accessToken: string; readonly providerId: string; readonly canSignOut?: boolean };
@@ -112,7 +112,7 @@ export interface AllowedExtension {
112112
export function readAllowedExtensions(storageService: IStorageService, providerId: string, accountName: string): AllowedExtension[] {
113113
let trustedExtensions: AllowedExtension[] = [];
114114
try {
115-
const trustedExtensionSrc = storageService.get(`${providerId}-${accountName}`, StorageScope.PROFILE);
115+
const trustedExtensionSrc = storageService.get(`${providerId}-${accountName}`, StorageScope.APPLICATION);
116116
if (trustedExtensionSrc) {
117117
trustedExtensions = JSON.parse(trustedExtensionSrc);
118118
}
@@ -410,7 +410,7 @@ export class AuthenticationService extends Disposable implements IAuthentication
410410
allowList[index].allowed = isAllowed;
411411
}
412412

413-
await this.storageService.store(`${providerId}-${accountName}`, JSON.stringify(allowList), StorageScope.PROFILE, StorageTarget.USER);
413+
await this.storageService.store(`${providerId}-${accountName}`, JSON.stringify(allowList), StorageScope.APPLICATION, StorageTarget.USER);
414414
}
415415

416416
async showGetSessionPrompt(providerId: string, accountName: string, extensionId: string, extensionName: string): Promise<boolean> {
@@ -475,7 +475,7 @@ export class AuthenticationService extends Disposable implements IAuthentication
475475
this.updatedAllowedExtension(providerId, accountName, extensionId, extensionName, true);
476476

477477
this.removeAccessRequest(providerId, extensionId);
478-
this.storageService.store(`${extensionName}-${providerId}`, session.id, StorageScope.PROFILE, StorageTarget.MACHINE);
478+
this.storageService.store(`${extensionName}-${providerId}`, session.id, StorageScope.APPLICATION, StorageTarget.MACHINE);
479479

480480
quickPick.dispose();
481481
resolve(session);
@@ -615,7 +615,7 @@ export class AuthenticationService extends Disposable implements IAuthentication
615615
this.updatedAllowedExtension(providerId, session.account.label, extensionId, extensionName, true);
616616

617617
// And also set it as the preferred account for the extension
618-
storageService.store(`${extensionName}-${providerId}`, session.id, StorageScope.PROFILE, StorageTarget.MACHINE);
618+
storageService.store(`${extensionName}-${providerId}`, session.id, StorageScope.APPLICATION, StorageTarget.MACHINE);
619619
}
620620
});
621621

0 commit comments

Comments
 (0)