* Avoid conflicting scopes and commandIds in quiet logins from Accounts (fix #137601) * revert from scopesJSON to scopesList but use space as separator * define SCOPESLIST_SEPARATOR and use it consistently * simplify diff
This commit is contained in:
parent
00e466b4b9
commit
5128d2c32c
|
@ -163,13 +163,16 @@ export function readAllowedExtensions(storageService: IStorageService, providerI
|
|||
return trustedExtensions;
|
||||
}
|
||||
|
||||
export interface SessionRequest {
|
||||
// OAuth2 spec prohibits space in a scope, so use that to join them.
|
||||
const SCOPESLIST_SEPARATOR = ' ';
|
||||
|
||||
interface SessionRequest {
|
||||
disposables: IDisposable[];
|
||||
requestingExtensionIds: string[];
|
||||
}
|
||||
|
||||
export interface SessionRequestInfo {
|
||||
[scopes: string]: SessionRequest;
|
||||
interface SessionRequestInfo {
|
||||
[scopesList: string]: SessionRequest;
|
||||
}
|
||||
|
||||
CommandsRegistry.registerCommand('workbench.getCodeExchangeProxyEndpoints', function (accessor, _) {
|
||||
|
@ -347,7 +350,7 @@ export class AuthenticationService extends Disposable implements IAuthentication
|
|||
}
|
||||
|
||||
Object.keys(existingRequestsForProvider).forEach(requestedScopes => {
|
||||
if (addedSessions.some(session => session.scopes.slice().join('') === requestedScopes)) {
|
||||
if (addedSessions.some(session => session.scopes.slice().join(SCOPESLIST_SEPARATOR) === requestedScopes)) {
|
||||
const sessionRequest = existingRequestsForProvider[requestedScopes];
|
||||
sessionRequest?.disposables.forEach(item => item.dispose());
|
||||
|
||||
|
@ -613,7 +616,7 @@ export class AuthenticationService extends Disposable implements IAuthentication
|
|||
|
||||
if (provider) {
|
||||
const providerRequests = this._signInRequestItems.get(providerId);
|
||||
const scopesList = scopes.join('');
|
||||
const scopesList = scopes.join(SCOPESLIST_SEPARATOR);
|
||||
const extensionHasExistingRequest = providerRequests
|
||||
&& providerRequests[scopesList]
|
||||
&& providerRequests[scopesList].requestingExtensionIds.includes(extensionId);
|
||||
|
@ -622,10 +625,12 @@ export class AuthenticationService extends Disposable implements IAuthentication
|
|||
return;
|
||||
}
|
||||
|
||||
// Construct a commandId that won't clash with others generated here, nor likely with an extension's command
|
||||
const commandId = `${providerId}:${extensionId}:signIn${Object.keys(providerRequests || []).length}`;
|
||||
const menuItem = MenuRegistry.appendMenuItem(MenuId.AccountsContext, {
|
||||
group: '2_signInRequests',
|
||||
command: {
|
||||
id: `${extensionId}signIn`,
|
||||
id: commandId,
|
||||
title: nls.localize({
|
||||
key: 'signInRequest',
|
||||
comment: [`The placeholder {0} will be replaced with an authentication provider's label. {1} will be replaced with an extension name. (1) is to indicate that this menu item contributes to a badge count.`]
|
||||
|
@ -637,7 +642,7 @@ export class AuthenticationService extends Disposable implements IAuthentication
|
|||
});
|
||||
|
||||
const signInCommand = CommandsRegistry.registerCommand({
|
||||
id: `${extensionId}signIn`,
|
||||
id: commandId,
|
||||
handler: async (accessor) => {
|
||||
const authenticationService = accessor.get(IAuthenticationService);
|
||||
const storageService = accessor.get(IStorageService);
|
||||
|
|
Loading…
Reference in a new issue