mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -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:
@@ -129,7 +129,7 @@ async function launchSsmsDialog(action: string, connectionContext: azdata.Object
|
||||
server: connectionContext.connectionProfile.serverName,
|
||||
database: connectionContext.connectionProfile.databaseName,
|
||||
user: connectionContext.connectionProfile.userName,
|
||||
useAad: connectionContext.connectionProfile.authenticationType === 'AzureMFA',
|
||||
useAad: connectionContext.connectionProfile.authenticationType === azdata.connection.AuthenticationType.AzureMFA,
|
||||
urn: urn
|
||||
};
|
||||
|
||||
|
||||
@@ -209,7 +209,7 @@ export class MiaaModel extends ResourceModel {
|
||||
return {
|
||||
serverName: `${ipAndPort.ip},${ipAndPort.port}`,
|
||||
databaseName: '',
|
||||
authenticationType: 'SqlLogin',
|
||||
authenticationType: azdata.connection.AuthenticationType.SqlLogin,
|
||||
providerName: loc.miaaProviderName,
|
||||
connectionName: '',
|
||||
userName: this._miaaInfo.userName || '',
|
||||
|
||||
@@ -192,7 +192,7 @@ export class PostgresModel extends ResourceModel {
|
||||
return {
|
||||
serverName: `${ipAndPort.ip},${ipAndPort.port}`,
|
||||
databaseName: '',
|
||||
authenticationType: 'SqlLogin',
|
||||
authenticationType: azdata.connection.AuthenticationType.SqlLogin,
|
||||
providerName: loc.postgresProviderName,
|
||||
connectionName: '',
|
||||
userName: this._pgInfo.userName || '',
|
||||
|
||||
@@ -97,7 +97,7 @@ export abstract class ConnectToSqlDialog extends InitializingComponent {
|
||||
const connectionProfile: azdata.IConnectionProfile = {
|
||||
serverName: this.serverNameInputBox.value,
|
||||
databaseName: '',
|
||||
authenticationType: 'SqlLogin',
|
||||
authenticationType: azdata.connection.AuthenticationType.SqlLogin,
|
||||
providerName: this.providerName,
|
||||
connectionName: '',
|
||||
userName: this.usernameInputBox.value,
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ExtensionNodeType, TreeItem } from 'azdata';
|
||||
import { ExtensionNodeType, TreeItem, connection } from 'azdata';
|
||||
import { TreeItemCollapsibleState, ExtensionContext } from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
const localize = nls.loadMessageBundle();
|
||||
@@ -43,7 +43,7 @@ export class AzureMonitorTreeDataProvider extends ResourceTreeDataProviderBase<a
|
||||
databaseName: databaseServer.defaultDatabaseName,
|
||||
userName: databaseServer.loginName,
|
||||
password: '',
|
||||
authenticationType: 'AzureMFA',
|
||||
authenticationType: connection.AuthenticationType.AzureMFA,
|
||||
savePassword: true,
|
||||
groupFullName: '',
|
||||
groupId: '',
|
||||
|
||||
@@ -42,7 +42,7 @@ export class CosmosDbMongoTreeDataProvider extends ResourceTreeDataProviderBase<
|
||||
serverName: databaseServer.name,
|
||||
userName: databaseServer.loginName,
|
||||
password: '',
|
||||
authenticationType: 'AzureMFA',
|
||||
authenticationType: azdata.connection.AuthenticationType.AzureMFA,
|
||||
savePassword: true,
|
||||
groupFullName: '',
|
||||
groupId: '',
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ExtensionNodeType, TreeItem } from 'azdata';
|
||||
import { connection, ExtensionNodeType, TreeItem } from 'azdata';
|
||||
import { TreeItemCollapsibleState, ExtensionContext } from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
const localize = nls.loadMessageBundle();
|
||||
@@ -43,7 +43,7 @@ export class KustoTreeDataProvider extends ResourceTreeDataProviderBase<azureRes
|
||||
databaseName: databaseServer.defaultDatabaseName,
|
||||
userName: databaseServer.loginName,
|
||||
password: '',
|
||||
authenticationType: 'AzureMFA',
|
||||
authenticationType: connection.AuthenticationType.AzureMFA,
|
||||
savePassword: true,
|
||||
groupFullName: '',
|
||||
groupId: '',
|
||||
|
||||
@@ -12,7 +12,7 @@ import { generateGuid } from '../../utils';
|
||||
import { IAzureResourceService } from '../../interfaces';
|
||||
import { ResourceTreeDataProviderBase } from '../resourceTreeDataProviderBase';
|
||||
import { azureResource } from 'azurecore';
|
||||
import { Account, ExtensionNodeType, TreeItem } from 'azdata';
|
||||
import { Account, ExtensionNodeType, TreeItem, connection } from 'azdata';
|
||||
|
||||
export class MysqlFlexibleServerTreeDataProvider extends ResourceTreeDataProviderBase<azureResource.AzureResourceDatabaseServer> {
|
||||
private static readonly MYSQL_FLEXIBLE_SERVER_PROVIDER_ID = 'MySQL';
|
||||
@@ -43,7 +43,7 @@ export class MysqlFlexibleServerTreeDataProvider extends ResourceTreeDataProvide
|
||||
databaseName: databaseServer.defaultDatabaseName,
|
||||
userName: databaseServer.loginName,
|
||||
password: '',
|
||||
authenticationType: 'SqlLogin',
|
||||
authenticationType: connection.AuthenticationType.SqlLogin,
|
||||
savePassword: true,
|
||||
groupFullName: '',
|
||||
groupId: '',
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ExtensionNodeType, TreeItem } from 'azdata';
|
||||
import { ExtensionNodeType, TreeItem, connection } from 'azdata';
|
||||
import { TreeItemCollapsibleState, ExtensionContext } from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
const localize = nls.loadMessageBundle();
|
||||
@@ -43,7 +43,7 @@ export class PostgresServerArcTreeDataProvider extends ResourceTreeDataProviderB
|
||||
databaseName: databaseServer.defaultDatabaseName,
|
||||
userName: `${databaseServer.loginName}@${databaseServer.fullName}`,
|
||||
password: '',
|
||||
authenticationType: 'SqlLogin',
|
||||
authenticationType: connection.AuthenticationType.SqlLogin,
|
||||
savePassword: true,
|
||||
groupFullName: '',
|
||||
groupId: '',
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ExtensionNodeType, TreeItem } from 'azdata';
|
||||
import { ExtensionNodeType, TreeItem, connection } from 'azdata';
|
||||
import { TreeItemCollapsibleState, ExtensionContext } from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
const localize = nls.loadMessageBundle();
|
||||
@@ -43,7 +43,7 @@ export class PostgresServerTreeDataProvider extends ResourceTreeDataProviderBase
|
||||
databaseName: databaseServer.defaultDatabaseName,
|
||||
userName: `${databaseServer.loginName}@${databaseServer.fullName}`,
|
||||
password: '',
|
||||
authenticationType: 'SqlLogin',
|
||||
authenticationType: connection.AuthenticationType.SqlLogin,
|
||||
savePassword: true,
|
||||
groupFullName: '',
|
||||
groupId: '',
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ExtensionNodeType, TreeItem } from 'azdata';
|
||||
import { ExtensionNodeType, TreeItem, connection } from 'azdata';
|
||||
import { TreeItemCollapsibleState, ExtensionContext } from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
const localize = nls.loadMessageBundle();
|
||||
@@ -43,7 +43,7 @@ export class SqlInstanceTreeDataProvider extends ResourceTreeDataProviderBase<az
|
||||
databaseName: databaseServer.defaultDatabaseName,
|
||||
userName: databaseServer.loginName,
|
||||
password: '',
|
||||
authenticationType: 'SqlLogin',
|
||||
authenticationType: connection.AuthenticationType.SqlLogin,
|
||||
savePassword: true,
|
||||
groupFullName: '',
|
||||
groupId: '',
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ExtensionNodeType, TreeItem } from 'azdata';
|
||||
import { ExtensionNodeType, TreeItem, connection } from 'azdata';
|
||||
import { TreeItemCollapsibleState, ExtensionContext } from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
const localize = nls.loadMessageBundle();
|
||||
@@ -43,7 +43,7 @@ export class SqlInstanceArcTreeDataProvider extends ResourceTreeDataProviderBase
|
||||
databaseName: databaseServer.defaultDatabaseName,
|
||||
userName: databaseServer.loginName,
|
||||
password: '',
|
||||
authenticationType: 'SqlLogin',
|
||||
authenticationType: connection.AuthenticationType.SqlLogin,
|
||||
savePassword: true,
|
||||
groupFullName: '',
|
||||
groupId: '',
|
||||
|
||||
@@ -139,7 +139,7 @@ async function getMountProps(explorerContext?: azdata.ObjectExplorerContext): Pr
|
||||
let profile = explorerContext.connectionProfile;
|
||||
let mountProps: MountHdfsProperties = {
|
||||
url: endpoint,
|
||||
auth: profile.authenticationType === 'SqlLogin' ? 'basic' : 'integrated',
|
||||
auth: profile.authenticationType === azdata.connection.AuthenticationType.SqlLogin ? 'basic' : 'integrated',
|
||||
username: profile.userName,
|
||||
password: profile.password,
|
||||
hdfsPath: getHdsfPath(explorerContext.nodeInfo.nodePath)
|
||||
|
||||
@@ -38,7 +38,7 @@ export class CmsResourceTreeNode extends CmsResourceTreeNodeBase {
|
||||
let nodes: CmsResourceTreeNodeBase[] = [];
|
||||
if (!this.ownerUri) {
|
||||
// Set back password to get ownerUri
|
||||
if (this.connection.options.authenticationType === 'SqlLogin' && this.connection.options.savePassword === true) {
|
||||
if (this.connection.options.authenticationType === azdata.connection.AuthenticationType.SqlLogin && this.connection.options.savePassword === true) {
|
||||
this.connection.options.password = await this.appContext.cmsUtils.getPassword(this.connection.options.user);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ export class RegisteredServerTreeNode extends CmsResourceTreeNodeBase {
|
||||
databaseName: '',
|
||||
userName: undefined as string,
|
||||
password: undefined as string,
|
||||
authenticationType: 'Integrated',
|
||||
authenticationType: azdata.connection.AuthenticationType.Integrated,
|
||||
savePassword: false,
|
||||
groupFullName: '',
|
||||
groupId: '',
|
||||
|
||||
@@ -14,7 +14,6 @@ const localize = nls.loadMessageBundle();
|
||||
const cmsProvider: string = 'MSSQL-CMS';
|
||||
const mssqlProvider: string = 'MSSQL';
|
||||
const CredentialNamespace = 'cmsCredentials';
|
||||
const sqlLoginAuthType: string = 'SqlLogin';
|
||||
|
||||
interface CreateCmsResult {
|
||||
listRegisteredServersResult: mssql.ListRegisteredServersResult;
|
||||
@@ -121,7 +120,7 @@ export class CmsUtils {
|
||||
return cachedServer.name !== cmsServerName;
|
||||
});
|
||||
}
|
||||
if (connection.options.authenticationType === sqlLoginAuthType && connection.options.savePassword) {
|
||||
if (connection.options.authenticationType === azdata.connection.AuthenticationType.SqlLogin && connection.options.savePassword) {
|
||||
this._credentialProvider.deleteCredential(connection.options.user);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ describe('import extension summary page tests', function () {
|
||||
options: {
|
||||
azureAccount: getAzureAccounts()[1].key.accountId,
|
||||
azureTenantId: 'azureAccount2Tenant',
|
||||
authenticationType: 'AzureMFA'
|
||||
authenticationType: azdata.connection.AuthenticationType.AzureMFA
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -136,11 +136,11 @@ export class SummaryPage extends ImportPage {
|
||||
let err;
|
||||
|
||||
const currentServer = this.model.server;
|
||||
const includePasswordInConnectionString = (currentServer.options.authenticationType === 'Integrated') ? false : true;
|
||||
const includePasswordInConnectionString = (currentServer.options.authenticationType === azdata.connection.AuthenticationType.Integrated) ? false : true;
|
||||
const connectionString = await azdata.connection.getConnectionString(currentServer.connectionId, includePasswordInConnectionString);
|
||||
|
||||
let accessToken = undefined;
|
||||
if (currentServer.options.authenticationType === 'AzureMFA') {
|
||||
if (currentServer.options.authenticationType === azdata.connection.AuthenticationType.AzureMFA) {
|
||||
const azureAccount = (await azdata.accounts.getAllAccounts()).filter(v => v.key.accountId === currentServer.options.azureAccount)[0];
|
||||
accessToken = (await azdata.accounts.getAccountSecurityToken(azureAccount, currentServer.options.azureTenantId, azdata.AzureResource.Sql)).token;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
|
||||
/*
|
||||
TODO: Due to a runtime error, I duplicated this file at these 2 locations:
|
||||
$/extensions/integration-test/src/testConfig.ts
|
||||
@@ -45,7 +47,7 @@ let connectionProviderMapping: { [key: string]: { name: string; displayName: str
|
||||
let authenticationTypeMapping: { [key: string]: { name: string; displayName: string } } = {};
|
||||
connectionProviderMapping[ConnectionProvider.SQLServer] = { name: 'MSSQL', displayName: 'Microsoft SQL Server' };
|
||||
|
||||
authenticationTypeMapping[AuthenticationType.SqlLogin] = { name: 'SqlLogin', displayName: 'SQL Login' };
|
||||
authenticationTypeMapping[AuthenticationType.SqlLogin] = { name: azdata.connection.AuthenticationType.SqlLogin, displayName: 'SQL Login' };
|
||||
authenticationTypeMapping[AuthenticationType.Windows] = { name: 'Integrated', displayName: 'Windows Authentication' };
|
||||
|
||||
export function getConfigValue(name: string): string {
|
||||
|
||||
@@ -263,7 +263,7 @@ describe('Jupyter Session', function (): void {
|
||||
id: 'id',
|
||||
providerName: 'MSSQL',
|
||||
options: {
|
||||
authenticationType: 'SqlLogin',
|
||||
authenticationType: connection.AuthenticationType.SqlLogin,
|
||||
},
|
||||
password: '',
|
||||
savePassword: false,
|
||||
@@ -340,7 +340,7 @@ describe('Jupyter Session', function (): void {
|
||||
id: 'id',
|
||||
providerName: 'MSSQL',
|
||||
options: {
|
||||
authenticationType: 'SqlLogin',
|
||||
authenticationType: connection.AuthenticationType.SqlLogin,
|
||||
},
|
||||
password: '',
|
||||
savePassword: false,
|
||||
@@ -366,7 +366,7 @@ describe('Jupyter Session', function (): void {
|
||||
id: 'id',
|
||||
providerName: 'provider',
|
||||
options: {
|
||||
authenticationType: 'SqlLogin',
|
||||
authenticationType: connection.AuthenticationType.SqlLogin,
|
||||
},
|
||||
password: '',
|
||||
savePassword: false,
|
||||
|
||||
@@ -15,7 +15,7 @@ export const mockIConnectionProfile: azdata.IConnectionProfile = {
|
||||
databaseName: 'My Database',
|
||||
userName: 'My User',
|
||||
password: 'My Pwd',
|
||||
authenticationType: 'SqlLogin',
|
||||
authenticationType: azdata.connection.AuthenticationType.SqlLogin,
|
||||
savePassword: false,
|
||||
groupFullName: 'My groupName',
|
||||
groupId: 'My GroupId',
|
||||
@@ -38,7 +38,7 @@ export const mockConnectionInfo = {
|
||||
databaseName: 'My Database',
|
||||
userName: 'My User',
|
||||
password: 'My Pwd',
|
||||
authenticationType: 'SqlLogin'
|
||||
authenticationType: azdata.connection.AuthenticationType.SqlLogin
|
||||
};
|
||||
|
||||
export const mockFilePath: string = 'test.dacpac';
|
||||
|
||||
@@ -120,7 +120,7 @@ export async function verifyConnectionAndGetOwnerUri(endpoint: mssql.SchemaCompa
|
||||
|
||||
let userConnection;
|
||||
userConnection = connectionList.find(connection =>
|
||||
(endpoint.connectionDetails['authenticationType'] === 'SqlLogin'
|
||||
(endpoint.connectionDetails['authenticationType'] === azdata.connection.AuthenticationType.SqlLogin
|
||||
&& endpoint.connectionDetails['serverName'] === connection.options.server
|
||||
&& endpoint.connectionDetails['userName'] === connection.options.user
|
||||
&& (endpoint.connectionDetails['databaseName'].toLowerCase() === connection.options.database.toLowerCase()
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as vscodeMssql from 'vscode-mssql';
|
||||
import * as fs from 'fs';
|
||||
import * as vscode from 'vscode';
|
||||
import * as path from 'path';
|
||||
@@ -9,7 +11,6 @@ import * as utils from './utils';
|
||||
import * as constants from './constants';
|
||||
import * as azureFunctionsContracts from '../contracts/azureFunctions/azureFunctionsContracts';
|
||||
import { BindingType, IConnectionStringInfo, ObjectType } from 'sql-bindings';
|
||||
import { ConnectionDetails, IConnectionInfo } from 'vscode-mssql';
|
||||
// https://github.com/microsoft/vscode-azurefunctions/blob/main/src/vscode-azurefunctions.api.d.ts
|
||||
import { AzureFunctionsExtensionApi } from '../../../types/vscode-azurefunctions.api';
|
||||
// https://github.com/microsoft/vscode-azuretools/blob/main/ui/api.d.ts
|
||||
@@ -306,7 +307,7 @@ export async function promptForObjectType(): Promise<ObjectType | undefined> {
|
||||
* @param objectType (optional) type of object to query/upsert into
|
||||
* @returns the object name from user's input or menu choice
|
||||
*/
|
||||
export async function promptForObjectName(bindingType: BindingType, connectionInfo?: IConnectionInfo, objectType?: ObjectType): Promise<string | undefined> {
|
||||
export async function promptForObjectName(bindingType: BindingType, connectionInfo?: vscodeMssql.IConnectionInfo, objectType?: ObjectType): Promise<string | undefined> {
|
||||
// show the connection string methods (user input and connection profile options)
|
||||
let connectionURI: string | undefined;
|
||||
let selectedDatabase: string | undefined;
|
||||
@@ -344,7 +345,7 @@ export async function promptForObjectName(bindingType: BindingType, connectionIn
|
||||
* if left undefined we prompt the user for the connection info
|
||||
* @returns connection string setting name to be used for the createFunction API
|
||||
*/
|
||||
export async function promptAndUpdateConnectionStringSetting(projectUri: vscode.Uri | undefined, connectionInfo?: IConnectionInfo): Promise<IConnectionStringInfo | undefined> {
|
||||
export async function promptAndUpdateConnectionStringSetting(projectUri: vscode.Uri | undefined, connectionInfo?: vscodeMssql.IConnectionInfo): Promise<IConnectionStringInfo | undefined> {
|
||||
let connectionStringSettingName: string | undefined;
|
||||
|
||||
// show the settings from project's local.settings.json if there's an AF functions project
|
||||
@@ -495,16 +496,16 @@ export async function promptAndUpdateConnectionStringSetting(projectUri: vscode.
|
||||
* @param localSettingsPath path to the local.settings.json file
|
||||
* @returns the updated connection string based on password prompts
|
||||
*/
|
||||
export async function promptConnectionStringPasswordAndUpdateConnectionString(connectionInfo: IConnectionInfo, localSettingsPath: string): Promise<string | undefined> {
|
||||
export async function promptConnectionStringPasswordAndUpdateConnectionString(connectionInfo: vscodeMssql.IConnectionInfo, localSettingsPath: string): Promise<string | undefined> {
|
||||
let includePassword: string | undefined;
|
||||
let connectionString: string = '';
|
||||
let connectionDetails: ConnectionDetails;
|
||||
let connectionDetails: vscodeMssql.ConnectionDetails;
|
||||
let userPassword: string | undefined;
|
||||
const vscodeMssqlApi = await utils.getVscodeMssqlApi();
|
||||
connectionDetails = { options: connectionInfo };
|
||||
|
||||
try {
|
||||
if (connectionInfo.authenticationType === 'SqlLogin' && connectionInfo.password) {
|
||||
if (connectionInfo.authenticationType === vscodeMssql.AuthenticationType.SqlLogin && connectionInfo.password) {
|
||||
// Prompt to include password in connection string if authentication type is SqlLogin and connection has password saved
|
||||
includePassword = await vscode.window.showQuickPick([constants.yesString, constants.noString], {
|
||||
title: constants.includePassword,
|
||||
@@ -517,18 +518,18 @@ export async function promptConnectionStringPasswordAndUpdateConnectionString(co
|
||||
}
|
||||
}
|
||||
|
||||
if (includePassword !== constants.yesString || !connectionInfo.password || connectionInfo.authenticationType !== 'SqlLogin') {
|
||||
if (includePassword !== constants.yesString || !connectionInfo.password || connectionInfo.authenticationType !== vscodeMssql.AuthenticationType.SqlLogin) {
|
||||
// get connection string to not include the password if connection info does not include password,
|
||||
// or user chooses to not include password (or if user cancels out of include password prompt), or authentication type is not SQL login
|
||||
connectionString = await vscodeMssqlApi.getConnectionString(connectionDetails, false, false);
|
||||
|
||||
if (connectionInfo.authenticationType !== 'SqlLogin') {
|
||||
if (connectionInfo.authenticationType !== vscodeMssql.AuthenticationType.SqlLogin) {
|
||||
// temporarily fix until STS is fix to not include the placeholder: https://github.com/microsoft/sqltoolsservice/issues/1508
|
||||
// if authentication type is not SQL login, remove password in connection string
|
||||
connectionString = connectionString.replace(`Password=${constants.passwordPlaceholder};`, '');
|
||||
}
|
||||
|
||||
if (!connectionInfo.password && connectionInfo.authenticationType === 'SqlLogin') {
|
||||
if (!connectionInfo.password && connectionInfo.authenticationType === vscodeMssql.AuthenticationType.SqlLogin) {
|
||||
// if a connection exists but does not have password saved we ask user if they would like to enter it and save it in local.settings.json
|
||||
userPassword = await vscode.window.showInputBox({
|
||||
prompt: constants.enterPasswordPrompt,
|
||||
@@ -542,7 +543,7 @@ export async function promptConnectionStringPasswordAndUpdateConnectionString(co
|
||||
}
|
||||
}
|
||||
|
||||
if (!userPassword && connectionInfo.authenticationType === 'SqlLogin') {
|
||||
if (!userPassword && connectionInfo.authenticationType === vscodeMssql.AuthenticationType.SqlLogin) {
|
||||
// show warning message that user will have to enter password manually later in local.settings.json
|
||||
// if they choose to not to include password, if connection info does not include password
|
||||
void vscode.window.showWarningMessage(constants.userPasswordLater, constants.openFile, constants.closeButton).then(async (result) => {
|
||||
@@ -580,7 +581,7 @@ export async function promptSelectDatabase(connectionURI: string): Promise<strin
|
||||
return selectedDatabase;
|
||||
}
|
||||
|
||||
export async function getConnectionURI(connectionInfo: IConnectionInfo): Promise<string | undefined> {
|
||||
export async function getConnectionURI(connectionInfo: vscodeMssql.IConnectionInfo): Promise<string | undefined> {
|
||||
const vscodeMssqlApi = await utils.getVscodeMssqlApi();
|
||||
let connectionURI: string = '';
|
||||
try {
|
||||
|
||||
@@ -88,7 +88,7 @@ export function createTestCredentials(): vscodeMssql.IConnectionInfo {
|
||||
accountId: 'test-account-id',
|
||||
tenantId: 'test-tenant-id',
|
||||
port: 1234,
|
||||
authenticationType: 'SqlLogin',
|
||||
authenticationType: vscodeMssql.AuthenticationType.SqlLogin,
|
||||
azureAccountToken: '',
|
||||
expiresOn: 0,
|
||||
encrypt: false,
|
||||
|
||||
@@ -535,11 +535,6 @@ export const activeDirectoryInteractive = 'active directory interactive';
|
||||
export const userIdSetting = 'User ID';
|
||||
export const passwordSetting = 'Password';
|
||||
|
||||
// Authentication types
|
||||
export const integratedAuth = 'Integrated';
|
||||
export const azureMfaAuth = 'AzureMFA';
|
||||
export const sqlAuth = 'SqlAuth';
|
||||
|
||||
export const azureAddAccount = localize('azureAddAccount', "Add an Account...");
|
||||
|
||||
// Tree item types
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import * as constants from '../../common/constants';
|
||||
import * as utils from '../../common/utils';
|
||||
import * as vscode from 'vscode';
|
||||
import { ConnectionResult } from 'azdata';
|
||||
import { IFireWallRuleError } from 'vscode-mssql';
|
||||
import { ISqlConnectionProperties } from 'sqldbproj';
|
||||
|
||||
@@ -28,7 +28,7 @@ export class ConnectionService {
|
||||
* @param database database name
|
||||
* @returns
|
||||
*/
|
||||
private async connectToDatabase(profile: ISqlConnectionProperties, saveConnectionAndPassword: boolean, database: string): Promise<ConnectionResult | string | undefined> {
|
||||
private async connectToDatabase(profile: ISqlConnectionProperties, saveConnectionAndPassword: boolean, database: string): Promise<azdata.ConnectionResult | string | undefined> {
|
||||
const azdataApi = utils.getAzdataApi();
|
||||
const vscodeMssqlApi = azdataApi ? undefined : await utils.getVscodeMssqlApi();
|
||||
if (azdataApi) {
|
||||
@@ -43,7 +43,7 @@ export class ConnectionService {
|
||||
id: '',
|
||||
connectionName: profile.profileName,
|
||||
options: [],
|
||||
authenticationType: 'SqlLogin'
|
||||
authenticationType: azdata.connection.AuthenticationType.SqlLogin
|
||||
};
|
||||
return await azdataApi.connection.connect(connectionProfile, saveConnectionAndPassword, false);
|
||||
} else if (vscodeMssqlApi) {
|
||||
@@ -54,7 +54,7 @@ export class ConnectionService {
|
||||
database: database,
|
||||
savePassword: saveConnectionAndPassword,
|
||||
user: profile.userName,
|
||||
authenticationType: 'SqlLogin',
|
||||
authenticationType: azdata.connection.AuthenticationType.SqlLogin,
|
||||
encrypt: false,
|
||||
connectTimeout: 30,
|
||||
applicationName: 'SQL Database Project',
|
||||
@@ -112,12 +112,12 @@ export class ConnectionService {
|
||||
* @param connection connection result or connection Id
|
||||
* @returns validation result
|
||||
*/
|
||||
private async validateConnection(connection: ConnectionResult | string | undefined): Promise<utils.ValidationResult> {
|
||||
private async validateConnection(connection: azdata.ConnectionResult | string | undefined): Promise<utils.ValidationResult> {
|
||||
const azdataApi = utils.getAzdataApi();
|
||||
if (!connection) {
|
||||
return { validated: false, errorMessage: constants.connectionFailedError('No result returned') };
|
||||
} else if (azdataApi) {
|
||||
const connectionResult = <ConnectionResult>connection;
|
||||
const connectionResult = <azdata.ConnectionResult>connection;
|
||||
if (connectionResult) {
|
||||
const connected = connectionResult !== undefined && connectionResult.connected && connectionResult.connectionId !== undefined;
|
||||
return { validated: connected, errorMessage: connected ? '' : constants.connectionFailedError(connectionResult?.errorMessage!) };
|
||||
@@ -134,9 +134,9 @@ export class ConnectionService {
|
||||
* @param connection connection result or connection Id
|
||||
* @returns formatted connection result
|
||||
*/
|
||||
private async formatConnectionResult(connection: ConnectionResult | string | undefined): Promise<string> {
|
||||
private async formatConnectionResult(connection: azdata.ConnectionResult | string | undefined): Promise<string> {
|
||||
const azdataApi = utils.getAzdataApi();
|
||||
const connectionResult = connection !== undefined && azdataApi ? <ConnectionResult>connection : undefined;
|
||||
const connectionResult = connection !== undefined && azdataApi ? <azdata.ConnectionResult>connection : undefined;
|
||||
return connectionResult?.connected ? connectionResult.connectionId! : <string>connection;
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ export class ConnectionService {
|
||||
this.defaultSqlNumberOfRetries, profile.connectionRetryTimeout || this.defaultSqlRetryTimeoutInSec);
|
||||
|
||||
if (connection) {
|
||||
const connectionResult = <ConnectionResult>connection;
|
||||
const connectionResult = <azdata.ConnectionResult>connection;
|
||||
if (azdataApi) {
|
||||
utils.throwIfNotConnected(connectionResult);
|
||||
return azdataApi.connection.getUriForConnection(connectionResult.connectionId!);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import type * as azdataType from 'azdata';
|
||||
import * as vscodeMssql from 'vscode-mssql';
|
||||
import { DataSource } from './dataSources';
|
||||
import * as constants from '../../common/constants';
|
||||
|
||||
@@ -44,11 +45,11 @@ export class SqlConnectionDataSource extends DataSource {
|
||||
|
||||
public get authType(): string {
|
||||
if (this.azureMFA) {
|
||||
return constants.azureMfaAuth;
|
||||
return vscodeMssql.AuthenticationType.AzureMFA;
|
||||
} else if (this.integratedSecurity) {
|
||||
return constants.integratedAuth;
|
||||
return vscodeMssql.AuthenticationType.Integrated;
|
||||
} else {
|
||||
return constants.sqlAuth;
|
||||
return 'SqlAuth';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ export const mockConnectionProfile: azdata.IConnectionProfile = {
|
||||
databaseName: 'My Database',
|
||||
userName: 'My User',
|
||||
password: 'My Pwd',
|
||||
authenticationType: 'SqlLogin',
|
||||
authenticationType: azdata.connection.AuthenticationType.SqlLogin,
|
||||
savePassword: false,
|
||||
groupFullName: 'My groupName',
|
||||
groupId: 'My GroupId',
|
||||
@@ -122,7 +122,7 @@ export const mockConnectionProfile: azdata.IConnectionProfile = {
|
||||
database: 'My Database',
|
||||
user: 'My User',
|
||||
password: 'My Pwd',
|
||||
authenticationType: 'SqlLogin',
|
||||
authenticationType: azdata.connection.AuthenticationType.SqlLogin,
|
||||
connectionName: 'My Connection Name'
|
||||
}
|
||||
};
|
||||
|
||||
@@ -50,11 +50,6 @@ export const excludeDatabses: string[] = [
|
||||
'model'
|
||||
];
|
||||
|
||||
export enum AuthenticationType {
|
||||
Integrated = 'Integrated',
|
||||
SqlLogin = 'SqlLogin'
|
||||
}
|
||||
|
||||
export interface TableInfo {
|
||||
databaseName: string;
|
||||
tableName: string;
|
||||
@@ -89,14 +84,14 @@ function getSqlDbConnectionProfile(
|
||||
databaseName: databaseName,
|
||||
userName: userName,
|
||||
password: password,
|
||||
authenticationType: AuthenticationType.SqlLogin,
|
||||
authenticationType: azdata.connection.AuthenticationType.SqlLogin,
|
||||
savePassword: false,
|
||||
saveProfile: false,
|
||||
options: {
|
||||
conectionName: '',
|
||||
server: serverName,
|
||||
database: databaseName,
|
||||
authenticationType: AuthenticationType.SqlLogin,
|
||||
authenticationType: azdata.connection.AuthenticationType.SqlLogin,
|
||||
user: userName,
|
||||
password: password,
|
||||
connectionTimeout: 60,
|
||||
@@ -125,7 +120,7 @@ function getConnectionProfile(
|
||||
azureResourceId: azureResourceId,
|
||||
userName: userName,
|
||||
password: password,
|
||||
authenticationType: AuthenticationType.SqlLogin,
|
||||
authenticationType: azdata.connection.AuthenticationType.SqlLogin,
|
||||
savePassword: false,
|
||||
groupFullName: '',
|
||||
groupId: '',
|
||||
@@ -134,7 +129,7 @@ function getConnectionProfile(
|
||||
options: {
|
||||
conectionName: '',
|
||||
server: serverName,
|
||||
authenticationType: AuthenticationType.SqlLogin,
|
||||
authenticationType: azdata.connection.AuthenticationType.SqlLogin,
|
||||
user: userName,
|
||||
password: password,
|
||||
connectionTimeout: 60,
|
||||
|
||||
@@ -16,7 +16,6 @@ import * as utils from '../api/utils';
|
||||
import { logError, TelemetryViews } from '../telemtery';
|
||||
import * as styles from '../constants/styles';
|
||||
import { TableMigrationSelectionDialog } from '../dialog/tableMigrationSelection/tableMigrationSelectionDialog';
|
||||
import { AuthenticationType } from '../api/sqlUtils';
|
||||
|
||||
const WIZARD_TABLE_COLUMN_WIDTH = '200px';
|
||||
const WIZARD_TABLE_COLUMN_WIDTH_SMALL = '170px';
|
||||
@@ -728,9 +727,9 @@ export class DatabaseBackupPage extends MigrationWizardPage {
|
||||
this.migrationStateModel.sourceConnectionId)), query);
|
||||
|
||||
const username = results.rows[0][0].displayValue;
|
||||
this.migrationStateModel._authenticationType = connectionProfile.authenticationType === AuthenticationType.SqlLogin
|
||||
this.migrationStateModel._authenticationType = connectionProfile.authenticationType === azdata.connection.AuthenticationType.SqlLogin
|
||||
? MigrationSourceAuthenticationType.Sql
|
||||
: connectionProfile.authenticationType === AuthenticationType.Integrated
|
||||
: connectionProfile.authenticationType === azdata.connection.AuthenticationType.Integrated
|
||||
? MigrationSourceAuthenticationType.Integrated
|
||||
: undefined!;
|
||||
this._sourceHelpText.value = constants.SQL_SOURCE_DETAILS(
|
||||
|
||||
@@ -9,7 +9,6 @@ import { MigrationWizardPage } from '../models/migrationWizardPage';
|
||||
import { MigrationSourceAuthenticationType, MigrationStateModel, StateChangeEvent } from '../models/stateMachine';
|
||||
import * as constants from '../constants/strings';
|
||||
import { createLabelTextComponent, createHeadingTextComponent, WIZARD_INPUT_COMPONENT_WIDTH } from './wizardController';
|
||||
import { AuthenticationType } from '../api/sqlUtils';
|
||||
|
||||
export class SqlSourceConfigurationPage extends MigrationWizardPage {
|
||||
private _view!: azdata.ModelView;
|
||||
@@ -60,9 +59,9 @@ export class SqlSourceConfigurationPage extends MigrationWizardPage {
|
||||
const query = 'select SUSER_NAME()';
|
||||
const results = await queryProvider.runQueryAndReturn(await (azdata.connection.getUriForConnection(this.migrationStateModel.sourceConnectionId)), query);
|
||||
const username = results.rows[0][0].displayValue;
|
||||
this.migrationStateModel._authenticationType = connectionProfile.authenticationType === AuthenticationType.SqlLogin
|
||||
this.migrationStateModel._authenticationType = connectionProfile.authenticationType === azdata.connection.AuthenticationType.SqlLogin
|
||||
? MigrationSourceAuthenticationType.Sql
|
||||
: connectionProfile.authenticationType === AuthenticationType.Integrated
|
||||
: connectionProfile.authenticationType === azdata.connection.AuthenticationType.Integrated
|
||||
? MigrationSourceAuthenticationType.Integrated
|
||||
: undefined!;
|
||||
|
||||
|
||||
32
extensions/types/vscode-mssql.d.ts
vendored
32
extensions/types/vscode-mssql.d.ts
vendored
@@ -122,11 +122,41 @@ declare module 'vscode-mssql' {
|
||||
getServerInfo(connectionInfo: IConnectionInfo): ServerInfo
|
||||
}
|
||||
|
||||
/**
|
||||
* Well-known Authentication types.
|
||||
*/
|
||||
export const 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'
|
||||
}
|
||||
|
||||
/**
|
||||
* The possible values of the server engine edition
|
||||
* EngineEdition under https://docs.microsoft.com/sql/t-sql/functions/serverproperty-transact-sql is associated with these values
|
||||
*/
|
||||
export const enum DatabaseEngineEdition {
|
||||
export const enum DatabaseEngineEdition {
|
||||
Unknown = 0,
|
||||
Personal = 1,
|
||||
Standard = 2,
|
||||
|
||||
Reference in New Issue
Block a user