Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

Merge remote-tracking branch 'origin/main' into fix/address-azure-sql-server-dynamic-secret-integration

Sheen Capadngan7806bf402580
diff --cc backend/src/ee/services/dynamic-secret/providers/sql-database.ts
index 562aa58f2b,e68e41c6be..e2b89ac04e
--- a/backend/src/ee/services/dynamic-secret/providers/sql-database.ts
+++ b/backend/src/ee/services/dynamic-secret/providers/sql-database.ts
@@@ -157,32 -154,18 +157,34 @@@ export const SqlDatabaseProvider = ({ g
const ssl = providerInputs.ca
? { rejectUnauthorized: false, ca: providerInputs.ca, servername: providerInputs.host }
: undefined;
+
const isMsSQLClient = providerInputs.client === SqlProviders.MsSQL;
+ /*
+ We route through the gateway by setting connection.host = "localhost".
+ Azure SQL identifies the logical server from the TDS login name when the host
+ isn’t the Azure FQDN. Therefore, when using the gateway, ensure username is
+ "user@<azure-server-name>" so Azure opens the correct logical server.
+ Direct connections to the Azure FQDN usually don’t require this suffix.
+ */
- const isGatewayForwardedTraffic = providerInputs.host === "localhost";
+ const isAzureSql = isMsSQLClient && new RE2(/\.database\.windows\.net$/i).test(providerInputs.originalHost);
+ const azureServerLabel =
- isAzureSql && isGatewayForwardedTraffic ? providerInputs.originalHost?.split(".")[0] : undefined;
++ isAzureSql && providerInputs.gatewayId ? providerInputs.originalHost?.split(".")[0] : undefined;
+ const effectiveUser =
+ isAzureSql && !providerInputs.username.includes("@")
+ ? `${providerInputs.username}@${azureServerLabel}`
+ : providerInputs.username;
+
const db = knex({
client: providerInputs.client,
connection: {
database: providerInputs.database,
port: providerInputs.port,
- host: providerInputs.client === SqlProviders.Postgres ? providerInputs.hostIp : providerInputs.host,
+ host:
+ providerInputs.client === SqlProviders.Postgres && !providerInputs.gatewayId
+ ? providerInputs.hostIp
+ : providerInputs.host,
- user: providerInputs.username,
+ user: effectiveUser,
password: providerInputs.password,
ssl,
// @ts-expect-error this is because of knexjs type signature issue. This is directly passed to driver