From 4c0ae515ccaef1b96aed73828d9930d7e857da9f Mon Sep 17 00:00:00 2001 From: Nazar Kovtun Date: Fri, 18 Oct 2024 18:48:25 +0300 Subject: [PATCH 1/3] HCK-8467: added input for Client Id in Azure Active Directory (Username / Password) connection method --- .../connectionSettingsModalConfig.json | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/reverse_engineering/connection_settings_modal/connectionSettingsModalConfig.json b/reverse_engineering/connection_settings_modal/connectionSettingsModalConfig.json index 3f0c28e..495bbac 100644 --- a/reverse_engineering/connection_settings_modal/connectionSettingsModalConfig.json +++ b/reverse_engineering/connection_settings_modal/connectionSettingsModalConfig.json @@ -221,6 +221,16 @@ "key": "authMethod", "value": ["Azure Active Directory (MFA)"] } + }, + { + "inputLabel": "Application (client) ID", + "inputKeyword": "clientId", + "inputType": "text", + "inputTooltip": "Azure Active Directory application id from the Overview screen of the App registration", + "dependency": { + "key": "authMethod", + "value": "Azure Active Directory (Username / Password)" + } } ] }, From 325b8ef2089db6143f26d5648c2905e95a462df7 Mon Sep 17 00:00:00 2001 From: Nazar Kovtun Date: Fri, 18 Oct 2024 19:25:11 +0300 Subject: [PATCH 2/3] HCK-8467: added client id passing to connection --- reverse_engineering/databaseService/databaseService.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/reverse_engineering/databaseService/databaseService.js b/reverse_engineering/databaseService/databaseService.js index 2907bc0..fee7af4 100644 --- a/reverse_engineering/databaseService/databaseService.js +++ b/reverse_engineering/databaseService/databaseService.js @@ -50,6 +50,7 @@ const getConnectionClient = async (connectionInfo, logger) => { ? `${connectionInfo.userName}@${hostName}` : connectionInfo.userName; const tenantId = connectionInfo.connectionTenantId || connectionInfo.tenantId || 'common'; + const clientId = connectionInfo.clientId; const sslOptions = getSslConfig(connectionInfo); if (connectionInfo.authMethod === 'Username / Password') { @@ -127,6 +128,8 @@ const getConnectionClient = async (connectionInfo, logger) => { options: { userName: connectionInfo.userName, password: connectionInfo.userPassword, + domain: tenantId, + clientId, }, }, connectTimeout: Number(connectionInfo.queryRequestTimeout) || 60000, From bef47dc0cd40b75bde44894e7eae5d228d25663c Mon Sep 17 00:00:00 2001 From: Nazar Kovtun Date: Thu, 24 Oct 2024 17:11:44 +0300 Subject: [PATCH 3/3] HCK-8467: reused HCK app clientId for password auth flow --- .../connectionSettingsModalConfig.json | 10 ---------- reverse_engineering/databaseService/databaseService.js | 7 +++---- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/reverse_engineering/connection_settings_modal/connectionSettingsModalConfig.json b/reverse_engineering/connection_settings_modal/connectionSettingsModalConfig.json index 495bbac..3f0c28e 100644 --- a/reverse_engineering/connection_settings_modal/connectionSettingsModalConfig.json +++ b/reverse_engineering/connection_settings_modal/connectionSettingsModalConfig.json @@ -221,16 +221,6 @@ "key": "authMethod", "value": ["Azure Active Directory (MFA)"] } - }, - { - "inputLabel": "Application (client) ID", - "inputKeyword": "clientId", - "inputType": "text", - "inputTooltip": "Azure Active Directory application id from the Overview screen of the App registration", - "dependency": { - "key": "authMethod", - "value": "Azure Active Directory (Username / Password)" - } } ] }, diff --git a/reverse_engineering/databaseService/databaseService.js b/reverse_engineering/databaseService/databaseService.js index fee7af4..9dc7c2d 100644 --- a/reverse_engineering/databaseService/databaseService.js +++ b/reverse_engineering/databaseService/databaseService.js @@ -50,8 +50,9 @@ const getConnectionClient = async (connectionInfo, logger) => { ? `${connectionInfo.userName}@${hostName}` : connectionInfo.userName; const tenantId = connectionInfo.connectionTenantId || connectionInfo.tenantId || 'common'; - const clientId = connectionInfo.clientId; const sslOptions = getSslConfig(connectionInfo); + const clientId = '0dc36597-bc44-49f8-a4a7-ae5401959b85'; + const redirectUri = 'http://localhost:8080'; if (connectionInfo.authMethod === 'Username / Password') { return await sql.connect({ @@ -89,8 +90,6 @@ const getConnectionClient = async (connectionInfo, logger) => { requestTimeout: Number(connectionInfo.queryRequestTimeout) || 60000, }); } else if (connectionInfo.authMethod === 'Azure Active Directory (MFA)') { - const clientId = '0dc36597-bc44-49f8-a4a7-ae5401959b85'; - const redirectUri = 'http://localhost:8080'; const token = await getToken({ connectionInfo, tenantId, clientId, redirectUri, logger }); return await sql.connect({ @@ -128,7 +127,7 @@ const getConnectionClient = async (connectionInfo, logger) => { options: { userName: connectionInfo.userName, password: connectionInfo.userPassword, - domain: tenantId, + tenantId, clientId, }, },