Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed settings sync has duplicate logins #142340

Merged
merged 4 commits into from Feb 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 10 additions & 4 deletions extensions/microsoft-authentication/src/AADHelper.ts
Expand Up @@ -203,6 +203,12 @@ export class AzureActiveDirectoryService {
}

public createSession(scopes: string[]): Promise<vscode.AuthenticationSession> {
if (!scopes.includes('openid')) {
scopes.push('openid');
}
if (!scopes.includes('email')) {
scopes.push('email');
}
const scopeData: IScopeData = {
scopes,
scopeStr: scopes.join(' '),
Expand Down Expand Up @@ -410,14 +416,14 @@ export class AzureActiveDirectoryService {
let claims = undefined;

try {
claims = JSON.parse(Buffer.from(json.access_token.split('.')[1], 'base64').toString());
} catch (e) {
if (json.id_token) {
Logger.info('Attempting to parse id_token instead since access_token was not parsable');
claims = JSON.parse(Buffer.from(json.id_token.split('.')[1], 'base64').toString());
} else {
throw e;
claims = JSON.parse(Buffer.from(json.access_token.split('.')[1], 'base64').toString());
}
} catch (e) {
throw e;
}

return {
Expand All @@ -429,7 +435,7 @@ export class AzureActiveDirectoryService {
scope: scopeData.scopeStr,
sessionId: existingId || `${claims.tid}/${(claims.oid || (claims.altsecid || '' + claims.ipd || ''))}/${uuid()}`,
account: {
label: claims.email || claims.unique_name || claims.preferred_username || 'user@example.com',
label: `${claims.name} - ${claims.email}` || claims.email || claims.unique_name || claims.preferred_username || 'user@example.com',
id: `${claims.tid}/${(claims.oid || (claims.altsecid || '' + claims.ipd || ''))}`
}
};
Expand Down