Skip to content

Commit 33659ed

Browse files
author
Rachel Macfarlane
committed
Add codeExchangeProxyEndpoints to web api
1 parent b2d1932 commit 33659ed

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

extensions/microsoft-authentication/src/AADHelper.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,10 @@ export class AzureActiveDirectoryService {
471471
redirect_uri: redirectUrl
472472
});
473473

474-
const result = await fetch(`${loginEndpointUrl}${tenant}/oauth2/v2.0/token`, {
474+
const proxyEndpoints: { [providerId: string]: string } | undefined = await vscode.commands.executeCommand('workbench.getCodeExchangeProxyEndpoints');
475+
const endpoint = proxyEndpoints && proxyEndpoints['microsoft'] || `${loginEndpointUrl}${tenant}/oauth2/v2.0/token`;
476+
477+
const result = await fetch(endpoint, {
475478
method: 'POST',
476479
headers: {
477480
'Content-Type': 'application/x-www-form-urlencoded',

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
1515
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
1616
import { IActivityService, NumberBadge } from 'vs/workbench/services/activity/common/activity';
1717
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
18+
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
1819

1920
export function getAuthenticationProviderActivationEvent(id: string): string { return `onAuthenticationRequest${id}`; }
2021

@@ -70,6 +71,11 @@ export interface SessionRequestInfo {
7071
[scopes: string]: SessionRequest;
7172
}
7273

74+
CommandsRegistry.registerCommand('workbench.getCodeExchangeProxyEndpoints', function (accessor, _) {
75+
const environmentService = accessor.get(IWorkbenchEnvironmentService);
76+
return environmentService.options?.codeExchangeProxyEndpoints;
77+
});
78+
7379
export class AuthenticationService extends Disposable implements IAuthenticationService {
7480
declare readonly _serviceBrand: undefined;
7581
private _placeholderMenuItem: IDisposable | undefined;

src/vs/workbench/workbench.web.api.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,11 @@ interface IWorkbenchConstructionOptions {
345345
*/
346346
readonly driver?: boolean;
347347

348+
/**
349+
* Endpoints to be used for proxying authentication code exchange calls in the browser.
350+
*/
351+
readonly codeExchangeProxyEndpoints?: { [providerId: string]: string }
352+
348353
//#endregion
349354
}
350355

0 commit comments

Comments
 (0)