mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-08 09:38:26 -05:00
Add MSAL Authentication Library support (#21024)
This commit is contained in:
@@ -26,6 +26,7 @@ import { ILayoutService } from 'vs/platform/layout/browser/layoutService';
|
||||
import { ConnectionWidget } from 'sql/workbench/services/connection/browser/connectionWidget';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { IErrorMessageService } from 'sql/platform/errorMessage/common/errorMessageService';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
|
||||
/**
|
||||
* Connection Widget clas for CMS Connections
|
||||
@@ -47,8 +48,9 @@ export class CmsConnectionWidget extends ConnectionWidget {
|
||||
@IAccountManagementService _accountManagementService: IAccountManagementService,
|
||||
@ILogService _logService: ILogService,
|
||||
@IErrorMessageService _errorMessageService: IErrorMessageService,
|
||||
@IConfigurationService configurationService: IConfigurationService
|
||||
) {
|
||||
super(options, callbacks, providerName, _themeService, _contextViewService, _connectionManagementService, _accountManagementService, _logService, _errorMessageService);
|
||||
super(options, callbacks, providerName, _themeService, _contextViewService, _connectionManagementService, _accountManagementService, _logService, _errorMessageService, configurationService);
|
||||
let authTypeOption = this._optionsMaps[ConnectionOptionSpecialType.authType];
|
||||
if (authTypeOption) {
|
||||
let authTypeDefault = this.getAuthTypeDefault(authTypeOption, OS);
|
||||
|
||||
@@ -27,7 +27,6 @@ import { AzureResource, ConnectionOptionSpecialType } from 'sql/workbench/api/co
|
||||
import { IAccountManagementService } from 'sql/platform/accounts/common/interfaces';
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
|
||||
import * as nls from 'vs/nls';
|
||||
import * as errors from 'vs/base/common/errors';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
|
||||
@@ -36,6 +36,8 @@ import Severity from 'vs/base/common/severity';
|
||||
import { ConnectionStringOptions } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||
import { isFalsyOrWhitespace } from 'vs/base/common/strings';
|
||||
import { AuthenticationType } from 'sql/platform/connection/common/constants';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { AuthLibrary, filterAccounts } from 'sql/workbench/services/accountManagement/browser/accountDialog';
|
||||
|
||||
const ConnectionStringText = localize('connectionWidget.connectionString', "Connection string");
|
||||
|
||||
@@ -107,6 +109,7 @@ export class ConnectionWidget extends lifecycle.Disposable {
|
||||
color: undefined,
|
||||
description: undefined,
|
||||
};
|
||||
private readonly configurationService: IConfigurationService;
|
||||
constructor(options: azdata.ConnectionOption[],
|
||||
callbacks: IConnectionComponentCallbacks,
|
||||
providerName: string,
|
||||
@@ -115,7 +118,8 @@ export class ConnectionWidget extends lifecycle.Disposable {
|
||||
@IConnectionManagementService private _connectionManagementService: IConnectionManagementService,
|
||||
@IAccountManagementService private _accountManagementService: IAccountManagementService,
|
||||
@ILogService protected _logService: ILogService,
|
||||
@IErrorMessageService private _errorMessageService: IErrorMessageService
|
||||
@IErrorMessageService private _errorMessageService: IErrorMessageService,
|
||||
@IConfigurationService configurationService: IConfigurationService
|
||||
) {
|
||||
super();
|
||||
this._callbacks = callbacks;
|
||||
@@ -135,6 +139,7 @@ export class ConnectionWidget extends lifecycle.Disposable {
|
||||
}
|
||||
this._providerName = providerName;
|
||||
this._connectionStringOptions = this._connectionManagementService.getProviderProperties(this._providerName).connectionStringOptions;
|
||||
this.configurationService = configurationService;
|
||||
}
|
||||
|
||||
protected getAuthTypeDefault(option: azdata.ConnectionOption, os: OperatingSystem): string {
|
||||
@@ -591,7 +596,12 @@ export class ConnectionWidget extends lifecycle.Disposable {
|
||||
private async fillInAzureAccountOptions(): Promise<void> {
|
||||
let oldSelection = this._azureAccountDropdown.value;
|
||||
const accounts = await this._accountManagementService.getAccounts();
|
||||
this._azureAccountList = accounts.filter(a => a.key.providerId.startsWith('azure'));
|
||||
const updatedAccounts = accounts.filter(a => a.key.providerId.startsWith('azure'));
|
||||
const authLibrary: AuthLibrary = this.configurationService.getValue('azure.authenticationLibrary');
|
||||
if (authLibrary) {
|
||||
this._azureAccountList = filterAccounts(updatedAccounts, authLibrary);
|
||||
}
|
||||
|
||||
let accountDropdownOptions: SelectOptionItemSQL[] = this._azureAccountList.map(account => {
|
||||
return {
|
||||
text: account.displayInfo.displayName,
|
||||
|
||||
Reference in New Issue
Block a user