fix(doris): honor MySQL TLS configuration
This commit is contained in:
1 parent
8e0b2ff496
commit
e6106072d5
4 files changed
+147
-8
No files matched your search
@@ -101,6 +101,7 @@ import { connectionAttemptOriginalErrorMessage, connectionAttemptTimeoutMessage,
|
|||||||
import { consulAgentAddressesMatch } from "@/lib/consul/agentTarget";
|
import { consulAgentAddressesMatch } from "@/lib/consul/agentTarget";
|
||||||
import { appendConnectionErrorHints, isJdbcMissingRuntimeDependencyError } from "@/lib/connection/connectionErrorHints";
|
import { appendConnectionErrorHints, isJdbcMissingRuntimeDependencyError } from "@/lib/connection/connectionErrorHints";
|
||||||
import { buildCassandraExternalConfig, cassandraTlsConfigFromExternalConfig, type CassandraTlsConfig } from "@/lib/connection/cassandraTlsOptions";
|
import { buildCassandraExternalConfig, cassandraTlsConfigFromExternalConfig, type CassandraTlsConfig } from "@/lib/connection/cassandraTlsOptions";
|
||||||
|
import { savedMysqlTlsFormFields, supportsMysqlTlsOptions as mysqlTlsOptionsSupported, supportsMysqlTlsTab } from "@/lib/connection/mysqlTlsCapabilities";
|
||||||
import { preventDialogDocumentSelectAll } from "@/lib/connection/dialogTextSelection";
|
import { preventDialogDocumentSelectAll } from "@/lib/connection/dialogTextSelection";
|
||||||
import { postgresLegacyTlsEnabled, postgresTlsModeForForm, setPostgresLegacyTlsEnabled } from "@/lib/connection/postgresTlsMode";
|
import { postgresLegacyTlsEnabled, postgresTlsModeForForm, setPostgresLegacyTlsEnabled } from "@/lib/connection/postgresTlsMode";
|
||||||
import { buildMqKafkaConnectionExtra, mqKafkaConnectionTarget, resolveMqKafkaConnectionSource, type MqKafkaConnectionSource } from "@/lib/connection/mqKafkaConnection";
|
import { buildMqKafkaConnectionExtra, mqKafkaConnectionTarget, resolveMqKafkaConnectionSource, type MqKafkaConnectionSource } from "@/lib/connection/mqKafkaConnection";
|
||||||
@@ -3066,7 +3067,7 @@ watch(
|
|||||||
db_type: oceanbasePatch?.db_type || profileConfig?.type || config.db_type,
|
db_type: oceanbasePatch?.db_type || profileConfig?.type || config.db_type,
|
||||||
driver_profile: config.db_type === "plugin" ? "plugin" : oceanbasePatch?.driver_profile || config.driver_profile || profile,
|
driver_profile: config.db_type === "plugin" ? "plugin" : oceanbasePatch?.driver_profile || config.driver_profile || profile,
|
||||||
driver_label: config.driver_label || oceanbasePatch?.driver_label || driverProfiles[profile]?.label || config.db_type,
|
driver_label: config.driver_label || oceanbasePatch?.driver_label || driverProfiles[profile]?.label || config.db_type,
|
||||||
url_params: config.url_params || "",
|
...savedMysqlTlsFormFields(config),
|
||||||
agent_java_options: config.agent_java_options || [],
|
agent_java_options: config.agent_java_options || [],
|
||||||
host: config.db_type === "h2" && h2FilePathFromJdbcUrl(config.connection_string) ? h2FilePathFromJdbcUrl(config.connection_string) : config.host,
|
host: config.db_type === "h2" && h2FilePathFromJdbcUrl(config.connection_string) ? h2FilePathFromJdbcUrl(config.connection_string) : config.host,
|
||||||
port: profile === "tdengine" && (config.port === 0 || config.port === 6030) ? 6041 : config.port,
|
port: profile === "tdengine" && (config.port === 0 || config.port === 6030) ? 6041 : config.port,
|
||||||
@@ -3083,10 +3084,6 @@ watch(
|
|||||||
query_timeout_inherit: config.query_timeout_inherit === true,
|
query_timeout_inherit: config.query_timeout_inherit === true,
|
||||||
idle_timeout_secs: config.idle_timeout_secs ?? 60,
|
idle_timeout_secs: config.idle_timeout_secs ?? 60,
|
||||||
keepalive_interval_secs: config.keepalive_interval_secs ?? 30,
|
keepalive_interval_secs: config.keepalive_interval_secs ?? 30,
|
||||||
ssl: config.ssl || false,
|
|
||||||
ca_cert_path: config.ca_cert_path || "",
|
|
||||||
client_cert_path: config.client_cert_path || "",
|
|
||||||
client_key_path: config.client_key_path || "",
|
|
||||||
sysdba: config.sysdba || isOracleSysUser(config),
|
sysdba: config.sysdba || isOracleSysUser(config),
|
||||||
oracle_connection_type: config.oracle_connection_type || "service_name",
|
oracle_connection_type: config.oracle_connection_type || "service_name",
|
||||||
connection_string: config.connection_string,
|
connection_string: config.connection_string,
|
||||||
@@ -3646,12 +3643,12 @@ const tlsCapableDatabaseTypes = new Set<DatabaseType>([
|
|||||||
"cassandra",
|
"cassandra",
|
||||||
"zookeeper",
|
"zookeeper",
|
||||||
]);
|
]);
|
||||||
const supportsTlsToggle = computed(() => tlsCapableDatabaseTypes.has(form.value.db_type));
|
const supportsTlsToggle = computed(() => tlsCapableDatabaseTypes.has(form.value.db_type) || supportsMysqlTlsTab(form.value.db_type, selectedType.value));
|
||||||
const supportsCaCertificatePath = computed(() => form.value.db_type === "clickhouse" || form.value.db_type === "victoriametrics");
|
const supportsCaCertificatePath = computed(() => form.value.db_type === "clickhouse" || form.value.db_type === "victoriametrics");
|
||||||
const supportsGenericUrlParams = computed(() => form.value.db_type !== "manticoresearch" && form.value.db_type !== "hbase");
|
const supportsGenericUrlParams = computed(() => form.value.db_type !== "manticoresearch" && form.value.db_type !== "hbase");
|
||||||
const showGenericUrlParamsHint = computed(() => form.value.db_type === "mysql" || form.value.db_type === "doris" || form.value.db_type === "starrocks");
|
const showGenericUrlParamsHint = computed(() => form.value.db_type === "mysql" || form.value.db_type === "doris" || form.value.db_type === "starrocks");
|
||||||
const bareMysqlProfiles = new Set(["doris", "selectdb", "oceanbase"]);
|
const bareMysqlProfiles = new Set(["doris", "selectdb", "oceanbase"]);
|
||||||
const supportsMysqlTlsOptions = computed(() => form.value.db_type === "starrocks" || (form.value.db_type === "mysql" && !bareMysqlProfiles.has(selectedType.value)));
|
const supportsMysqlTlsOptions = computed(() => mysqlTlsOptionsSupported(form.value.db_type, selectedType.value));
|
||||||
const supportsMysqlCleartextPasswordAuth = computed(() => form.value.db_type === "mysql" && !bareMysqlProfiles.has(selectedType.value));
|
const supportsMysqlCleartextPasswordAuth = computed(() => form.value.db_type === "mysql" && !bareMysqlProfiles.has(selectedType.value));
|
||||||
const supportsDoltSystemTables = computed(() => isDoltDriverProfile(form.value.driver_profile));
|
const supportsDoltSystemTables = computed(() => isDoltDriverProfile(form.value.driver_profile));
|
||||||
const showDoltSystemTables = computed({
|
const showDoltSystemTables = computed({
|
||||||
@@ -5027,6 +5024,7 @@ function connectionConfigForSubmit(id: string, generatedName = "", validatePlugi
|
|||||||
config.db_type !== "etcd" &&
|
config.db_type !== "etcd" &&
|
||||||
config.db_type !== "consul" &&
|
config.db_type !== "consul" &&
|
||||||
config.db_type !== "starrocks" &&
|
config.db_type !== "starrocks" &&
|
||||||
|
config.db_type !== "doris" &&
|
||||||
config.db_type !== "mongodb" &&
|
config.db_type !== "mongodb" &&
|
||||||
config.db_type !== "victoriametrics" &&
|
config.db_type !== "victoriametrics" &&
|
||||||
config.db_type !== "zookeeper" &&
|
config.db_type !== "zookeeper" &&
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import { describe, expect, it } from "vitest";
|
||||||
|
import { savedMysqlTlsFormFields, supportsMysqlTlsOptions, supportsMysqlTlsTab } from "../mysqlTlsCapabilities";
|
||||||
|
|
||||||
|
describe("supportsMysqlTlsOptions", () => {
|
||||||
|
it.each([
|
||||||
|
["doris", "doris"],
|
||||||
|
["starrocks", "starrocks"],
|
||||||
|
["mysql", "mysql"],
|
||||||
|
["mysql", "doris"],
|
||||||
|
["mysql", "starrocks"],
|
||||||
|
] as const)("makes the TLS tab and its MySQL controls reachable for %s/%s", (dbType, selectedType) => {
|
||||||
|
expect(supportsMysqlTlsTab(dbType, selectedType)).toBe(true);
|
||||||
|
expect(supportsMysqlTlsOptions(dbType, selectedType)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
["mysql", "selectdb"],
|
||||||
|
["mysql", "oceanbase"],
|
||||||
|
] as const)("does not expand TLS support to %s/%s", (dbType, selectedType) => {
|
||||||
|
expect(supportsMysqlTlsTab(dbType, selectedType)).toBe(false);
|
||||||
|
expect(supportsMysqlTlsOptions(dbType, selectedType)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
["native", "doris", "doris"],
|
||||||
|
["legacy", "mysql", "doris"],
|
||||||
|
] as const)("retains saved %s Doris TLS settings when the form reopens", (_kind, dbType, driverProfile) => {
|
||||||
|
const fields = savedMysqlTlsFormFields({
|
||||||
|
ssl: true,
|
||||||
|
url_params: "ssl-mode=verify_identity&verify_ca=true&verify_identity=true&ssl-cert=/tmp/client.pem&ssl-key=/tmp/client-key.pem",
|
||||||
|
ca_cert_path: "/tmp/doris-ca.pem",
|
||||||
|
client_cert_path: "/tmp/legacy-client.pem",
|
||||||
|
client_key_path: "/tmp/legacy-client-key.pem",
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(supportsMysqlTlsTab(dbType, driverProfile)).toBe(true);
|
||||||
|
expect(new URLSearchParams(fields.url_params).get("ssl-mode")).toBe("verify_identity");
|
||||||
|
expect(fields).toEqual({
|
||||||
|
ssl: true,
|
||||||
|
url_params: "ssl-mode=verify_identity&verify_ca=true&verify_identity=true&ssl-cert=/tmp/client.pem&ssl-key=/tmp/client-key.pem",
|
||||||
|
ca_cert_path: "/tmp/doris-ca.pem",
|
||||||
|
client_cert_path: "/tmp/legacy-client.pem",
|
||||||
|
client_key_path: "/tmp/legacy-client-key.pem",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import type { ConnectionConfig, DatabaseType } from "@/types/database";
|
||||||
|
|
||||||
|
const unsupportedBareMysqlTlsProfiles = new Set(["selectdb", "oceanbase"]);
|
||||||
|
|
||||||
|
export function supportsMysqlTlsOptions(dbType: DatabaseType, selectedType: string): boolean {
|
||||||
|
return dbType === "doris" || dbType === "starrocks" || (dbType === "mysql" && !unsupportedBareMysqlTlsProfiles.has(selectedType));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function supportsMysqlTlsTab(dbType: DatabaseType, selectedType: string): boolean {
|
||||||
|
return supportsMysqlTlsOptions(dbType, selectedType);
|
||||||
|
}
|
||||||
|
|
||||||
|
type SavedMysqlTlsFields = Pick<ConnectionConfig, "url_params" | "ssl" | "ca_cert_path" | "client_cert_path" | "client_key_path">;
|
||||||
|
|
||||||
|
export function savedMysqlTlsFormFields(config: SavedMysqlTlsFields): Required<SavedMysqlTlsFields> {
|
||||||
|
return {
|
||||||
|
url_params: config.url_params || "",
|
||||||
|
ssl: config.ssl || false,
|
||||||
|
ca_cert_path: config.ca_cert_path || "",
|
||||||
|
client_cert_path: config.client_cert_path || "",
|
||||||
|
client_key_path: config.client_key_path || "",
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -971,8 +971,14 @@ impl ConnectionConfig {
|
|||||||
|| self.driver_profile.as_deref().is_some_and(|profile| profile.eq_ignore_ascii_case("starrocks"))
|
|| self.driver_profile.as_deref().is_some_and(|profile| profile.eq_ignore_ascii_case("starrocks"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_doris(&self) -> bool {
|
||||||
|
self.db_type == DatabaseType::Doris
|
||||||
|
|| (self.db_type == DatabaseType::Mysql
|
||||||
|
&& self.driver_profile.as_deref().is_some_and(|profile| profile.eq_ignore_ascii_case("doris")))
|
||||||
|
}
|
||||||
|
|
||||||
pub fn bare_mysql_supports_tls(&self) -> bool {
|
pub fn bare_mysql_supports_tls(&self) -> bool {
|
||||||
self.is_starrocks()
|
self.is_doris() || self.is_starrocks()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bare_mysql_uses_tls(&self) -> bool {
|
pub fn bare_mysql_uses_tls(&self) -> bool {
|
||||||
@@ -3458,6 +3464,72 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn doris_database_type_preserves_mysql_tls_params_when_enabled() {
|
||||||
|
let mut config = mysql_config("root", "secret", Some("analytics"));
|
||||||
|
config.db_type = DatabaseType::Doris;
|
||||||
|
config.ssl = true;
|
||||||
|
config.ca_cert_path = "/tmp/doris-ca.pem".to_string();
|
||||||
|
config.url_params = Some("verify_ca=true&verify_identity=true".to_string());
|
||||||
|
|
||||||
|
assert!(config.bare_mysql_uses_tls());
|
||||||
|
assert_eq!(
|
||||||
|
config.connection_url(),
|
||||||
|
"mysql://root:secret@10.1.2.3:2883/analytics?require_ssl=true&verify_ca=true&verify_identity=true&charset=utf8mb4&enable_cleartext_plugin=true"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn legacy_doris_profile_preserves_mysql_tls_params_when_enabled() {
|
||||||
|
let mut config = mysql_config("root", "secret", Some("analytics"));
|
||||||
|
config.driver_profile = Some("doris".to_string());
|
||||||
|
config.ssl = true;
|
||||||
|
config.ca_cert_path = "/tmp/doris-ca.pem".to_string();
|
||||||
|
config.url_params = Some("verify_ca=true&verify_identity=false".to_string());
|
||||||
|
|
||||||
|
assert!(config.bare_mysql_uses_tls());
|
||||||
|
assert_eq!(
|
||||||
|
config.connection_url(),
|
||||||
|
"mysql://root:secret@10.1.2.3:2883/analytics?require_ssl=true&verify_ca=true&verify_identity=false&charset=utf8mb4&enable_cleartext_plugin=true"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn doris_explicit_disabled_mode_remains_plaintext() {
|
||||||
|
let mut config = mysql_config("root", "secret", Some("analytics"));
|
||||||
|
config.db_type = DatabaseType::Doris;
|
||||||
|
config.ssl = true;
|
||||||
|
config.url_params = Some("ssl-mode=disabled&verify_ca=true&verify_identity=true".to_string());
|
||||||
|
|
||||||
|
assert!(!config.bare_mysql_uses_tls());
|
||||||
|
assert_eq!(config.connection_url(), "mysql://root:secret@10.1.2.3:2883/analytics?enable_cleartext_plugin=true");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn selectdb_profile_does_not_gain_bare_mysql_tls_support() {
|
||||||
|
let mut config = mysql_config("root", "secret", Some("analytics"));
|
||||||
|
config.driver_profile = Some("selectdb".to_string());
|
||||||
|
config.ssl = true;
|
||||||
|
config.url_params = Some("require_ssl=true&verify_ca=true&verify_identity=true".to_string());
|
||||||
|
|
||||||
|
assert!(!config.bare_mysql_supports_tls());
|
||||||
|
assert!(!config.bare_mysql_uses_tls());
|
||||||
|
assert_eq!(config.connection_url(), "mysql://root:secret@10.1.2.3:2883/analytics?enable_cleartext_plugin=true");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn doris_profile_on_unrelated_database_type_does_not_gain_bare_mysql_tls_support() {
|
||||||
|
let mut config = mysql_config("root", "secret", Some("analytics"));
|
||||||
|
config.db_type = DatabaseType::Postgres;
|
||||||
|
config.driver_profile = Some("doris".to_string());
|
||||||
|
config.ssl = true;
|
||||||
|
config.url_params = Some("require_ssl=true&verify_ca=true&verify_identity=true".to_string());
|
||||||
|
|
||||||
|
assert!(!config.is_doris());
|
||||||
|
assert!(!config.bare_mysql_supports_tls());
|
||||||
|
assert!(!config.bare_mysql_uses_tls());
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn tdengine_profile_is_canonicalized_to_agent_database_type() {
|
fn tdengine_profile_is_canonicalized_to_agent_database_type() {
|
||||||
let mut config = mysql_config("root", "taosdata", Some("power"));
|
let mut config = mysql_config("root", "taosdata", Some("power"));
|
||||||
|
|||||||
Reference in new issue
Block a user