mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-22 09:35:37 -05:00
Add AuthenticationType enum to typings (#20699)
* Add AuthenticationType enum to typings * fix * const * Add comments * fix comment * remove unused
This commit is contained in:
@@ -23,7 +23,7 @@ import * as DOM from 'vs/base/browser/dom';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { OS, OperatingSystem } from 'vs/base/common/platform';
|
||||
import { ILayoutService } from 'vs/platform/layout/browser/layoutService';
|
||||
import { ConnectionWidget, AuthenticationType } from 'sql/workbench/services/connection/browser/connectionWidget';
|
||||
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';
|
||||
|
||||
@@ -33,8 +33,8 @@ import { IErrorMessageService } from 'sql/platform/errorMessage/common/errorMess
|
||||
export class CmsConnectionWidget extends ConnectionWidget {
|
||||
|
||||
private _serverDescriptionInputBox: InputBox;
|
||||
protected _authTypeMap: { [providerName: string]: AuthenticationType[] } = {
|
||||
[Constants.cmsProviderName]: [AuthenticationType.SqlLogin, AuthenticationType.Integrated]
|
||||
protected _authTypeMap: { [providerName: string]: Constants.AuthenticationType[] } = {
|
||||
[Constants.cmsProviderName]: [Constants.AuthenticationType.SqlLogin, Constants.AuthenticationType.Integrated]
|
||||
};
|
||||
|
||||
constructor(options: azdata.ConnectionOption[],
|
||||
@@ -92,17 +92,17 @@ export class CmsConnectionWidget extends ConnectionWidget {
|
||||
// True when opening a CMS dialog to add a registered server
|
||||
if (authTypeChanged) {
|
||||
// Registered Servers only support Integrated Auth
|
||||
newAuthTypes = authTypeOption.categoryValues.filter((option) => option.name === AuthenticationType.Integrated);
|
||||
newAuthTypes = authTypeOption.categoryValues.filter((option) => option.name === Constants.AuthenticationType.Integrated);
|
||||
this._authTypeSelectBox.setOptions(newAuthTypes.map(c => c.displayName));
|
||||
authTypeOption.defaultValue = AuthenticationType.Integrated;
|
||||
authTypeOption.defaultValue = Constants.AuthenticationType.Integrated;
|
||||
} else {
|
||||
// CMS supports all auth types
|
||||
newAuthTypes = authTypeOption.categoryValues;
|
||||
this._authTypeSelectBox.setOptions(newAuthTypes.map(c => c.displayName));
|
||||
if (OS === OperatingSystem.Windows) {
|
||||
authTypeOption.defaultValue = this.getAuthTypeDisplayName(AuthenticationType.Integrated);
|
||||
authTypeOption.defaultValue = this.getAuthTypeDisplayName(Constants.AuthenticationType.Integrated);
|
||||
} else {
|
||||
authTypeOption.defaultValue = this.getAuthTypeDisplayName(AuthenticationType.SqlLogin);
|
||||
authTypeOption.defaultValue = this.getAuthTypeDisplayName(Constants.AuthenticationType.SqlLogin);
|
||||
}
|
||||
}
|
||||
this._authTypeSelectBox.selectWithOptionName(authTypeOption.defaultValue);
|
||||
|
||||
@@ -158,7 +158,7 @@ export class ConnectionDialogService implements IConnectionDialogService {
|
||||
defaultAuthenticationType = WorkbenchUtils.getSqlConfigValue<string>(this._configurationService, Constants.defaultAuthenticationType);
|
||||
}
|
||||
|
||||
return defaultAuthenticationType || Constants.sqlLogin; // as a fallback, default to sql login if the value from settings is not available
|
||||
return defaultAuthenticationType || Constants.AuthenticationType.SqlLogin; // as a fallback, default to sql login if the value from settings is not available
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -865,9 +865,9 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
||||
* @param connection The connection to fill in or update
|
||||
*/
|
||||
private async fillInOrClearToken(connection: interfaces.IConnectionProfile): Promise<boolean> {
|
||||
if (connection.authenticationType !== Constants.azureMFA
|
||||
&& connection.authenticationType !== Constants.azureMFAAndUser
|
||||
&& connection.authenticationType !== Constants.dstsAuth) {
|
||||
if (connection.authenticationType !== Constants.AuthenticationType.AzureMFA
|
||||
&& connection.authenticationType !== Constants.AuthenticationType.AzureMFAAndUser
|
||||
&& connection.authenticationType !== Constants.AuthenticationType.DSTSAuth) {
|
||||
connection.options['azureAccountToken'] = undefined;
|
||||
return true;
|
||||
}
|
||||
@@ -875,7 +875,7 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
||||
let azureResource = this.getAzureResourceForConnection(connection);
|
||||
const accounts = await this._accountManagementService.getAccounts();
|
||||
|
||||
if (connection.authenticationType === Constants.dstsAuth) {
|
||||
if (connection.authenticationType === Constants.AuthenticationType.DSTSAuth) {
|
||||
let dstsAccounts = accounts.filter(a => a.key.providerId.startsWith('dstsAuth'));
|
||||
if (dstsAccounts.length <= 0) {
|
||||
connection.options['azureAccountToken'] = undefined;
|
||||
@@ -894,7 +894,7 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
||||
|
||||
const azureAccounts = accounts.filter(a => a.key.providerId.startsWith('azure'));
|
||||
if (azureAccounts && azureAccounts.length > 0) {
|
||||
let accountId = (connection.authenticationType === Constants.azureMFA || connection.authenticationType === Constants.azureMFAAndUser) ? connection.azureAccount : connection.userName;
|
||||
let accountId = (connection.authenticationType === Constants.AuthenticationType.AzureMFA || connection.authenticationType === Constants.AuthenticationType.AzureMFAAndUser) ? connection.azureAccount : connection.userName;
|
||||
let account = azureAccounts.find(account => account.key.accountId === accountId);
|
||||
if (account) {
|
||||
this._logService.debug(`Getting security token for Azure account ${account.key.accountId}`);
|
||||
|
||||
@@ -35,15 +35,7 @@ import { IErrorMessageService } from 'sql/platform/errorMessage/common/errorMess
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import { ConnectionStringOptions } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||
import { isFalsyOrWhitespace } from 'vs/base/common/strings';
|
||||
|
||||
export enum AuthenticationType {
|
||||
SqlLogin = 'SqlLogin',
|
||||
Integrated = 'Integrated',
|
||||
AzureMFA = 'AzureMFA',
|
||||
AzureMFAAndUser = 'AzureMFAAndUser',
|
||||
dSTSAuth = 'dstsAuth',
|
||||
None = 'None' // Kusto supports no authentication
|
||||
}
|
||||
import { AuthenticationType } from 'sql/platform/connection/common/constants';
|
||||
|
||||
const ConnectionStringText = localize('connectionWidget.connectionString', "Connection string");
|
||||
|
||||
@@ -83,7 +75,7 @@ export class ConnectionWidget extends lifecycle.Disposable {
|
||||
protected _databaseNameInputBox: Dropdown;
|
||||
protected _advancedButton: Button;
|
||||
private static readonly _authTypes: AuthenticationType[] =
|
||||
[AuthenticationType.AzureMFA, AuthenticationType.AzureMFAAndUser, AuthenticationType.Integrated, AuthenticationType.SqlLogin, AuthenticationType.dSTSAuth, AuthenticationType.None];
|
||||
[AuthenticationType.AzureMFA, AuthenticationType.AzureMFAAndUser, AuthenticationType.Integrated, AuthenticationType.SqlLogin, AuthenticationType.DSTSAuth, AuthenticationType.None];
|
||||
private static readonly _osByName = {
|
||||
Windows: OperatingSystem.Windows,
|
||||
Macintosh: OperatingSystem.Macintosh,
|
||||
@@ -528,7 +520,7 @@ export class ConnectionWidget extends lifecycle.Disposable {
|
||||
// Immediately show/hide appropriate elements though so user gets immediate feedback while we load accounts
|
||||
this._tableContainer.classList.remove('hide-username');
|
||||
this._tableContainer.classList.remove('hide-azure-accounts');
|
||||
} else if (currentAuthType === AuthenticationType.dSTSAuth) {
|
||||
} else if (currentAuthType === AuthenticationType.DSTSAuth) {
|
||||
this._accountManagementService.getAccountsForProvider('dstsAuth').then(accounts => {
|
||||
if (accounts && accounts.length > 0) {
|
||||
accounts[0].key.providerArgs = {
|
||||
@@ -891,7 +883,7 @@ export class ConnectionWidget extends lifecycle.Disposable {
|
||||
if (this.authenticationType === AuthenticationType.AzureMFAAndUser || this.authenticationType === AuthenticationType.AzureMFA) {
|
||||
return this._azureAccountDropdown.value;
|
||||
}
|
||||
if (this.authenticationType === AuthenticationType.dSTSAuth) {
|
||||
if (this.authenticationType === AuthenticationType.DSTSAuth) {
|
||||
return this._token;
|
||||
}
|
||||
return undefined;
|
||||
|
||||
Reference in New Issue
Block a user