From d12854f6ba34a313c656ab0e97dd4d00a6087537 Mon Sep 17 00:00:00 2001 From: Tyler James Leonhardt Date: Wed, 20 Nov 2024 13:15:09 -0800 Subject: [PATCH] Default MSAL to true (#234290) Using new `microsoft-authentication.implementation` setting --- extensions/microsoft-authentication/package.json | 15 ++++++++++++--- .../microsoft-authentication/package.nls.json | 4 +++- .../microsoft-authentication/src/extension.ts | 12 ++++++------ 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/extensions/microsoft-authentication/package.json b/extensions/microsoft-authentication/package.json index 0f5b707f18a..6751caa5336 100644 --- a/extensions/microsoft-authentication/package.json +++ b/extensions/microsoft-authentication/package.json @@ -100,9 +100,18 @@ { "title": "Microsoft", "properties": { - "microsoft.useMsal": { - "type": "boolean", - "description": "%useMsal.description%", + "microsoft-authentication.implementation": { + "type": "string", + "default": "msal", + "enum": [ + "msal", + "classic" + ], + "enumDescriptions": [ + "%microsoft-authentication.implementation.enumDescriptions.msal%", + "%microsoft-authentication.implementation.enumDescriptions.classic%" + ], + "description": "%microsoft-authentication.implementation.description%", "tags": [ "onExP", "preview" diff --git a/extensions/microsoft-authentication/package.nls.json b/extensions/microsoft-authentication/package.nls.json index 80cbb32d4ab..dd33d036abc 100644 --- a/extensions/microsoft-authentication/package.nls.json +++ b/extensions/microsoft-authentication/package.nls.json @@ -3,7 +3,9 @@ "description": "Microsoft authentication provider", "signIn": "Sign In", "signOut": "Sign Out", - "useMsal.description": "Use the Microsoft Authentication Library (MSAL) to sign in with a Microsoft account.", + "microsoft-authentication.implementation.description": "The authentication implementation to use for signing in with a Microsoft account.", + "microsoft-authentication.implementation.enumDescriptions.msal": "Use the Microsoft Authentication Library (MSAL) to sign in with a Microsoft account.", + "microsoft-authentication.implementation.enumDescriptions.classic": "Use the classic authentication flow to sign in with a Microsoft account.", "microsoft-sovereign-cloud.environment.description": { "message": "The Sovereign Cloud to use for authentication. If you select `custom`, you must also set the `#microsoft-sovereign-cloud.customEnvironment#` setting.", "comment": [ diff --git a/extensions/microsoft-authentication/src/extension.ts b/extensions/microsoft-authentication/src/extension.ts index 3f9b5d3a4d1..333a183f4b7 100644 --- a/extensions/microsoft-authentication/src/extension.ts +++ b/extensions/microsoft-authentication/src/extension.ts @@ -13,18 +13,18 @@ import Logger from './logger'; function shouldUseMsal(expService: IExperimentationService): boolean { // First check if there is a setting value to allow user to override the default - const inspect = workspace.getConfiguration('microsoft').inspect('useMsal'); + const inspect = workspace.getConfiguration('microsoft-authentication').inspect<'msal' | 'classic'>('implementation'); if (inspect?.workspaceFolderValue !== undefined) { Logger.debug(`Acquired MSAL enablement value from 'workspaceFolderValue'. Value: ${inspect.workspaceFolderValue}`); - return inspect.workspaceFolderValue; + return inspect.workspaceFolderValue === 'msal'; } if (inspect?.workspaceValue !== undefined) { Logger.debug(`Acquired MSAL enablement value from 'workspaceValue'. Value: ${inspect.workspaceValue}`); - return inspect.workspaceValue; + return inspect.workspaceValue === 'msal'; } if (inspect?.globalValue !== undefined) { Logger.debug(`Acquired MSAL enablement value from 'globalValue'. Value: ${inspect.globalValue}`); - return inspect.globalValue; + return inspect.globalValue === 'msal'; } // Then check if the experiment value @@ -36,7 +36,7 @@ function shouldUseMsal(expService: IExperimentationService): boolean { Logger.debug('Acquired MSAL enablement value from default. Value: false'); // If no setting or experiment value is found, default to false - return false; + return true; } let useMsal: boolean | undefined; @@ -50,7 +50,7 @@ export async function activate(context: ExtensionContext) { useMsal = shouldUseMsal(expService); context.subscriptions.push(workspace.onDidChangeConfiguration(async e => { - if (!e.affectsConfiguration('microsoft.useMsal') || useMsal === shouldUseMsal(expService)) { + if (!e.affectsConfiguration('microsoft-authentication.implementation') || useMsal === shouldUseMsal(expService)) { return; }