mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Remove ADAL Code (#23360)
* initial commit, removed all adal code * remove all authLibrary references in extension/azurecore * removed authLibrary references from src/sql * remove MSAL/ADAL setting option * wip fixing tests and removing Msal from method names * fixed tests * create accountInfo mock * fix tests * fix clientApplication mock * remove clientapplication * fix compile * add typing * wip * wip * wip * fix tree provider * remove SimpleTokenCache, FileDatabase & tests * remove remaining adal / authentication library references: * remove comma from package.nls.json * fix error fetching subscriptions * fix tests * remove getAzureAuthenticationLibraryConfig * remove adal check * fix build * remove test * undo remove customProviderSettings * fix bracket
This commit is contained in:
@@ -17,11 +17,11 @@ import { AzureResourceServiceNames } from './constants';
|
||||
import { AzureAccount, Tenant, azureResource } from 'azurecore';
|
||||
import { FlatTenantTreeNode } from './tree/flatTenantTreeNode';
|
||||
import { ConnectionDialogTreeProvider } from './tree/connectionDialogTreeProvider';
|
||||
import { AzureResourceErrorMessageUtil, filterAccounts } from './utils';
|
||||
import { AzureResourceErrorMessageUtil } from './utils';
|
||||
import { AzureResourceTenantTreeNode } from './tree/tenantTreeNode';
|
||||
import { FlatAccountTreeNode } from './tree/flatAccountTreeNode';
|
||||
|
||||
export function registerAzureResourceCommands(appContext: AppContext, azureViewTree: AzureResourceTreeProvider, connectionDialogTree: ConnectionDialogTreeProvider, authLibrary: string): void {
|
||||
export function registerAzureResourceCommands(appContext: AppContext, azureViewTree: AzureResourceTreeProvider, connectionDialogTree: ConnectionDialogTreeProvider): void {
|
||||
const trees = [azureViewTree, connectionDialogTree];
|
||||
vscode.commands.registerCommand('azure.resource.startterminal', async (node?: TreeNode) => {
|
||||
try {
|
||||
@@ -35,7 +35,7 @@ export function registerAzureResourceCommands(appContext: AppContext, azureViewT
|
||||
if (node instanceof AzureResourceAccountTreeNode) {
|
||||
azureAccount = node.account;
|
||||
} else {
|
||||
let accounts = filterAccounts(await azdata.accounts.getAllAccounts(), authLibrary);
|
||||
let accounts = await azdata.accounts.getAllAccounts();
|
||||
accounts = accounts.filter(a => a.key.providerId.startsWith('azure'));
|
||||
if (accounts.length === 0) {
|
||||
const signin = localize('azure.signIn', "Sign in");
|
||||
|
||||
@@ -13,7 +13,7 @@ import { TreeNode } from '../treeNode';
|
||||
import { AzureResourceAccountNotSignedInTreeNode } from './accountNotSignedInTreeNode';
|
||||
import { AzureResourceMessageTreeNode } from '../messageTreeNode';
|
||||
import { AzureResourceContainerTreeNodeBase } from './baseTreeNodes';
|
||||
import { AzureResourceErrorMessageUtil, equals, filterAccounts } from '../utils';
|
||||
import { AzureResourceErrorMessageUtil, equals } from '../utils';
|
||||
import { IAzureResourceTreeChangeHandler } from './treeChangeHandler';
|
||||
import { Logger } from '../../utils/Logger';
|
||||
import { AzureAccount } from 'azurecore';
|
||||
@@ -26,11 +26,10 @@ export class ConnectionDialogTreeProvider implements vscode.TreeDataProvider<Tre
|
||||
private _onDidChangeTreeData = new vscode.EventEmitter<TreeNode | undefined>();
|
||||
private loadingAccountsPromise: Promise<void> | undefined;
|
||||
|
||||
public constructor(private readonly appContext: AppContext,
|
||||
private readonly authLibrary: string) {
|
||||
public constructor(private readonly appContext: AppContext) {
|
||||
azdata.accounts.onDidChangeAccounts(async (e: azdata.DidChangeAccountsParams) => {
|
||||
// This event sends it per provider, we need to make sure we get all the azure related accounts
|
||||
let accounts = filterAccounts(await azdata.accounts.getAllAccounts(), authLibrary);
|
||||
let accounts = await azdata.accounts.getAllAccounts();
|
||||
accounts = accounts.filter(a => a.key.providerId.startsWith('azure'));
|
||||
// the onDidChangeAccounts event will trigger in many cases where the accounts didn't actually change
|
||||
// the notifyNodeChanged event triggers a refresh which triggers a getChildren which can trigger this callback
|
||||
@@ -56,11 +55,10 @@ export class ConnectionDialogTreeProvider implements vscode.TreeDataProvider<Tre
|
||||
}
|
||||
|
||||
if (this.accounts && this.accounts.length > 0) {
|
||||
let accounts = filterAccounts(this.accounts, this.authLibrary);
|
||||
const accountNodes: FlatAccountTreeNode[] = [];
|
||||
const errorMessages: string[] = [];
|
||||
// We are doing sequential account loading to avoid the Azure request throttling
|
||||
for (const account of accounts) {
|
||||
for (const account of this.accounts) {
|
||||
try {
|
||||
const accountNode = new FlatAccountTreeNode(account, this.appContext, this);
|
||||
accountNode.refreshLabel();
|
||||
@@ -87,7 +85,7 @@ export class ConnectionDialogTreeProvider implements vscode.TreeDataProvider<Tre
|
||||
|
||||
private async loadAccounts(): Promise<void> {
|
||||
try {
|
||||
this.accounts = filterAccounts(await azdata.accounts.getAllAccounts(), this.authLibrary);
|
||||
this.accounts = await azdata.accounts.getAllAccounts();
|
||||
// System has been initialized
|
||||
this.setSystemInitialized();
|
||||
this._onDidChangeTreeData.fire(undefined);
|
||||
|
||||
@@ -14,7 +14,7 @@ import { AzureResourceAccountTreeNode } from './accountTreeNode';
|
||||
import { AzureResourceAccountNotSignedInTreeNode } from './accountNotSignedInTreeNode';
|
||||
import { AzureResourceMessageTreeNode } from '../messageTreeNode';
|
||||
import { AzureResourceContainerTreeNodeBase } from './baseTreeNodes';
|
||||
import { AzureResourceErrorMessageUtil, equals, filterAccounts } from '../utils';
|
||||
import { AzureResourceErrorMessageUtil, equals } from '../utils';
|
||||
import { IAzureResourceTreeChangeHandler } from './treeChangeHandler';
|
||||
import { AzureAccount } from 'azurecore';
|
||||
|
||||
@@ -25,11 +25,10 @@ export class AzureResourceTreeProvider implements vscode.TreeDataProvider<TreeNo
|
||||
private _onDidChangeTreeData = new vscode.EventEmitter<TreeNode | undefined>();
|
||||
private loadingAccountsPromise: Promise<void> | undefined;
|
||||
|
||||
public constructor(private readonly appContext: AppContext,
|
||||
private readonly authLibrary: string) {
|
||||
public constructor(private readonly appContext: AppContext) {
|
||||
azdata.accounts.onDidChangeAccounts(async (e: azdata.DidChangeAccountsParams) => {
|
||||
// This event sends it per provider, we need to make sure we get all the azure related accounts
|
||||
let accounts = filterAccounts(await azdata.accounts.getAllAccounts(), authLibrary);
|
||||
let accounts = await azdata.accounts.getAllAccounts();
|
||||
accounts = accounts.filter(a => a.key.providerId.startsWith('azure'));
|
||||
// the onDidChangeAccounts event will trigger in many cases where the accounts didn't actually change
|
||||
// the notifyNodeChanged event triggers a refresh which triggers a getChildren which can trigger this callback
|
||||
@@ -59,7 +58,6 @@ export class AzureResourceTreeProvider implements vscode.TreeDataProvider<TreeNo
|
||||
if (this.accounts.length === 0) {
|
||||
return [new AzureResourceAccountNotSignedInTreeNode()];
|
||||
} else {
|
||||
this.accounts = filterAccounts(this.accounts, this.authLibrary);
|
||||
return this.accounts.map((account) => new AzureResourceAccountTreeNode(account, this.appContext, this));
|
||||
}
|
||||
} else {
|
||||
@@ -72,10 +70,7 @@ export class AzureResourceTreeProvider implements vscode.TreeDataProvider<TreeNo
|
||||
|
||||
private async loadAccounts(): Promise<void> {
|
||||
try {
|
||||
let accounts = await azdata.accounts.getAllAccounts();
|
||||
if (accounts) {
|
||||
this.accounts = filterAccounts(accounts, this.authLibrary);
|
||||
}
|
||||
this.accounts = await azdata.accounts.getAllAccounts();
|
||||
// System has been initialized
|
||||
this.setSystemInitialized();
|
||||
this._onDidChangeTreeData.fire(undefined);
|
||||
|
||||
@@ -674,18 +674,3 @@ export function getProviderMetadataForAccount(account: AzureAccount): AzureAccou
|
||||
|
||||
return provider.metadata;
|
||||
}
|
||||
|
||||
// Filter accounts based on currently selected Auth Library:
|
||||
// if the account key is present, filter based on current auth library
|
||||
// if there is no account key (pre-MSAL account), then it is an ADAL account and
|
||||
// should be displayed as long as ADAL is the currently selected auth library
|
||||
export function filterAccounts(accounts: azdata.Account[], authLibrary: string): azdata.Account[] {
|
||||
let filteredAccounts = accounts.filter(account => {
|
||||
if (account.key.authLibrary) {
|
||||
return account.key.authLibrary === authLibrary;
|
||||
} else {
|
||||
return authLibrary === Constants.AuthLibrary.ADAL;
|
||||
}
|
||||
});
|
||||
return filteredAccounts;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user