From 4d6ec69ebabd72bc13d9c4791508a3640fb2a26a Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Tue, 2 Jun 2020 13:27:37 -0700 Subject: [PATCH] Fetch password from credential store before connecting to knox endpoint (#10666) * Fetch password from credential store before connecting to knox endpoint * Add combined code coverage script * Revert "Add combined code coverage script" This reverts commit e538f2fb2a79993a77f749f384fbc306b18b9f64. --- .../src/jupyter/jupyterSessionManager.ts | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/extensions/notebook/src/jupyter/jupyterSessionManager.ts b/extensions/notebook/src/jupyter/jupyterSessionManager.ts index 07e809485c..01b613c973 100644 --- a/extensions/notebook/src/jupyter/jupyterSessionManager.ts +++ b/extensions/notebook/src/jupyter/jupyterSessionManager.ts @@ -282,6 +282,10 @@ export class JupyterSession implements nb.ISession { // %_do_not_call_change_endpoint is a SparkMagic command that lets users change endpoint options, // such as user/profile/host name/auth type + let credentials; + if (!this.isIntegratedAuth(connectionProfile)) { + credentials = await connection.getCredentials(connectionProfile.id); + } //Update server info with bigdata endpoint - Unified Connection if (connectionProfile.providerName === SQL_PROVIDER) { const endpoints = await this.getClusterEndpoints(connectionProfile.id); @@ -296,16 +300,16 @@ export class JupyterSession implements nb.ISession { // as a default now we'll still fall back to root if it's empty for some reason. (but the calls below should // get the actual correct value regardless) connectionProfile.options[USER] = connectionProfile.userName || 'root'; - - try { - const bdcApi = await vscode.extensions.getExtension(bdc.constants.extensionName).activate(); - const controllerEndpoint = endpoints.find(ep => ep.serviceName.toLowerCase() === CONTROLLER_ENDPOINT); - const controller = bdcApi.getClusterController(controllerEndpoint.endpoint, 'basic', connectionProfile.userName, connectionProfile.password); - connectionProfile.options[USER] = await controller.getKnoxUsername(connectionProfile.userName); - } catch (err) { - console.log(`Unexpected error getting Knox username for Spark kernel: ${err}`); + if (!this.isIntegratedAuth(connectionProfile)) { + try { + const bdcApi = await vscode.extensions.getExtension(bdc.constants.extensionName).activate(); + const controllerEndpoint = endpoints.find(ep => ep.serviceName.toLowerCase() === CONTROLLER_ENDPOINT); + const controller = bdcApi.getClusterController(controllerEndpoint.endpoint, 'basic', connectionProfile.userName, credentials.password); + connectionProfile.options[USER] = await controller.getKnoxUsername(connectionProfile.userName); + } catch (err) { + console.log(`Unexpected error getting Knox username for Spark kernel: ${err}`); + } } - } else { connectionProfile.options[KNOX_ENDPOINT_PORT] = this.getKnoxPortOrDefault(connectionProfile); @@ -318,7 +322,7 @@ export class JupyterSession implements nb.ISession { if (this.isIntegratedAuth(connectionProfile)) { doNotCallChangeEndpointParams = `%_do_not_call_change_endpoint --server=${server} --auth=Kerberos`; } else { - const credentials = await connection.getCredentials(connectionProfile.id); + doNotCallChangeEndpointParams = `%_do_not_call_change_endpoint --username=${connectionProfile.options[USER]} --password=${credentials.password} --server=${server} --auth=Basic_Access`; } let future = this.sessionImpl.kernel.requestExecute({