mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-14 12:08:36 -05:00
Support AD in cluster connection dialog (#7367)
- Use token API to get auth token before using other endpoints. Note this needs server updates before it'll work as expected (will only checkin after verifying this) - Add auth option in controller UI and plumb through connection save, load, and uses of the controller API Because the swagger spec is split in 2 created new file for the 2nd swagger spec including token auth endpoints. These come from a running cluster and instructions were updated to reflect this. New UI Changes: - Added authentication type field with "Basic" and "Windows Authentication" as the options - Moved error notifications to the dialog instead of separate notification window. That's the recommended pattern - Username / password aren't required for Windows Authentication. I couldn't find a way to change required status in form container on switching from Windows => Basic Auth so have error show on clicking OK. - Controller URL should use ":" not "," for IP:Port
This commit is contained in:
35
extensions/big-data-cluster/src/bigDataCluster/auth.ts
Normal file
35
extensions/big-data-cluster/src/bigDataCluster/auth.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as kerberos from 'kerberos';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
export async function authenticateKerberos(hostname: string): Promise<string> {
|
||||
const service = 'HTTP' + (process.platform === 'win32' ? '/' : '@') + hostname;
|
||||
const mechOID = kerberos.GSS_MECH_OID_KRB5;
|
||||
let client = await kerberos.initializeClient(service, { mechOID });
|
||||
let response = await client.step('');
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
export type HostAndIp = { host: string, port: string };
|
||||
|
||||
export function getHostAndPortFromEndpoint(endpoint: string): HostAndIp {
|
||||
let authority = vscode.Uri.parse(endpoint).authority;
|
||||
let hostAndPortRegex = /^(.*)([,:](\d+))/g;
|
||||
let match = hostAndPortRegex.exec(authority);
|
||||
if (match) {
|
||||
return {
|
||||
host: match[1],
|
||||
port: match[3]
|
||||
};
|
||||
}
|
||||
return {
|
||||
host: authority,
|
||||
port: undefined
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user