Add AuthenticationType enum to typings (#20699)

* Add AuthenticationType enum to typings

* fix

* const

* Add comments

* fix comment

* remove unused
This commit is contained in:
Charles Gagnon
2022-09-30 16:49:36 -07:00
committed by GitHub
parent d6d75d8817
commit 85dc506a3c
49 changed files with 236 additions and 164 deletions

View File

@@ -9,6 +9,7 @@ import { ConnectionConfig } from 'sql/platform/connection/common/connectionConfi
import { fixupConnectionCredentials } from 'sql/platform/connection/common/connectionInfo';
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
import { ConnectionProfileGroup, IConnectionProfileGroup } from 'sql/platform/connection/common/connectionProfileGroup';
import { AuthenticationType } from 'sql/platform/connection/common/constants';
import { IConnectionProfile, ProfileMatcher } from 'sql/platform/connection/common/interfaces';
import { ICredentialsService } from 'sql/platform/credentials/common/credentialsService';
import { isDisposable } from 'vs/base/common/lifecycle';
@@ -90,9 +91,9 @@ export class ConnectionStore {
}
return { profile: credentialsItem, savedCred: !!savedCred };
});
} else if (credentialsItem.authenticationType === 'AzureMFA' || credentialsItem.authenticationType === 'dstsAuth' && credentialsItem.azureAccount) {
} else if (credentialsItem.authenticationType === AuthenticationType.AzureMFA || credentialsItem.authenticationType === AuthenticationType.DSTSAuth && credentialsItem.azureAccount) {
return Promise.resolve({ profile: credentialsItem, savedCred: true });
} else if (credentialsItem.authenticationType === 'None') {
} else if (credentialsItem.authenticationType === AuthenticationType.None) {
// Kusto supports no authentication
return Promise.resolve({ profile: credentialsItem, savedCred: true });
} else {

View File

@@ -24,12 +24,35 @@ export const passwordChars = '***************';
/* default authentication type setting name*/
export const defaultAuthenticationType = 'defaultAuthenticationType';
/* authentication types */
export const sqlLogin = 'SqlLogin';
export const integrated = 'Integrated';
export const azureMFA = 'AzureMFA';
export const azureMFAAndUser = 'AzureMFAAndUser';
export const dstsAuth = 'dstsAuth';
/**
* Well-known Authentication types commonly supported by connection providers.
*/
export enum AuthenticationType {
/**
* Username and password
*/
SqlLogin = 'SqlLogin',
/**
* Windows Authentication
*/
Integrated = 'Integrated',
/**
* Azure Active Directory - Universal with MFA support
*/
AzureMFA = 'AzureMFA',
/**
* Azure Active Directory - Password
*/
AzureMFAAndUser = 'AzureMFAAndUser',
/**
* Datacenter Security Token Service Authentication
*/
DSTSAuth = 'dstsAuth',
/**
* No authentication required
*/
None = 'None'
}
/* CMS constants */
export const cmsProviderName = 'MSSQL-CMS';

View File

@@ -19,7 +19,6 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect
options: { [name: string]: any } = {};
private _providerName?: string;
private static readonly SqlAuthentication = 'SqlLogin';
public static readonly ProviderPropertyName = 'providerName';
public constructor(
@@ -194,7 +193,7 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect
option => option.specialValueType === ConnectionOptionSpecialType.password)!; // i guess we are going to assume there is a password field
let isPasswordRequired = optionMetadata.isRequired;
if (this.providerName === Constants.mssqlProviderName) {
isPasswordRequired = this.authenticationType === ProviderConnectionInfo.SqlAuthentication && optionMetadata.isRequired;
isPasswordRequired = this.authenticationType === Constants.AuthenticationType.SqlLogin && optionMetadata.isRequired;
}
return isPasswordRequired;
}

View File

@@ -15,7 +15,7 @@ import { TestCredentialsService } from 'sql/platform/credentials/test/common/tes
import { TestCapabilitiesService } from 'sql/platform/capabilities/test/common/testCapabilitiesService';
import { deepClone, deepFreeze } from 'vs/base/common/objects';
import { ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
import { AuthenticationType, mssqlProviderName } from 'sql/platform/connection/common/constants';
import { ConnectionProviderProperties } from 'sql/platform/capabilities/common/capabilitiesService';
import { InMemoryStorageService } from 'vs/platform/storage/common/storage';
import { generateUuid } from 'vs/base/common/uuid';
@@ -25,7 +25,7 @@ suite('ConnectionStore', () => {
connectionName: 'new name',
serverName: 'namedServer',
databaseName: 'bcd',
authenticationType: 'SqlLogin',
authenticationType: AuthenticationType.SqlLogin,
userName: 'cde', // [SuppressMessage("Microsoft.Security", "CS001:SecretInline", Justification="Mock value, never actually used to connect")]
password: generateUuid(),
savePassword: true,
@@ -214,7 +214,7 @@ suite('ConnectionStore', () => {
credentialsService, capabilitiesService);
const integratedCred = Object.assign({}, defaultNamedProfile, {
serverName: defaultNamedProfile.serverName + 'Integrated',
authenticationType: 'Integrated',
authenticationType: AuthenticationType.Integrated,
userName: '',
password: ''
});