Skip to content

Commit 19e2fdd

Browse files
authored
Revert "feat(auth): Add Kerberos support for Trino/Presto (growthbook#4850)" (growthbook#4911)
This reverts commit c2aa785.
1 parent 099639d commit 19e2fdd

11 files changed

Lines changed: 152 additions & 251 deletions

File tree

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ FROM python:${PYTHON_MAJOR}-slim
6161
ARG NODE_MAJOR
6262
WORKDIR /usr/local/src/app
6363
RUN apt-get update && \
64-
apt-get install -y wget gnupg2 build-essential ca-certificates libkrb5-dev && \
64+
apt-get install -y wget gnupg2 build-essential ca-certificates && \
6565
mkdir -p /etc/apt/keyrings && \
6666
wget -qO- https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
6767
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x buster main" > /etc/apt/sources.list.d/nodesource.list && \

packages/back-end/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
"@stdlib/random": "^0.1.1",
5353
"@stdlib/stats": "^0.1.1",
5454
"@types/handlebars": "^4.1.0",
55-
"@types/presto-client": "^1.0.2",
5655
"agenda": "^5.0.0",
5756
"asn1.js": "^5.4.1",
5857
"async": "^3.1.0",
@@ -81,7 +80,6 @@
8180
"json5": "^2.2.3",
8281
"jsonwebtoken": "^8.5.1",
8382
"jwks-rsa": "^1.8.0",
84-
"kerberos": "^2.1.1",
8583
"lodash": "^4.17.21",
8684
"md5": "^2.3.0",
8785
"module-alias": "^2.2.3",
@@ -131,7 +129,6 @@
131129
"@types/jest": "^27.0.1",
132130
"@types/js-yaml": "^4.0.2",
133131
"@types/jsonwebtoken": "^8.5.1",
134-
"@types/kerberos": "^1.1.5",
135132
"@types/lodash": "^4.14.157",
136133
"@types/md5": "^2.2.0",
137134
"@types/module-alias": "^2.0.4",

packages/back-end/src/controllers/datasources.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ export async function postDataSources(
259259
datasource: getDataSourceWithParams(integration),
260260
});
261261
} catch (e) {
262-
req.log.error(e, "Failed to create data source");
263262
res.status(400).json({
264263
status: 400,
265264
message: e.message || "An error occurred",

packages/back-end/src/integrations/Presto.ts

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Client, ClientOptions, QueryOptions } from "presto-client";
1+
/// <reference types="../../typings/presto-client" />
2+
import { Client, IPrestoClientOptions } from "presto-client";
23
import { format } from "shared/sql";
34
import { FormatDialect } from "shared/src/types";
45
import { prestoCreateTablePartitions } from "shared/enterprise";
@@ -10,7 +11,6 @@ import {
1011
MaxTimestampIncrementalUnitsQueryParams,
1112
MaxTimestampMetricSourceQueryParams,
1213
} from "back-end/src/types/Integration";
13-
import { getKerberosHeader } from "../util/kerberos.util";
1414
import SqlIntegration from "./SqlIntegration";
1515

1616
// eslint-disable-next-line
@@ -36,8 +36,7 @@ export default class Presto extends SqlIntegration {
3636
return true;
3737
}
3838
runQuery(sql: string): Promise<QueryResponse> {
39-
const configOptions: ClientOptions = {
40-
engine: this.params.engine,
39+
const configOptions: IPrestoClientOptions = {
4140
host: this.params.host,
4241
port: this.params.port,
4342
user: "growthbook",
@@ -56,18 +55,6 @@ export default class Presto extends SqlIntegration {
5655
if (this.params?.authType === "customAuth") {
5756
configOptions.custom_auth = this.params.customAuth || "";
5857
}
59-
if (this.params?.authType === "kerberos") {
60-
const servicePrincipal = this.params.kerberosServicePrincipal;
61-
const clientPrincipal = this.params.kerberosClientPrincipal;
62-
if (!servicePrincipal) {
63-
throw new Error(
64-
"Kerberos service principal is required for Kerberos authentication",
65-
);
66-
}
67-
// Use a function to generate fresh Kerberos tokens for each request
68-
configOptions.custom_auth = () =>
69-
getKerberosHeader(servicePrincipal, clientPrincipal);
70-
}
7158
if (this.params?.ssl) {
7259
configOptions.ssl = {
7360
ca: this.params?.caCert,
@@ -83,7 +70,7 @@ export default class Presto extends SqlIntegration {
8370
const rows: Row[] = [];
8471
const statistics: QueryStatistics = {};
8572

86-
const executeOptions: QueryOptions = {
73+
client.execute({
8774
query: sql,
8875
catalog: this.params.catalog,
8976
schema: this.params.schema,
@@ -110,7 +97,6 @@ export default class Presto extends SqlIntegration {
11097
statistics.bytesProcessed = Number(stats.processedBytes);
11198
statistics.rowsProcessed = Number(stats.processedRows);
11299
statistics.physicalWrittenBytes = Number(
113-
// @ts-expect-error - From our testing this does exist but types are not happy
114100
stats.physicalWrittenBytes,
115101
);
116102
}
@@ -124,15 +110,7 @@ export default class Presto extends SqlIntegration {
124110
statistics,
125111
});
126112
},
127-
};
128-
129-
// For Kerberos auth we need to explicitly set user
130-
// which sets X-Trino-User header and is required by Trino
131-
if (this.params?.authType === "kerberos") {
132-
executeOptions.user = this.params.kerberosUser || "growthbook";
133-
}
134-
135-
client.execute(executeOptions);
113+
});
136114
});
137115
}
138116
addTime(

packages/back-end/src/util/kerberos.util.ts

Lines changed: 0 additions & 53 deletions
This file was deleted.

packages/back-end/types/integrations/presto.d.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
export interface PrestoConnectionParams {
2-
authType?: "basicAuth" | "none" | "customAuth" | "kerberos";
2+
authType?: "basicAuth" | "none" | "customAuth";
33
engine: "presto" | "trino";
44
host: string;
55
port: number;
66
username?: string;
77
password?: string;
88
customAuth?: string;
9-
kerberosServicePrincipal?: string;
10-
kerberosClientPrincipal?: string;
11-
kerberosUser?: string;
129
source?: string;
1310
catalog: string;
1411
schema: string;
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
/* eslint-disable */
2+
declare module "presto-client" {
3+
interface IPrestoClientOptions {
4+
host: string;
5+
ssl?: {
6+
ca?: string;
7+
cert: string;
8+
ciphers?: string;
9+
key?: string;
10+
passphrase?: string;
11+
secureProtocol: string;
12+
pfx?: string;
13+
rejectUnauthorized?: boolean;
14+
servername?: string;
15+
};
16+
port: number;
17+
source: string;
18+
user: string;
19+
catalog: string;
20+
checkInterval: number;
21+
basic_auth?: {
22+
user: string;
23+
password: string;
24+
};
25+
custom_auth?: string;
26+
schema?: string;
27+
enableVerboseStateCallback?: boolean;
28+
jsonParser?: {
29+
parse: (data: any) => any;
30+
};
31+
engine?: string;
32+
timeout?: number;
33+
}
34+
35+
enum PrestoClientQueryStates {
36+
WAITING_FOR_PREREQUISITES = "WAITING_FOR_PREREQUISITES",
37+
QUEUED = "QUEUED",
38+
WAITING_FOR_RESOURCES = "WAITING_FOR_RESOURCES",
39+
DISPATCHING = "DISPATCHING",
40+
PLANNING = "PLANNING",
41+
STARTING = "STARTING",
42+
RUNNING = "RUNNING",
43+
FINISHING = "FINISHING",
44+
FINISHED = "FINISHED",
45+
CANCELED = "CANCELED",
46+
FAILED = "FAILED",
47+
}
48+
49+
interface IPrestoClientStats {
50+
processedBytes: number;
51+
processedRows: number;
52+
wallTimeMillis: number;
53+
cpuTimeMillis: number;
54+
userTimeMillis: number;
55+
physicalWrittenBytes: number;
56+
state: PrestoClientQueryStates;
57+
scheduled: boolean;
58+
nodes: number;
59+
totalSplits: number;
60+
queuedSplits: number;
61+
runningSplits: number;
62+
completedSplits: number;
63+
}
64+
65+
// NOTE: Needs to be extended with missing items
66+
enum PrestoClientPrestoTypes {
67+
varchar = "varchar",
68+
bigint = "bigint",
69+
boolean = "boolean",
70+
char = "char",
71+
date = "date",
72+
decimal = "decimal",
73+
double = "double",
74+
}
75+
76+
interface IPrestoClientColumnMetaData {
77+
name: string;
78+
type: PrestoClientPrestoTypes;
79+
}
80+
81+
type PrestoClientColumnDatum = [string, any];
82+
83+
interface IPrestoClientExecuteOptions {
84+
query: string;
85+
catalog: string;
86+
schema: string;
87+
timezone?: string;
88+
user?: string;
89+
prepares?: string[];
90+
timeout?: null | number;
91+
info?: boolean;
92+
cancel?: () => boolean;
93+
state?: (error: any, query_id: string, stats: IPrestoClientStats) => void;
94+
columns?: (error: any, data: IPrestoClientColumnMetaData[]) => void;
95+
data?: (
96+
error: any,
97+
data: PrestoClientColumnDatum[],
98+
columns: IPrestoClientColumnMetaData[],
99+
stats: IPrestoClientStats,
100+
) => void;
101+
success?: (error: any, stats: IPrestoClientStats) => void;
102+
error?: (error: any) => void;
103+
callback?: (error: any, stats: IPrestoClientStats) => void;
104+
}
105+
106+
class Client {
107+
constructor(options: IPrestoClientOptions);
108+
public execute(options: IPrestoClientExecuteOptions): void;
109+
public query(
110+
query_id: string,
111+
callback: (error: any, data?: any) => void,
112+
): void;
113+
public kill(query_id: string, callback: (error: any) => void): void;
114+
public nodes(
115+
opts: null | undefined | {},
116+
callback: (error: any, data: {}[]) => void,
117+
): void;
118+
}
119+
}

0 commit comments

Comments
 (0)