mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-15 15:41:27 +00:00
improvements: add ssl options to sql connections and update ui/docs
This commit is contained in:
@@ -29,7 +29,9 @@ export const SanitizedMsSqlConnectionSchema = z.discriminatedUnion("method", [
|
||||
host: true,
|
||||
database: true,
|
||||
port: true,
|
||||
username: true
|
||||
username: true,
|
||||
sslEnabled: true,
|
||||
sslRejectUnauthorized: true
|
||||
})
|
||||
})
|
||||
]);
|
||||
|
||||
@@ -27,7 +27,9 @@ export const SanitizedPostgresConnectionSchema = z.discriminatedUnion("method",
|
||||
host: true,
|
||||
database: true,
|
||||
port: true,
|
||||
username: true
|
||||
username: true,
|
||||
sslEnabled: true,
|
||||
sslRejectUnauthorized: true
|
||||
})
|
||||
})
|
||||
]);
|
||||
|
||||
@@ -5,7 +5,6 @@ import {
|
||||
TSqlCredentialsRotationGeneratedCredentials,
|
||||
TSqlCredentialsRotationWithConnection
|
||||
} from "@app/ee/services/secret-rotation-v2/shared/sql-credentials/sql-credentials-rotation-types";
|
||||
import { getConfig } from "@app/lib/config/env";
|
||||
import { BadRequestError, DatabaseError } from "@app/lib/errors";
|
||||
import { alphaNumericNanoId } from "@app/lib/nanoid";
|
||||
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
|
||||
@@ -21,16 +20,14 @@ const SQL_CONNECTION_CLIENT_MAP = {
|
||||
|
||||
const getConnectionConfig = ({
|
||||
app,
|
||||
credentials: { sslCertificate, host }
|
||||
credentials: { host, sslCertificate, sslEnabled, sslRejectUnauthorized }
|
||||
}: Pick<TSqlConnection, "credentials" | "app">) => {
|
||||
const appCfg = getConfig();
|
||||
|
||||
switch (app) {
|
||||
case AppConnection.Postgres: {
|
||||
return {
|
||||
ssl: appCfg.DB_SSL_REQUIRED
|
||||
ssl: sslEnabled
|
||||
? {
|
||||
rejectUnauthorized: appCfg.DB_SSL_REJECT_UNAUTHORIZED,
|
||||
rejectUnauthorized: sslRejectUnauthorized,
|
||||
ca: sslCertificate,
|
||||
servername: host
|
||||
}
|
||||
@@ -39,13 +36,13 @@ const getConnectionConfig = ({
|
||||
}
|
||||
case AppConnection.MsSql: {
|
||||
return {
|
||||
options: appCfg.DB_SSL_REQUIRED
|
||||
options: sslEnabled
|
||||
? {
|
||||
trustServerCertificate: !appCfg.DB_SSL_REJECT_UNAUTHORIZED,
|
||||
trustServerCertificate: !sslRejectUnauthorized,
|
||||
encrypt: true,
|
||||
cryptoCredentialsDetails: sslCertificate ? { ca: sslCertificate } : {}
|
||||
}
|
||||
: undefined
|
||||
: { encrypt: false }
|
||||
};
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -8,5 +8,12 @@ export const BaseSqlUsernameAndPasswordConnectionSchema = z.object({
|
||||
database: z.string().trim().min(1, "Database required").describe(AppConnections.CREDENTIALS.SQL_CONNECTION.database),
|
||||
username: z.string().trim().min(1, "Username required").describe(AppConnections.CREDENTIALS.SQL_CONNECTION.username),
|
||||
password: z.string().trim().min(1, "Password required").describe(AppConnections.CREDENTIALS.SQL_CONNECTION.password),
|
||||
sslCertificate: z.string().trim().optional().describe(AppConnections.CREDENTIALS.SQL_CONNECTION.sslCertificate)
|
||||
sslEnabled: z.boolean().describe(AppConnections.CREDENTIALS.SQL_CONNECTION.sslEnabled),
|
||||
sslRejectUnauthorized: z.boolean().describe(AppConnections.CREDENTIALS.SQL_CONNECTION.sslRejectUnauthorized),
|
||||
sslCertificate: z
|
||||
.string()
|
||||
.trim()
|
||||
.transform((value) => value || undefined)
|
||||
.optional()
|
||||
.describe(AppConnections.CREDENTIALS.SQL_CONNECTION.sslCertificate)
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user