mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Allow non-admin BDC connections to see BDC features (#12663)
* Add handling for non-admin BDC users * Bump STS * Fix HDFS root node commands * remove nested awaits * colon
This commit is contained in:
20
extensions/big-data-cluster/src/bdc.d.ts
vendored
20
extensions/big-data-cluster/src/bdc.d.ts
vendored
@@ -8,10 +8,30 @@ declare module 'bdc' {
|
||||
getClusterController(url: string, authType: AuthType, username?: string, password?: string): IClusterController;
|
||||
}
|
||||
|
||||
export interface IEndpointModel {
|
||||
name?: string;
|
||||
description?: string;
|
||||
endpoint?: string;
|
||||
protocol?: string;
|
||||
}
|
||||
|
||||
export interface IHttpResponse {
|
||||
method?: string;
|
||||
url?: string;
|
||||
statusCode?: number;
|
||||
statusMessage?: string;
|
||||
}
|
||||
|
||||
export interface IEndPointsResponse {
|
||||
response: IHttpResponse;
|
||||
endPoints: IEndpointModel[];
|
||||
}
|
||||
|
||||
export type AuthType = 'integrated' | 'basic';
|
||||
|
||||
export interface IClusterController {
|
||||
getClusterConfig(): Promise<any>;
|
||||
getKnoxUsername(clusterUsername: string): Promise<string>;
|
||||
getEndPoints(promptConnect?: boolean): Promise<IEndPointsResponse>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
import localVarRequest = require('request');
|
||||
import http = require('http');
|
||||
import * as bdc from 'bdc';
|
||||
|
||||
let defaultBasePath = 'https://localhost';
|
||||
|
||||
@@ -203,7 +204,7 @@ export class Dashboards {
|
||||
}
|
||||
}
|
||||
|
||||
export class EndpointModel {
|
||||
export class EndpointModel implements bdc.IEndpointModel {
|
||||
'name'?: string;
|
||||
'description'?: string;
|
||||
'endpoint'?: string;
|
||||
|
||||
@@ -10,7 +10,7 @@ import { TokenRouterApi } from './clusterApiGenerated2';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { ConnectControllerDialog, ConnectControllerModel } from '../dialog/connectControllerDialog';
|
||||
import { getIgnoreSslVerificationConfigSetting } from '../utils';
|
||||
import { IClusterController, AuthType } from 'bdc';
|
||||
import { IClusterController, AuthType, IEndPointsResponse, IHttpResponse } from 'bdc';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
@@ -174,24 +174,17 @@ export class ClusterController implements IClusterController {
|
||||
}
|
||||
|
||||
public async getKnoxUsername(sqlLogin: string): Promise<string> {
|
||||
try {
|
||||
// This all is necessary because prior to CU5 BDC deployments all had the same default username for
|
||||
// accessing the Knox gateway. But in the allowRunAsRoot setting was added and defaulted to false - so
|
||||
// if that exists and is false then we use the username instead.
|
||||
// Note that the SQL username may not necessarily be correct here either - but currently this is what
|
||||
// we're requiring to run Notebooks in a BDC
|
||||
const config = await this.getClusterConfig();
|
||||
return config.spec?.spec?.security?.allowRunAsRoot === false ? sqlLogin : DEFAULT_KNOX_USERNAME;
|
||||
} catch (err) {
|
||||
console.log(`Unexpected error fetching cluster config for getKnoxUsername ${err}`);
|
||||
// Optimistically fall back to SQL login since root shouldn't be typically used going forward
|
||||
return sqlLogin;
|
||||
}
|
||||
|
||||
// This all is necessary because prior to CU5 BDC deployments all had the same default username for
|
||||
// accessing the Knox gateway. But in the allowRunAsRoot setting was added and defaulted to false - so
|
||||
// if that exists and is false then we use the username instead.
|
||||
// Note that the SQL username may not necessarily be correct here either - but currently this is what
|
||||
// we're requiring to run Notebooks in a BDC
|
||||
const config = await this.getClusterConfig();
|
||||
return config.spec?.spec?.security?.allowRunAsRoot === false ? sqlLogin : DEFAULT_KNOX_USERNAME;
|
||||
}
|
||||
|
||||
public async getClusterConfig(promptConnect: boolean = false): Promise<any> {
|
||||
return await this.withConnectRetry<IEndPointsResponse>(
|
||||
return await this.withConnectRetry<any>(
|
||||
this.getClusterConfigImpl,
|
||||
promptConnect,
|
||||
localize('bdc.error.getClusterConfig', "Error retrieving cluster config from {0}", this._url));
|
||||
@@ -387,11 +380,6 @@ export interface IClusterRequest {
|
||||
method?: string;
|
||||
}
|
||||
|
||||
export interface IEndPointsResponse {
|
||||
response: IHttpResponse;
|
||||
endPoints: EndpointModel[];
|
||||
}
|
||||
|
||||
export interface IBdcStatusResponse {
|
||||
response: IHttpResponse;
|
||||
bdcStatus: BdcStatusModel;
|
||||
@@ -419,13 +407,6 @@ export interface MountStatusResponse {
|
||||
mount: MountInfo[];
|
||||
}
|
||||
|
||||
export interface IHttpResponse {
|
||||
method?: string;
|
||||
url?: string;
|
||||
statusCode?: number;
|
||||
statusMessage?: string;
|
||||
}
|
||||
|
||||
export class ControllerError extends Error {
|
||||
public code?: number;
|
||||
public reason?: string;
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import { ClusterController, ControllerError, IEndPointsResponse } from '../controller/clusterControllerApi';
|
||||
import { ClusterController, ControllerError } from '../controller/clusterControllerApi';
|
||||
import { Deferred } from '../../common/promise';
|
||||
import * as loc from '../localizedConstants';
|
||||
import { AuthType } from 'bdc';
|
||||
import { AuthType, IEndPointsResponse } from 'bdc';
|
||||
|
||||
function getAuthCategory(name: AuthType): azdata.CategoryValue {
|
||||
if (name === 'basic') {
|
||||
|
||||
Reference in New Issue
Block a user