Re-add AD auth for SQL big data cluster (#6759)

* Revert "Revert "Initial AD support for BDCs (#6741)" as it breaks linux (#6758)"

This reverts commit 51660b25ef.

* Install kerberos package on linux
This commit is contained in:
Kevin Cunnane
2019-08-14 20:19:31 -07:00
committed by GitHub
parent 51660b25ef
commit fdac1d5382
32 changed files with 640 additions and 189 deletions

View File

@@ -16,6 +16,7 @@ import * as nls from 'vscode-nls';
import * as constants from '../constants';
import { WebHDFS, HdfsError } from './webhdfs';
import * as auth from '../util/auth';
const localize = nls.loadMessageBundle();
@@ -84,11 +85,13 @@ export interface IHdfsOptions {
export interface IRequestParams {
auth?: IHttpAuthentication;
isKerberos?: boolean;
/**
* Timeout in milliseconds to wait for response
*/
timeout?: number;
agent?: https.Agent;
headers?: {};
}
export interface IHdfsFileStatus {
@@ -106,10 +109,10 @@ export class FileSourceFactory {
return FileSourceFactory._instance;
}
public createHdfsFileSource(options: IHdfsOptions): IFileSource {
public async createHdfsFileSource(options: IHdfsOptions): Promise<IFileSource> {
options = options && options.host ? FileSourceFactory.removePortFromHost(options) : options;
let requestParams: IRequestParams = options.requestParams ? options.requestParams : {};
if (requestParams.auth) {
if (requestParams.auth || requestParams.isKerberos) {
// TODO Remove handling of unsigned cert once we have real certs in our Knox service
let agentOptions = {
host: options.host,
@@ -119,6 +122,11 @@ export class FileSourceFactory {
};
let agent = new https.Agent(agentOptions);
requestParams['agent'] = agent;
}
if (requestParams.isKerberos) {
let kerberosToken = await auth.authenticateKerberos(options.host);
requestParams.headers = { Authorization: `Negotiate ${kerberosToken}` };
}
return new HdfsFileSource(WebHDFS.createClient(options, requestParams));
}