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

auth: Add changes to be compatible with the new tenant view #1789

Merged
merged 10 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion auth/src/AzureSubscriptionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface AzureSubscriptionProvider {
*
* @returns A list of tenants.
*/
getTenants(session?: vscode.AuthenticationSession): Promise<TenantIdDescription[]>;
getTenants(account?: vscode.AuthenticationSessionAccountInformation): Promise<TenantIdDescription[]>;

/**
* Gets a list of Azure subscriptions available to the user.
Expand Down
8 changes: 4 additions & 4 deletions auth/src/VSCodeAzureSubscriptionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ export class VSCodeAzureSubscriptionProvider extends vscode.Disposable implement
*
* @returns A list of tenants.
*/
public async getTenants(session?: vscode.AuthenticationSession): Promise<TenantIdDescription[]> {
public async getTenants(account?: vscode.AuthenticationSessionAccountInformation): Promise<TenantIdDescription[]> {
const session = await vscode.authentication.getSession(getConfiguredAuthProviderId(), ['https://management.azure.com/.default'], { account: account });
const { client } = await this.getSubscriptionClient(undefined, undefined, session);

const results: TenantIdDescription[] = [];
Expand Down Expand Up @@ -94,8 +95,7 @@ export class VSCodeAzureSubscriptionProvider extends vscode.Disposable implement
// Get the list of tenants from each account
const accounts = await vscode.authentication.getAccounts(getConfiguredAuthProviderId());
for (const account of accounts) {
const session = await vscode.authentication.getSession(getConfiguredAuthProviderId(), ['https://management.azure.com/.default'], { account: account });
for (const tenant of await this.getTenants(session)) {
for (const tenant of await this.getTenants(account)) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const tenantId = tenant.tenantId!;

Expand Down Expand Up @@ -247,7 +247,7 @@ export class VSCodeAzureSubscriptionProvider extends vscode.Disposable implement
const armSubs = await import('@azure/arm-resources-subscriptions');
if (!session) {
if (account) {
session = await getSessionFromVSCode(scopes, tenantId, { createIfNone: false, silent: true, account: account }); //pass in account
session = await getSessionFromVSCode(scopes, tenantId, { createIfNone: false, silent: true, account: account });
} else {
session = await getSessionFromVSCode(scopes, tenantId, { createIfNone: false, silent: true });
}
Expand Down
1 change: 0 additions & 1 deletion auth/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export * from './AzureAuthentication';
export * from './AzureDevOpsSubscriptionProvider';
export * from './AzureSubscription';
export * from './AzureSubscriptionProvider';
export * from './getSessionFromVSCode';
export * from './NotSignedInError';
export * from './signInToTenant';
export * from './utils/configuredAzureEnv';
Expand Down
Loading