diff --git a/backend/src/ee/services/secret-rotation-v2/mssql-credentials/mssql-credentials-rotation-constants.ts b/backend/src/ee/services/secret-rotation-v2/mssql-credentials/mssql-credentials-rotation-constants.ts
index 670c98997..b256bd77f 100644
--- a/backend/src/ee/services/secret-rotation-v2/mssql-credentials/mssql-credentials-rotation-constants.ts
+++ b/backend/src/ee/services/secret-rotation-v2/mssql-credentials/mssql-credentials-rotation-constants.ts
@@ -7,7 +7,20 @@ export const MSSQL_CREDENTIALS_ROTATION_LIST_OPTION: TSecretRotationV2ListItem =
type: SecretRotation.MsSqlCredentials,
connection: AppConnection.MsSql,
template: {
- createUserStatement: `CREATE LOGIN [my_mssql_user] WITH PASSWORD = 'my_temporary_password'; CREATE USER [my_mssql_user] FOR LOGIN [my_mssql_user]; GRANT SELECT, INSERT, UPDATE, DELETE ON SCHEMA::dbo TO [my_mssql_user];`,
+ createUserStatement: `-- Create login at the server level
+CREATE LOGIN [infisical_user] WITH PASSWORD = 'my-password';
+
+-- Grant server-level connect permission
+GRANT CONNECT SQL TO [infisical_user];
+
+-- Switch to the database where you want to create the user
+USE my_database;
+
+-- Create the database user mapped to the login
+CREATE USER [infisical_user] FOR LOGIN [infisical_user];
+
+-- Grant permissions to the user on the schema in this database
+GRANT SELECT, INSERT, UPDATE, DELETE ON SCHEMA::dbo TO [infisical_user];`,
secretsMapping: {
username: "MSSQL_DB_USERNAME",
password: "MSSQL_DB_PASSWORD"
diff --git a/backend/src/ee/services/secret-rotation-v2/postgres-credentials/postgres-credentials-rotation-constants.ts b/backend/src/ee/services/secret-rotation-v2/postgres-credentials/postgres-credentials-rotation-constants.ts
index 68a31e8c9..395ed46d1 100644
--- a/backend/src/ee/services/secret-rotation-v2/postgres-credentials/postgres-credentials-rotation-constants.ts
+++ b/backend/src/ee/services/secret-rotation-v2/postgres-credentials/postgres-credentials-rotation-constants.ts
@@ -7,7 +7,14 @@ export const POSTGRES_CREDENTIALS_ROTATION_LIST_OPTION: TSecretRotationV2ListIte
type: SecretRotation.PostgresCredentials,
connection: AppConnection.Postgres,
template: {
- createUserStatement: `CREATE USER "my_pg_user" WITH ENCRYPTED PASSWORD 'temporary_password'; GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO "my_pg_user";`,
+ createUserStatement: `-- create user role
+CREATE USER infisical_user WITH ENCRYPTED PASSWORD 'temporary_password';
+
+-- grant database connection permissions
+GRANT CONNECT ON DATABASE my_database TO infisical_user;
+
+-- grant relevant table permissions
+GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO infisical_user;`,
secretsMapping: {
username: "POSTGRES_DB_USERNAME",
password: "POSTGRES_DB_PASSWORD"
diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.ts
index 7fa6e6df7..ea5c07789 100644
--- a/backend/src/lib/api-docs/constants.ts
+++ b/backend/src/lib/api-docs/constants.ts
@@ -1691,6 +1691,8 @@ export const AppConnections = {
database: "The name of the database to connect to.",
username: "The username to connect to the database with.",
password: "The password to connect to the database with.",
+ sslEnabled: "Whether or not to use SSL when connecting to the database.",
+ sslRejectUnauthorized: "Whether or not to reject unauthorized SSL certificates.",
sslCertificate: "The SSL certificate to use for connection."
}
}
diff --git a/backend/src/lib/config/env.ts b/backend/src/lib/config/env.ts
index f43b0b443..0906e5269 100644
--- a/backend/src/lib/config/env.ts
+++ b/backend/src/lib/config/env.ts
@@ -59,8 +59,6 @@ const envSchema = z
QUEUE_WORKERS_ENABLED: zodStrBool.default("true"),
HTTPS_ENABLED: zodStrBool,
ROTATION_DEVELOPMENT_MODE: zodStrBool.default("false").optional(),
- DB_SSL_REJECT_UNAUTHORIZED: zodStrBool.default("true"),
- DB_SSL_REQUIRED: zodStrBool.default("true"),
// smtp options
SMTP_HOST: zpStr(z.string().optional()),
SMTP_IGNORE_TLS: zodStrBool.default("false"),
diff --git a/backend/src/services/app-connection/mssql/mssql-connection-schemas.ts b/backend/src/services/app-connection/mssql/mssql-connection-schemas.ts
index 1b659b658..38ef0eef6 100644
--- a/backend/src/services/app-connection/mssql/mssql-connection-schemas.ts
+++ b/backend/src/services/app-connection/mssql/mssql-connection-schemas.ts
@@ -29,7 +29,9 @@ export const SanitizedMsSqlConnectionSchema = z.discriminatedUnion("method", [
host: true,
database: true,
port: true,
- username: true
+ username: true,
+ sslEnabled: true,
+ sslRejectUnauthorized: true
})
})
]);
diff --git a/backend/src/services/app-connection/postgres/postgres-connection-schemas.ts b/backend/src/services/app-connection/postgres/postgres-connection-schemas.ts
index 3867ea8bf..510f7b7d0 100644
--- a/backend/src/services/app-connection/postgres/postgres-connection-schemas.ts
+++ b/backend/src/services/app-connection/postgres/postgres-connection-schemas.ts
@@ -27,7 +27,9 @@ export const SanitizedPostgresConnectionSchema = z.discriminatedUnion("method",
host: true,
database: true,
port: true,
- username: true
+ username: true,
+ sslEnabled: true,
+ sslRejectUnauthorized: true
})
})
]);
diff --git a/backend/src/services/app-connection/shared/sql/sql-connection-fns.ts b/backend/src/services/app-connection/shared/sql/sql-connection-fns.ts
index 4a6f2b05f..ed1d99941 100644
--- a/backend/src/services/app-connection/shared/sql/sql-connection-fns.ts
+++ b/backend/src/services/app-connection/shared/sql/sql-connection-fns.ts
@@ -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
-
+{rotationOption!.template.createUserStatement}diff --git a/frontend/src/hooks/api/appConnections/types/shared/sql-connection.ts b/frontend/src/hooks/api/appConnections/types/shared/sql-connection.ts index 79a14b520..d0e71158e 100644 --- a/frontend/src/hooks/api/appConnections/types/shared/sql-connection.ts +++ b/frontend/src/hooks/api/appConnections/types/shared/sql-connection.ts @@ -4,4 +4,6 @@ export type TBaseSqlConnectionCredentials = { username: string; password: string; database: string; + sslEnabled: boolean; + sslRejectUnauthorized: boolean; }; diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AwsConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AwsConnectionForm.tsx index d1137a887..1731cceef 100644 --- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AwsConnectionForm.tsx +++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AwsConnectionForm.tsx @@ -22,7 +22,7 @@ import { type Props = { appConnection?: TAwsConnection; - onSubmit: (formData: FormData) => void; + onSubmit: (formData: FormData) => Promise; }; const rootSchema = genericAppConnectionFieldsSchema.extend({ diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/DatabricksConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/DatabricksConnectionForm.tsx index 997609d1b..f5f531b4c 100644 --- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/DatabricksConnectionForm.tsx +++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/DatabricksConnectionForm.tsx @@ -25,7 +25,7 @@ import { type Props = { appConnection?: TDatabricksConnection; - onSubmit: (formData: FormData) => void; + onSubmit: (formData: FormData) => Promise ; }; const rootSchema = genericAppConnectionFieldsSchema.extend({ diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/GcpConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/GcpConnectionForm.tsx index 26160fe17..8d639111b 100644 --- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/GcpConnectionForm.tsx +++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/GcpConnectionForm.tsx @@ -28,7 +28,7 @@ import { type Props = { appConnection?: TGcpConnection; - onSubmit: (formData: FormData) => void; + onSubmit: (formData: FormData) => Promise ; }; const rootSchema = genericAppConnectionFieldsSchema.extend({ diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/HumanitecConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/HumanitecConnectionForm.tsx index b9a41f25c..39785c99b 100644 --- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/HumanitecConnectionForm.tsx +++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/HumanitecConnectionForm.tsx @@ -21,7 +21,7 @@ import { type Props = { appConnection?: THumanitecConnection; - onSubmit: (formData: FormData) => void; + onSubmit: (formData: FormData) => Promise ; }; const rootSchema = genericAppConnectionFieldsSchema.extend({ diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/MsSqlConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/MsSqlConnectionForm.tsx index bcea2f3bc..fecac3d3e 100644 --- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/MsSqlConnectionForm.tsx +++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/MsSqlConnectionForm.tsx @@ -24,7 +24,7 @@ import { type Props = { appConnection?: TMsSqlConnection; - onSubmit: (formData: FormData) => void; + onSubmit: (formData: FormData) => Promise ; }; const rootSchema = genericAppConnectionFieldsSchema.extend({ @@ -44,6 +44,7 @@ type FormData = z.infer ; export const MsSqlConnectionForm = ({ appConnection, onSubmit }: Props) => { const isUpdate = Boolean(appConnection); const [showConfirmation, setShowConfirmation] = useState(false); + const [selectedTabIndex, setSelectedTabIndex] = useState(0); const form = useForm ({ resolver: zodResolver(formSchema), @@ -56,7 +57,9 @@ export const MsSqlConnectionForm = ({ appConnection, onSubmit }: Props) => { database: "default", username: "", password: "", - sslCertificate: "" + sslEnabled: true, + sslRejectUnauthorized: true, + sslCertificate: undefined } } }); @@ -69,18 +72,23 @@ export const MsSqlConnectionForm = ({ appConnection, onSubmit }: Props) => { const isPlatformManagedCredentials = appConnection?.isPlatformManagedCredentials ?? false; - const confirmSubmit = (formData: FormData) => { + const confirmSubmit = async (formData: FormData) => { if (formData.isPlatformManagedCredentials) { setShowConfirmation(true); return; } - onSubmit(formData); + await onSubmit(formData); }; return ( -