Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
feat(pam): add MongoDB support (#5817)
Saif Ur Rahmane1b25f9f6a8d
diff --git a/backend/package-lock.json b/backend/package-lock.jsonindex 34bce8f903..7131aff53e 100644--- a/backend/package-lock.json+++ b/backend/package-lock.json@@ -105,6 +105,7 @@"libsodium-wrappers": "^0.7.13","lodash.isequal": "^4.5.0","mongodb": "^6.8.1",+ "mongodb-connection-string-url": "^3.0.0","ms": "^2.1.3","mysql2": "^3.9.8","nanoid": "^3.3.8",@@ -2211,6 +2212,7 @@"integrity": "sha512-vMqyb7XCDMPvJFFOaT9kxtiRh42GwlZEg1/uIgtZshS5a/8OaduUfCi7kynKgc3Tw/6Uo2D+db9qBttghhmxwQ==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"@ampproject/remapping": "^2.2.0","@babel/code-frame": "^7.26.2",@@ -4269,6 +4271,7 @@"url": "https://opencollective.com/csstools"}],+ "peer": true,"engines": {"node": ">=18"},@@ -4290,6 +4293,7 @@"url": "https://opencollective.com/csstools"}],+ "peer": true,"engines": {"node": ">=18"}@@ -6936,6 +6940,7 @@"resolved": "https://registry.npmjs.org/zod/-/zod-4.3.6.tgz","integrity": "sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg==","license": "MIT",+ "peer": true,"funding": {"url": "https://github.com/sponsors/colinhacks"}@@ -7856,6 +7861,7 @@"resolved": "https://registry.npmjs.org/@octokit/core/-/core-5.2.1.tgz","integrity": "sha512-dKYCMuPO1bmrpuogcjQ8z7ICCH3FP6WmxpwC03yjzGfZhj9fTJg6+bS1+UAplekbN2C+M61UNllGOOoAfGCrdQ==","license": "MIT",+ "peer": true,"dependencies": {"@octokit/auth-token": "^4.0.0","@octokit/graphql": "^7.1.0",@@ -8351,6 +8357,7 @@"version": "1.9.0","resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.9.0.tgz","integrity": "sha512-3giAOQvZiH5F9bMlMiv8+GSPMeqg0dbaeo58/0SlA9sxSqZhnUtxzX9/2FzyhS9sWQf5S0GJE0AKBrFqjpeYcg==",+ "peer": true,"engines": {"node": ">=8.0.0"}@@ -9014,6 +9021,7 @@"resolved": "https://registry.npmjs.org/@react-email/body/-/body-0.2.0.tgz","integrity": "sha512-9GCWmVmKUAoRfloboCd+RKm6X17xn7eGL7HnpAZUnjBXBilWCxsKnLMTC/ixSHDKS/A/057M1Tx6ZUXd89sVBw==","license": "MIT",+ "peer": true,"peerDependencies": {"react": "^18.0 || ^19.0 || ^19.0.0-rc"}@@ -9023,6 +9031,7 @@"resolved": "https://registry.npmjs.org/@react-email/button/-/button-0.2.0.tgz","integrity": "sha512-8i+v6cMxr2emz4ihCrRiYJPp2/sdYsNNsBzXStlcA+/B9Umpm5Jj3WJKYpgTPM+aeyiqlG/MMI1AucnBm4f1oQ==","license": "MIT",+ "peer": true,"engines": {"node": ">=18.0.0"},@@ -9035,6 +9044,7 @@"resolved": "https://registry.npmjs.org/@react-email/code-block/-/code-block-0.2.0.tgz","integrity": "sha512-eIrPW9PIFgDopQU0e/OPpwCW2QWQDtNZDSsiN4sJO8KdMnWWnXJicnRfzrit5rHwFo+Y98i+w/Y5ScnBAFr1dQ==","license": "MIT",+ "peer": true,"dependencies": {"prismjs": "^1.30.0"},@@ -9050,6 +9060,7 @@"resolved": "https://registry.npmjs.org/@react-email/code-inline/-/code-inline-0.0.5.tgz","integrity": "sha512-MmAsOzdJpzsnY2cZoPHFPk6uDO/Ncpb4Kh1hAt9UZc1xOW3fIzpe1Pi9y9p6wwUmpaeeDalJxAxH6/fnTquinA==","license": "MIT",+ "peer": true,"engines": {"node": ">=18.0.0"},@@ -9125,6 +9136,7 @@"resolved": "https://registry.npmjs.org/@react-email/container/-/container-0.0.15.tgz","integrity": "sha512-Qo2IQo0ru2kZq47REmHW3iXjAQaKu4tpeq/M8m1zHIVwKduL2vYOBQWbC2oDnMtWPmkBjej6XxgtZByxM6cCFg==","license": "MIT",+ "peer": true,"engines": {"node": ">=18.0.0"},@@ -9158,6 +9170,7 @@"resolved": "https://registry.npmjs.org/@react-email/heading/-/heading-0.0.15.tgz","integrity": "sha512-xF2GqsvBrp/HbRHWEfOgSfRFX+Q8I5KBEIG5+Lv3Vb2R/NYr0s8A5JhHHGf2pWBMJdbP4B2WHgj/VUrhy8dkIg==","license": "MIT",+ "peer": true,"engines": {"node": ">=18.0.0"},@@ -9170,6 +9183,7 @@"resolved": "https://registry.npmjs.org/@react-email/hr/-/hr-0.0.11.tgz","integrity": "sha512-S1gZHVhwOsd1Iad5IFhpfICwNPMGPJidG/Uysy1AwmspyoAP5a4Iw3OWEpINFdgh9MHladbxcLKO2AJO+cA9Lw==","license": "MIT",+ "peer": true,"engines": {"node": ">=18.0.0"},@@ -9194,6 +9208,7 @@"resolved": "https://registry.npmjs.org/@react-email/img/-/img-0.0.11.tgz","integrity": "sha512-aGc8Y6U5C3igoMaqAJKsCpkbm1XjguQ09Acd+YcTKwjnC2+0w3yGUJkjWB2vTx4tN8dCqQCXO8FmdJpMfOA9EQ==","license": "MIT",+ "peer": true,"engines": {"node": ">=18.0.0"},@@ -9206,6 +9221,7 @@"resolved": "https://registry.npmjs.org/@react-email/link/-/link-0.0.12.tgz","integrity": "sha512-vF+xxQk2fGS1CN7UPQDbzvcBGfffr+GjTPNiWM38fhBfsLv6A/YUfaqxWlmL7zLzVmo0K2cvvV9wxlSyNba1aQ==","license": "MIT",+ "peer": true,"engines": {"node": ">=18.0.0"},@@ -9233,6 +9249,7 @@"resolved": "https://registry.npmjs.org/@react-email/preview/-/preview-0.0.13.tgz","integrity": "sha512-F7j9FJ0JN/A4d7yr+aw28p4uX7VLWs7hTHtLo7WRyw4G+Lit6Zucq4UWKRxJC8lpsUdzVmG7aBJnKOT+urqs/w==","license": "MIT",+ "peer": true,"engines": {"node": ">=18.0.0"},@@ -9805,6 +9822,7 @@"resolved": "https://registry.npmjs.org/@react-email/text/-/text-0.1.5.tgz","integrity": "sha512-o5PNHFSE085VMXayxH+SJ1LSOtGsTv+RpNKnTiJDrJUwoBu77G3PlKOsZZQHCNyD28WsQpl9v2WcJLbQudqwPg==","license": "MIT",+ "peer": true,"engines": {"node": ">=18.0.0"},@@ -11468,6 +11486,7 @@"resolved": "https://registry.npmjs.org/@types/node/-/node-20.19.23.tgz","integrity": "sha512-yIdlVVVHXpmqRhtyovZAcSy0MiPcYWGkoO4CGe/+jpP0hmNuihm4XhHbADpK++MsiLHP5MVlv+bcgdF99kSiFQ==","license": "MIT",+ "peer": true,"dependencies": {"undici-types": "~6.21.0"}@@ -11961,6 +11980,7 @@"integrity": "sha512-tbsV1jPne5CkFQCgPBcDOt30ItF7aJoZL997JSF7MhGQqOeT3svWRYxiqlfA5RUdlHN6Fi+EI9bxqbdyAUZjYQ==","dev": true,"license": "BSD-2-Clause",+ "peer": true,"dependencies": {"@typescript-eslint/scope-manager": "6.21.0","@typescript-eslint/types": "6.21.0",@@ -12417,6 +12437,7 @@"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz","integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==","license": "MIT",+ "peer": true,"bin": {"acorn": "bin/acorn"},@@ -12897,6 +12918,7 @@"resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-5.4.1.tgz","integrity": "sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA==","license": "MIT",+ "peer": true,"dependencies": {"bn.js": "^4.0.0","inherits": "^2.0.1",@@ -13109,6 +13131,7 @@"resolved": "https://registry.npmjs.org/axios/-/axios-1.14.0.tgz","integrity": "sha512-3Y8yrqLSwjuzpXuZ0oIYZ/XGgLwUIBU3uLvbcpb0pidD9ctpShJd43KSlEEkVQg6DS0G9NKyzOvBfUtDKEyHvQ==","license": "MIT",+ "peer": true,"dependencies": {"follow-redirects": "^1.15.11","form-data": "^4.0.5",@@ -13740,6 +13763,7 @@}],"license": "MIT",+ "peer": true,"dependencies": {"baseline-browser-mapping": "^2.8.9","caniuse-lite": "^1.0.30001746",@@ -15171,6 +15195,7 @@"version": "16.4.1","resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.1.tgz","integrity": "sha512-CjA3y+Dr3FyFDOAMnxZEGtnW9KBR2M0JvvUtXNW+dYJL5ROWxP9DUHCwgFqpMk0OXCc0ljhaNTr2w/kutYIcHQ==",+ "peer": true,"engines": {"node": ">=12"},@@ -15541,6 +15566,7 @@"dev": true,"hasInstallScript": true,"license": "MIT",+ "peer": true,"bin": {"esbuild": "bin/esbuild"},@@ -15623,6 +15649,7 @@"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.56.0.tgz","integrity": "sha512-Go19xM6T9puCOWntie1/P997aXxFsOi37JIHRWI514Hc6ZnaHGKY9xFhrU65RT6CcBEzZoGG1e6Nq+DT04ZtZQ==","dev": true,+ "peer": true,"dependencies": {"@eslint-community/eslint-utils": "^4.2.0","@eslint-community/regexpp": "^4.6.1",@@ -15721,6 +15748,7 @@"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz","integrity": "sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==","dev": true,+ "peer": true,"bin": {"eslint-config-prettier": "bin/cli.js"},@@ -15809,6 +15837,7 @@"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.29.1.tgz","integrity": "sha512-BbPC0cuExzhiMo4Ff1BTVwHpjjv28C5R+btTOGaCRC7UEz801up0JadwkeSk5Ued6TG34uaczuVuH6qyy5YUxw==","dev": true,+ "peer": true,"dependencies": {"array-includes": "^3.1.7","array.prototype.findlastindex": "^1.2.3",@@ -16221,6 +16250,7 @@"resolved": "https://registry.npmjs.org/express/-/express-4.22.1.tgz","integrity": "sha512-F2X8g9P1X7uCPZMA3MVf9wcTqlyNp7IhH5qPCI0izhaOIYXaW9L535tGA3qmjRzpH+bZczqq7hVKxTR4NWnu+g==","license": "MIT",+ "peer": true,"dependencies": {"accepts": "~1.3.8","array-flatten": "1.1.1",@@ -16294,7 +16324,6 @@"resolved": "https://registry.npmjs.org/express-session/-/express-session-1.19.0.tgz","integrity": "sha512-0csaMkGq+vaiZTmSMMGkfdCOabYv192VbytFypcvI0MANrp+4i/7yEkJ0sbAEhycQjntaKGzYfjfXQyVb7BHMA==","license": "MIT",- "peer": true,"dependencies": {"cookie": "~0.7.2","cookie-signature": "~1.0.7",@@ -16316,14 +16345,12 @@"node_modules/express-session/node_modules/cookie-signature": {"version": "1.0.7","resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.7.tgz",- "integrity": "sha512-NXdYc3dLr47pBkpUCHtKSwIOQXLVn8dZEuywboCOJY/osA0wFSLlSawr3KN8qXJEyX66FcONTH8EIlVuK0yyFA==",- "peer": true+ "integrity": "sha512-NXdYc3dLr47pBkpUCHtKSwIOQXLVn8dZEuywboCOJY/osA0wFSLlSawr3KN8qXJEyX66FcONTH8EIlVuK0yyFA=="},"node_modules/express-session/node_modules/debug": {"version": "2.6.9","resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz","integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",- "peer": true,"dependencies": {"ms": "2.0.0"}@@ -16331,8 +16358,7 @@"node_modules/express-session/node_modules/ms": {"version": "2.0.0","resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",- "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",- "peer": true+ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A=="},"node_modules/express/node_modules/cookie-signature": {"version": "1.0.6",@@ -17786,6 +17812,7 @@"resolved": "https://registry.npmjs.org/hono/-/hono-4.12.9.tgz","integrity": "sha512-wy3T8Zm2bsEvxKZM5w21VdHDDcwVS1yUFFY6i8UobSsKfFceT7TOwhbhfKsDyx7tYQlmRM5FLpIuYvNFyjctiA==","license": "MIT",+ "peer": true,"engines": {"node": ">=16.9.0"}@@ -21263,7 +21290,6 @@"resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.1.0.tgz","integrity": "sha512-737ZY3yNnXy37FHkQxPzt4UZ2UWPWiCZWLvFZ4fu5cueciegX0zGPnrlY6bwRg4FdQOe9YU8MkmJwGhoMybl8A==","license": "MIT",- "peer": true,"engines": {"node": ">= 0.8"}@@ -21950,6 +21976,7 @@"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-3.0.2.tgz","integrity": "sha512-cfDHL6LStTEKlNilboNtobT/kEa30PtAf2Q1OgszfrG/rpVl1xaFWT9ktfkS306GmHgmnad1Sw4wabhlvFtsTw==","license": "MIT",+ "peer": true,"engines": {"node": ">=10"},@@ -22292,6 +22319,7 @@}],"license": "MIT",+ "peer": true,"dependencies": {"nanoid": "^3.3.11","picocolors": "^1.1.1",@@ -22389,6 +22417,7 @@"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.5.3.tgz","integrity": "sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw==","license": "MIT",+ "peer": true,"bin": {"prettier": "bin/prettier.cjs"},@@ -22805,7 +22834,6 @@"version": "1.0.0","resolved": "https://registry.npmjs.org/random-bytes/-/random-bytes-1.0.0.tgz","integrity": "sha512-iv7LhNVO047HzYR3InF6pUcUsPQiHTM1Qal51DcGSuZFBil1aBBWG5eHPNek7bvILMaYJ/8RU1e8w1AMdHmLQQ==",- "peer": true,"engines": {"node": ">= 0.8"}@@ -22909,6 +22937,7 @@"resolved": "https://registry.npmjs.org/react/-/react-19.1.0.tgz","integrity": "sha512-FS+XFBNvn3GTAWq26joslQgWNoFu08F4kl0J4CgdNKADkdSGXQyTCnKteIAJy96Br6YbpEU1LSzV5dYtjMkMDg==","license": "MIT",+ "peer": true,"engines": {"node": ">=0.10.0"}@@ -22918,6 +22947,7 @@"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.1.0.tgz","integrity": "sha512-Xs1hdnE+DyKgeHJeJznQmYMIBG3TKIHJJT95Q58nHLSrElKlGQqDTR2HQ9fx5CN/Gk6Vh/kupBTDLU11/nDk/g==","license": "MIT",+ "peer": true,"dependencies": {"scheduler": "^0.26.0"},@@ -24667,6 +24697,7 @@"resolved": "https://registry.npmjs.org/socks/-/socks-2.8.4.tgz","integrity": "sha512-D3YaD0aRxR3mEcqnidIs7ReYJFVzWdd6fXJYUM8ixcQcJRGTka/b3saV0KflYhyVJXKhb947GndU35SxYNResQ==","license": "MIT",+ "peer": true,"dependencies": {"ip-address": "^9.0.5","smart-buffer": "^4.2.0"@@ -26009,6 +26040,7 @@"integrity": "sha512-ytQKuwgmrrkDTFP4LjR0ToE2nqgy886GpvRSpU0JAnrdBYppuY5rLkRUYPU1yCryb24SsKBTL/hlDQAEFVwtZg==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"esbuild": "~0.25.0","get-tsconfig": "^4.7.5"@@ -26177,6 +26209,7 @@"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.2.tgz","integrity": "sha512-6l+RyNy7oAHDfxC4FzSJcz9vnjTKxrLpDG5M2Vu4SHRVNg6xzqZp6LYSR9zjqQTu8DU/f5xwxUdADOkbrIX2gQ==","dev": true,+ "peer": true,"bin": {"tsc": "bin/tsc","tsserver": "bin/tsserver"@@ -26217,7 +26250,6 @@"version": "2.1.5","resolved": "https://registry.npmjs.org/uid-safe/-/uid-safe-2.1.5.tgz","integrity": "sha512-KPHm4VL5dDXKz01UuEd88Df+KzynaohSL9fBh096KWAxSKZQDI2uBrVqtvRM4rwrIrRRKsdLNML/lnaaVSRioA==",- "peer": true,"dependencies": {"random-bytes": "~1.0.0"},@@ -26780,6 +26812,7 @@"integrity": "sha512-ZWyE8YXEXqJrrSLvYgrRP7p62OziLW7xI5HYGWFzOvupfAlrLvURSzv/FyGyy0eidogEM3ujU+kUG1zuHgb6Ug==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"esbuild": "^0.25.0","fdir": "^6.5.0",@@ -27436,6 +27469,7 @@"resolved": "https://registry.npmjs.org/zod/-/zod-3.24.3.tgz","integrity": "sha512-HhY1oqzWCQWuUqvBFnsyrtZRhyPeR7SUGv+C4+MsisMuVfSPx8HpwWqH8tRahSlt6M3PiFAcoeFhZAqIXTxoSg==","license": "MIT",+ "peer": true,"funding": {"url": "https://github.com/sponsors/colinhacks"}diff --git a/backend/package.json b/backend/package.jsonindex 9e44bc4e30..d80bec8466 100644--- a/backend/package.json+++ b/backend/package.json@@ -227,6 +227,7 @@"libsodium-wrappers": "^0.7.13","lodash.isequal": "^4.5.0","mongodb": "^6.8.1",+ "mongodb-connection-string-url": "^3.0.0","ms": "^2.1.3","mysql2": "^3.9.8","nanoid": "^3.3.8",diff --git a/backend/src/ee/routes/v1/pam-account-routers/index.ts b/backend/src/ee/routes/v1/pam-account-routers/index.tsindex 618ec0565f..3f9eb4e1f4 100644--- a/backend/src/ee/routes/v1/pam-account-routers/index.ts+++ b/backend/src/ee/routes/v1/pam-account-routers/index.ts@@ -13,6 +13,11 @@ import {SanitizedKubernetesAccountWithResourceSchema,UpdateKubernetesAccountSchema} from "@app/ee/services/pam-resource/kubernetes/kubernetes-resource-schemas";+import {+ CreateMongoDBAccountSchema,+ SanitizedMongoDBAccountWithResourceSchema,+ UpdateMongoDBAccountSchema+} from "@app/ee/services/pam-resource/mongodb/mongodb-resource-schemas";import {CreateMsSQLAccountSchema,SanitizedMsSQLAccountWithResourceSchema,@@ -84,6 +89,15 @@ export const PAM_ACCOUNT_REGISTER_ROUTER_MAP: Record<PamResource, (server: FastiupdateAccountSchema: UpdateRedisAccountSchema});},+ [PamResource.MongoDB]: async (server: FastifyZodProvider) => {+ registerPamAccountEndpoints({+ server,+ resourceType: PamResource.MongoDB,+ accountResponseSchema: SanitizedMongoDBAccountWithResourceSchema,+ createAccountSchema: CreateMongoDBAccountSchema,+ updateAccountSchema: UpdateMongoDBAccountSchema+ });+ },[PamResource.SSH]: async (server: FastifyZodProvider) => {registerPamAccountEndpoints({server,diff --git a/backend/src/ee/routes/v1/pam-account-routers/pam-account-router.ts b/backend/src/ee/routes/v1/pam-account-routers/pam-account-router.tsindex 9d5770e5b3..2e4275c550 100644--- a/backend/src/ee/routes/v1/pam-account-routers/pam-account-router.ts+++ b/backend/src/ee/routes/v1/pam-account-routers/pam-account-router.ts@@ -16,6 +16,10 @@ import {KubernetesAccountCredentialsSchema,SanitizedKubernetesAccountWithResourceSchema} from "@app/ee/services/pam-resource/kubernetes/kubernetes-resource-schemas";+import {+ MongoDBAccountCredentialsSchema,+ SanitizedMongoDBAccountWithResourceSchema+} from "@app/ee/services/pam-resource/mongodb/mongodb-resource-schemas";import {MsSQLAccountCredentialsSchema,SanitizedMsSQLAccountWithResourceSchema@@ -60,6 +64,7 @@ const SanitizedAccountSchema = zSanitizedPostgresAccountWithResourceSchema,SanitizedMySQLAccountWithResourceSchema,SanitizedMsSQLAccountWithResourceSchema,+ SanitizedMongoDBAccountWithResourceSchema,SanitizedRedisAccountWithResourceSchema,SanitizedAwsIamAccountWithResourceSchema,SanitizedWindowsAccountWithResourceSchema,@@ -97,6 +102,10 @@ const AccountCredentialsResponseSchema = z.discriminatedUnion("resourceType", [resourceType: z.literal(PamResource.MsSQL),credentials: MsSQLAccountCredentialsSchema}),+ AccountCredentialsBaseSchema.extend({+ resourceType: z.literal(PamResource.MongoDB),+ credentials: MongoDBAccountCredentialsSchema+ }),AccountCredentialsBaseSchema.extend({resourceType: z.literal(PamResource.SSH),credentials: SSHAccountCredentialsSchema@@ -527,6 +536,7 @@ export const registerPamAccountRouter = async (server: FastifyZodProvider) => {GatewayAccessResponseSchema.extend({ resourceType: z.literal(PamResource.Postgres) }),GatewayAccessResponseSchema.extend({ resourceType: z.literal(PamResource.MySQL) }),GatewayAccessResponseSchema.extend({ resourceType: z.literal(PamResource.MsSQL) }),+ GatewayAccessResponseSchema.extend({ resourceType: z.literal(PamResource.MongoDB) }),GatewayAccessResponseSchema.extend({ resourceType: z.literal(PamResource.Redis) }),GatewayAccessResponseSchema.extend({ resourceType: z.literal(PamResource.SSH) }),GatewayAccessResponseSchema.extend({ resourceType: z.literal(PamResource.Kubernetes) }),diff --git a/backend/src/ee/routes/v1/pam-resource-routers/index.ts b/backend/src/ee/routes/v1/pam-resource-routers/index.tsindex a518aeea46..0fdc50ca5c 100644--- a/backend/src/ee/routes/v1/pam-resource-routers/index.ts+++ b/backend/src/ee/routes/v1/pam-resource-routers/index.ts@@ -13,6 +13,11 @@ import {SanitizedKubernetesResourceSchema,UpdateKubernetesResourceSchema} from "@app/ee/services/pam-resource/kubernetes/kubernetes-resource-schemas";+import {+ CreateMongoDBResourceSchema,+ SanitizedMongoDBResourceSchema,+ UpdateMongoDBResourceSchema+} from "@app/ee/services/pam-resource/mongodb/mongodb-resource-schemas";import {CreateMsSQLResourceSchema,MsSQLResourceSchema,@@ -118,6 +123,15 @@ export const PAM_RESOURCE_REGISTER_ROUTER_MAP: Record<PamResource, (server: FastupdateResourceSchema: UpdateRedisResourceSchema});},+ [PamResource.MongoDB]: async (server: FastifyZodProvider) => {+ registerPamResourceEndpoints({+ server,+ resourceType: PamResource.MongoDB,+ resourceResponseSchema: SanitizedMongoDBResourceSchema,+ createResourceSchema: CreateMongoDBResourceSchema,+ updateResourceSchema: UpdateMongoDBResourceSchema+ });+ },[PamResource.Windows]: async (server: FastifyZodProvider) => {registerPamResourceEndpoints({server,diff --git a/backend/src/ee/routes/v1/pam-resource-routers/pam-resource-router.ts b/backend/src/ee/routes/v1/pam-resource-routers/pam-resource-router.tsindex 9a65c88e44..838eb308db 100644--- a/backend/src/ee/routes/v1/pam-resource-routers/pam-resource-router.ts+++ b/backend/src/ee/routes/v1/pam-resource-routers/pam-resource-router.ts@@ -14,6 +14,10 @@ import {KubernetesResourceListItemSchema,SanitizedKubernetesResourceSchema} from "@app/ee/services/pam-resource/kubernetes/kubernetes-resource-schemas";+import {+ MongoDBResourceListItemSchema,+ SanitizedMongoDBResourceSchema+} from "@app/ee/services/pam-resource/mongodb/mongodb-resource-schemas";import {MsSQLResourceListItemSchema,SanitizedMsSQLResourceSchema@@ -51,6 +55,7 @@ const SanitizedResourceSchema = z.discriminatedUnion("resourceType", [SanitizedSSHResourceSchema,SanitizedKubernetesResourceSchema,SanitizedAwsIamResourceSchema,+ SanitizedMongoDBResourceSchema,SanitizedRedisResourceSchema,SanitizedWindowsResourceSchema,SanitizedActiveDirectoryResourceSchema@@ -68,6 +73,7 @@ const ResourceOptionsSchema = z.discriminatedUnion("resource", [SSHResourceListItemSchema,KubernetesResourceListItemSchema,AwsIamResourceListItemSchema,+ MongoDBResourceListItemSchema,RedisResourceListItemSchema,WindowsResourceListItemSchema,ActiveDirectoryResourceListItemSchemadiff --git a/backend/src/ee/routes/v1/pam-session-router.ts b/backend/src/ee/routes/v1/pam-session-router.tsindex bc9face220..e0b8d0a7e8 100644--- a/backend/src/ee/routes/v1/pam-session-router.ts+++ b/backend/src/ee/routes/v1/pam-session-router.ts@@ -3,6 +3,7 @@ import { z } from "zod";import { PamSessionsSchema } from "@app/db/schemas";import { EventType } from "@app/ee/services/audit-log/audit-log-types";import { KubernetesSessionCredentialsSchema } from "@app/ee/services/pam-resource/kubernetes/kubernetes-resource-schemas";+import { MongoDBSessionCredentialsSchema } from "@app/ee/services/pam-resource/mongodb/mongodb-resource-schemas";import { MySQLSessionCredentialsSchema } from "@app/ee/services/pam-resource/mysql/mysql-resource-schemas";import { PostgresSessionCredentialsSchema } from "@app/ee/services/pam-resource/postgres/postgres-resource-schemas";import { RedisSessionCredentialsSchema } from "@app/ee/services/pam-resource/redis/redis-resource-schemas";@@ -23,6 +24,7 @@ const SessionCredentialsSchema = z.union([SSHSessionCredentialsSchema,PostgresSessionCredentialsSchema,MySQLSessionCredentialsSchema,+ MongoDBSessionCredentialsSchema,KubernetesSessionCredentialsSchema,RedisSessionCredentialsSchema]);diff --git a/backend/src/ee/services/gateway-v2/gateway-v2-service.ts b/backend/src/ee/services/gateway-v2/gateway-v2-service.tsindex cfc4def763..c1f8d81c74 100644--- a/backend/src/ee/services/gateway-v2/gateway-v2-service.ts+++ b/backend/src/ee/services/gateway-v2/gateway-v2-service.ts@@ -499,7 +499,7 @@ export const gatewayV2ServiceFactory = ({resourceType: PamResource;duration?: number;host: string;- port: number;+ port?: number;actorMetadata: { id: string; type: ActorType; name: string };}) => {const gateway = await gatewayV2DAL.findById(gatewayId);@@ -568,7 +568,7 @@ export const gatewayV2ServiceFactory = ({const routingInfo = {targetHost: host,- targetPort: port+ targetPort: port ?? 0};const routingExtension = new x509.Extension(diff --git a/backend/src/ee/services/pam-account/pam-account-service.ts b/backend/src/ee/services/pam-account/pam-account-service.tsindex 5a7b6981f6..28b8bdcc54 100644--- a/backend/src/ee/services/pam-account/pam-account-service.ts+++ b/backend/src/ee/services/pam-account/pam-account-service.ts@@ -7,6 +7,7 @@ import {generateConsoleFederationUrl,TAwsIamAccountCredentials} from "@app/ee/services/pam-resource/aws-iam";+import { parseMongoConnectionString } from "@app/ee/services/pam-resource/mongodb/mongodb-resource-factory";import { PAM_RESOURCE_FACTORY_MAP } from "@app/ee/services/pam-resource/pam-resource-factory";import {decryptResource,@@ -823,22 +824,25 @@ export const pamAccountServiceFactory = ({throw new BadRequestError({ message: "Gateway ID is required for this resource type" });}- const { host, port } =- resourceType !== PamResource.Kubernetes- ? connectionDetails- : (() => {- const url = new URL(connectionDetails.url);- let portNumber: number | undefined;- if (url.port) {- portNumber = Number(url.port);- } else {- portNumber = url.protocol === "https:" ? 443 : 80;- }- return {- host: url.hostname,- port: portNumber- };- })();+ const { host, port } = (() => {+ if (resourceType === PamResource.Kubernetes) {+ const url = new URL(connectionDetails.url);+ let portNumber: number | undefined;+ if (url.port) {+ portNumber = Number(url.port);+ } else {+ portNumber = url.protocol === "https:" ? 443 : 80;+ }+ return { host: url.hostname, port: portNumber };+ }++ if (resourceType === PamResource.MongoDB) {+ const parsed = parseMongoConnectionString(connectionDetails.connectionString);+ return { host: parsed.hostname, port: parsed.port };+ }++ return connectionDetails as { host: string; port: number };+ })();const gatewayConnectionDetails = await gatewayV2Service.getPAMConnectionDetails({gatewayId,@@ -864,6 +868,7 @@ export const pamAccountServiceFactory = ({case PamResource.Postgres:case PamResource.MySQL:case PamResource.MsSQL:+ case PamResource.MongoDB:{const connectionCredentials = (await decryptResourceConnectionDetails({encryptedConnectionDetails: resource.encryptedConnectionDetails,diff --git a/backend/src/ee/services/pam-resource/mongodb/mongodb-resource-factory.ts b/backend/src/ee/services/pam-resource/mongodb/mongodb-resource-factory.tsnew file mode 100644index 0000000000..da274558f9--- /dev/null+++ b/backend/src/ee/services/pam-resource/mongodb/mongodb-resource-factory.ts@@ -0,0 +1,280 @@+import dns from "dns";+import { MongoClient, MongoServerError } from "mongodb";+import ConnectionString from "mongodb-connection-string-url";+import tls, { PeerCertificate } from "tls";+import { promisify } from "util";++import { verifyHostInputValidity } from "@app/ee/services/dynamic-secret/dynamic-secret-fns";+import { TGatewayV2ServiceFactory } from "@app/ee/services/gateway-v2/gateway-v2-service";+import { BadRequestError } from "@app/lib/errors";+import { GatewayProxyProtocol } from "@app/lib/gateway";+import { withGatewayV2Proxy } from "@app/lib/gateway-v2/gateway-v2";++import {+ TPamResourceFactory,+ TPamResourceFactoryRotateAccountCredentials,+ TPamResourceFactoryValidateAccountCredentials,+ TPamResourceInternalMetadata+} from "../pam-resource-types";+import { TMongoDBAccountCredentials, TMongoDBResourceConnectionDetails } from "./mongodb-resource-types";++const resolveSrv = promisify(dns.resolveSrv);++const EXTERNAL_REQUEST_TIMEOUT = 10 * 1000;++// MongoDB error code 18 = AuthenticationFailed+const MONGO_AUTH_FAILED_CODE = 18;++interface MongoDBResourceConnection {+ validate: (connectOnly: boolean) => Promise<void>;+ rotateCredentials: (currentCredentials: TMongoDBAccountCredentials, newPassword: string) => Promise<never>;+ close: () => Promise<void>;+}++/**+ * Parse a MongoDB connection string into its components for relay routing and connection building.+ * Expects a validated URI (mongodb:// or mongodb+srv://) — schema validation ensures this.+ */+export const parseMongoConnectionString = (connectionString: string) => {+ const cs = new ConnectionString(connectionString);+ const { isSRV } = cs;+ const authSource = cs.searchParams.get("authSource") || "admin";++ const [firstHost] = cs.hosts;+ let hostname: string;+ let port: number | undefined;++ if (isSRV) {+ // SRV hosts have no port+ hostname = firstHost;+ } else {+ const colonIdx = firstHost.lastIndexOf(":");+ if (colonIdx !== -1) {+ hostname = firstHost.slice(0, colonIdx);+ port = parseInt(firstHost.slice(colonIdx + 1), 10);+ } else {+ hostname = firstHost;+ port = 27017;+ }+ }++ return { hostname, port, isSRV, authSource };+};++/**+ * For MongoDB SRV connections, resolve the SRV record to discover the actual host and port.+ * Used for relay routing — the relay needs a concrete host:port for the TCP tunnel.+ */+const resolveMongoSrvHost = async (host: string): Promise<{ host: string; port: number }> => {+ const records = await resolveSrv(`_mongodb._tcp.${host}`);+ if (records.length > 0) {+ // Randomize record selection so retries can hit a different node if one is down+ const record = records[Math.floor(Math.random() * records.length)];+ return { host: record.name, port: record.port };+ }+ throw new BadRequestError({+ message: `Unable to resolve SRV record for MongoDB host "${host}". Ensure the host is a valid SRV domain.`+ });+};++/**+ * Build a MongoDB client connection through a local gateway proxy.+ * Receives pre-parsed connection info — no URI parsing happens here.+ */+const makeMongoDBConnection = (+ proxyPort: number,+ config: {+ hostname: string;+ authSource: string;+ database: string;+ sslEnabled: boolean;+ sslRejectUnauthorized: boolean;+ sslCertificate?: string;+ username?: string;+ password?: string;+ }+): MongoDBResourceConnection => {+ const { hostname, authSource, database, sslEnabled, sslRejectUnauthorized, sslCertificate, username, password } =+ config;++ const authPart = username && password ? `${encodeURIComponent(username)}:${encodeURIComponent(password)}@` : "";++ const encodedDatabase = encodeURIComponent(database);+ const uri = `mongodb://${authPart}localhost:${proxyPort}/${encodedDatabase}?authSource=${encodeURIComponent(authSource)}&directConnection=true&serverSelectionTimeoutMS=${EXTERNAL_REQUEST_TIMEOUT}&connectTimeoutMS=${EXTERNAL_REQUEST_TIMEOUT}`;++ const mongoClient = new MongoClient(uri, {+ ...(sslEnabled && {+ tls: true,+ tlsAllowInvalidCertificates: !sslRejectUnauthorized,+ servername: hostname,+ checkServerIdentity: (_hostnameParam: string, cert: PeerCertificate) => {+ return tls.checkServerIdentity(hostname, cert);+ }+ }),+ ...(sslEnabled && sslCertificate && { ca: sslCertificate })+ });++ return {+ validate: async (connectOnly) => {+ try {+ await mongoClient.connect();+ await mongoClient.db(database).command({ ping: 1 });+ } catch (error) {+ if (connectOnly && error instanceof MongoServerError && error.code === MONGO_AUTH_FAILED_CODE) {+ return;+ }+ throw new BadRequestError({+ message: `Unable to validate connection to MongoDB: ${(error as Error).message || String(error)}`+ });+ }+ },+ rotateCredentials: async () => {+ throw new BadRequestError({+ message: "Credential rotation is not yet supported for MongoDB resources"+ });+ },+ close: async () => {+ await mongoClient.close();+ }+ };+};++const executeWithGateway = async <T>(+ config: {+ connectionDetails: TMongoDBResourceConnectionDetails;+ gatewayId: string;+ username?: string;+ password?: string;+ },+ gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">,+ operation: (connection: MongoDBResourceConnection) => Promise<T>+): Promise<T> => {+ const { connectionDetails, gatewayId } = config;++ // Parse the connection string once — extract hostname, port, SRV flag, and authSource+ const parsed = parseMongoConnectionString(connectionDetails.connectionString);++ let resolvedHost = parsed.hostname;+ let resolvedPort: number = parsed.port ?? 0;++ // For SRV hosts, resolve to a concrete host:port for the relay tunnel+ if (parsed.isSRV) {+ const resolved = await resolveMongoSrvHost(parsed.hostname);+ resolvedHost = resolved.host;+ resolvedPort = resolved.port;+ }++ const [targetHost] = await verifyHostInputValidity({+ host: resolvedHost,+ isGateway: true,+ isDynamicSecret: false+ });+ const platformConnectionDetails = await gatewayV2Service.getPlatformConnectionDetailsByGatewayId({+ gatewayId,+ targetHost,+ targetPort: resolvedPort+ });++ if (!platformConnectionDetails) {+ throw new BadRequestError({ message: "Unable to connect to gateway, no platform connection details found" });+ }++ // For SRV, use the resolved shard hostname for TLS servername.+ // TLS certificates are issued for individual shard hostnames, not the SRV domain,+ // so the servername must match the actual server we're connecting to.+ const effectiveHostname = parsed.isSRV ? resolvedHost : parsed.hostname;++ return withGatewayV2Proxy(+ async (proxyPort) => {+ const connection = makeMongoDBConnection(proxyPort, {+ hostname: effectiveHostname,+ authSource: parsed.authSource,+ database: connectionDetails.database,+ sslEnabled: connectionDetails.sslEnabled,+ sslRejectUnauthorized: connectionDetails.sslRejectUnauthorized,+ sslCertificate: connectionDetails.sslCertificate,+ username: config.username,+ password: config.password+ });+ try {+ return await operation(connection);+ } finally {+ await connection.close();+ }+ },+ {+ protocol: GatewayProxyProtocol.Tcp,+ relayHost: platformConnectionDetails.relayHost,+ gateway: platformConnectionDetails.gateway,+ relay: platformConnectionDetails.relay+ }+ );+};++export const mongodbResourceFactory: TPamResourceFactory<+ TMongoDBResourceConnectionDetails,+ TMongoDBAccountCredentials,+ TPamResourceInternalMetadata+> = (resourceType, connectionDetails, gatewayId, gatewayV2Service) => {+ const validateConnection = async () => {+ if (!gatewayId) {+ throw new BadRequestError({ message: "Gateway ID is required" });+ }++ await executeWithGateway({ connectionDetails, gatewayId }, gatewayV2Service, async (client) => {+ await client.validate(true);+ });+ return connectionDetails;+ };++ const validateAccountCredentials: TPamResourceFactoryValidateAccountCredentials<TMongoDBAccountCredentials> = async (+ credentials+ ) => {+ if (!gatewayId) {+ throw new BadRequestError({ message: "Gateway ID is required" });+ }++ await executeWithGateway(+ {+ connectionDetails,+ gatewayId,+ username: credentials.username,+ password: credentials.password+ },+ gatewayV2Service,+ async (client) => {+ await client.validate(false);+ }+ );+ return credentials;+ };++ const rotateAccountCredentials: TPamResourceFactoryRotateAccountCredentials<+ TMongoDBAccountCredentials+ > = async () => {+ throw new BadRequestError({+ message: "Credential rotation is not yet supported for MongoDB resources"+ });+ };++ const handleOverwritePreventionForCensoredValues = async (+ updatedAccountCredentials: TMongoDBAccountCredentials,+ currentCredentials: TMongoDBAccountCredentials+ ) => {+ if (updatedAccountCredentials.password === "__INFISICAL_UNCHANGED__") {+ return {+ ...updatedAccountCredentials,+ password: currentCredentials.password+ };+ }++ return updatedAccountCredentials;+ };++ return {+ validateConnection,+ validateAccountCredentials,+ rotateAccountCredentials,+ handleOverwritePreventionForCensoredValues+ };+};diff --git a/backend/src/ee/services/pam-resource/mongodb/mongodb-resource-fns.ts b/backend/src/ee/services/pam-resource/mongodb/mongodb-resource-fns.tsnew file mode 100644index 0000000000..408f3992cd--- /dev/null+++ b/backend/src/ee/services/pam-resource/mongodb/mongodb-resource-fns.ts@@ -0,0 +1,8 @@+import { MongoDBResourceListItemSchema } from "./mongodb-resource-schemas";++export const getMongoDBResourceListItem = () => {+ return {+ name: MongoDBResourceListItemSchema.shape.name.value,+ resource: MongoDBResourceListItemSchema.shape.resource.value+ };+};diff --git a/backend/src/ee/services/pam-resource/mongodb/mongodb-resource-schemas.ts b/backend/src/ee/services/pam-resource/mongodb/mongodb-resource-schemas.tsnew file mode 100644index 0000000000..eb2eea7b8d--- /dev/null+++ b/backend/src/ee/services/pam-resource/mongodb/mongodb-resource-schemas.ts@@ -0,0 +1,129 @@+import ConnectionString from "mongodb-connection-string-url";+import { z } from "zod";++import { PamResource } from "../pam-resource-enums";+import {+ BaseCreateGatewayPamResourceSchema,+ BaseCreatePamAccountSchema,+ BasePamAccountSchema,+ BasePamAccountSchemaWithResource,+ BasePamResourceSchema,+ BaseUpdateGatewayPamResourceSchema,+ BaseUpdatePamAccountSchema+} from "../pam-resource-schemas";++// Resources+// MongoDB uses a connection string (mongodb:// or mongodb+srv:// URI) instead of+// separate host + port fields. The URI is validated and sanitized on input.+export const MongoDBResourceConnectionDetailsSchema = z.object({+ connectionString: z+ .string()+ .trim()+ .min(1)+ .max(1024)+ .transform((val, ctx) => {+ let cs: ConnectionString;+ try {+ cs = new ConnectionString(val);+ } catch {+ ctx.addIssue({+ code: z.ZodIssueCode.custom,+ message: "Invalid MongoDB connection string. Must start with mongodb:// or mongodb+srv://"+ });+ return z.NEVER;+ }++ if (cs.username || cs.password) {+ ctx.addIssue({+ code: z.ZodIssueCode.custom,+ message:+ "Credentials should not be included in the connection string — they are managed separately per account"+ });+ return z.NEVER;+ }++ if (cs.pathname && cs.pathname !== "/") {+ ctx.addIssue({+ code: z.ZodIssueCode.custom,+ message: "Database should not be included in the connection string — use the Database field instead"+ });+ return z.NEVER;+ }++ return cs.toString();+ }),+ database: z+ .string()+ .trim()+ .min(1)+ .max(64)+ .regex(/^[a-zA-Z0-9_-]+$/, "Database name can only contain letters, numbers, underscores, and hyphens"),+ sslEnabled: z.boolean(),+ sslRejectUnauthorized: z.boolean(),+ sslCertificate: z+ .string()+ .trim()+ .transform((value) => value || undefined)+ .optional()+});++export const MongoDBAccountCredentialsSchema = z.object({+ username: z.string().trim().min(1).max(256, "Username must be 256 characters or less"),+ password: z.string().trim().min(1).max(256, "Password must be 256 characters or less")+});++const BaseMongoDBResourceSchema = BasePamResourceSchema.extend({ resourceType: z.literal(PamResource.MongoDB) });++export const MongoDBResourceSchema = BaseMongoDBResourceSchema.extend({+ connectionDetails: MongoDBResourceConnectionDetailsSchema,+ rotationAccountCredentials: MongoDBAccountCredentialsSchema.nullable().optional()+});++export const SanitizedMongoDBResourceSchema = BaseMongoDBResourceSchema.extend({+ connectionDetails: MongoDBResourceConnectionDetailsSchema,+ rotationAccountCredentials: MongoDBAccountCredentialsSchema.pick({+ username: true+ })+ .nullable()+ .optional()+});++export const MongoDBResourceListItemSchema = z.object({+ name: z.literal("MongoDB"),+ resource: z.literal(PamResource.MongoDB)+});++export const CreateMongoDBResourceSchema = BaseCreateGatewayPamResourceSchema.extend({+ connectionDetails: MongoDBResourceConnectionDetailsSchema,+ rotationAccountCredentials: MongoDBAccountCredentialsSchema.nullable().optional()+});++export const UpdateMongoDBResourceSchema = BaseUpdateGatewayPamResourceSchema.extend({+ connectionDetails: MongoDBResourceConnectionDetailsSchema.optional(),+ rotationAccountCredentials: MongoDBAccountCredentialsSchema.nullable().optional()+});++// Accounts+export const MongoDBAccountSchema = BasePamAccountSchema.extend({+ credentials: MongoDBAccountCredentialsSchema+});++export const CreateMongoDBAccountSchema = BaseCreatePamAccountSchema.extend({+ credentials: MongoDBAccountCredentialsSchema+});++export const UpdateMongoDBAccountSchema = BaseUpdatePamAccountSchema.extend({+ credentials: MongoDBAccountCredentialsSchema.optional()+});++export const SanitizedMongoDBAccountWithResourceSchema = BasePamAccountSchemaWithResource.extend({+ resourceType: z.literal(PamResource.MongoDB),+ credentials: MongoDBAccountCredentialsSchema.pick({+ username: true+ })+});++// Sessions+export const MongoDBSessionCredentialsSchema = MongoDBResourceConnectionDetailsSchema.and(+ MongoDBAccountCredentialsSchema+);diff --git a/backend/src/ee/services/pam-resource/mongodb/mongodb-resource-types.ts b/backend/src/ee/services/pam-resource/mongodb/mongodb-resource-types.tsnew file mode 100644index 0000000000..0d0d18ad25--- /dev/null+++ b/backend/src/ee/services/pam-resource/mongodb/mongodb-resource-types.ts@@ -0,0 +1,16 @@+import { z } from "zod";++import {+ MongoDBAccountCredentialsSchema,+ MongoDBAccountSchema,+ MongoDBResourceConnectionDetailsSchema,+ MongoDBResourceSchema+} from "./mongodb-resource-schemas";++// Resources+export type TMongoDBResource = z.infer<typeof MongoDBResourceSchema>;+export type TMongoDBResourceConnectionDetails = z.infer<typeof MongoDBResourceConnectionDetailsSchema>;++// Accounts+export type TMongoDBAccount = z.infer<typeof MongoDBAccountSchema>;+export type TMongoDBAccountCredentials = z.infer<typeof MongoDBAccountCredentialsSchema>;diff --git a/backend/src/ee/services/pam-resource/pam-resource-enums.ts b/backend/src/ee/services/pam-resource/pam-resource-enums.tsindex 5ccb0125c0..bb7476b62e 100644--- a/backend/src/ee/services/pam-resource/pam-resource-enums.ts+++ b/backend/src/ee/services/pam-resource/pam-resource-enums.ts@@ -6,6 +6,7 @@ export enum PamResource {Kubernetes = "kubernetes",AwsIam = "aws-iam",Redis = "redis",+ MongoDB = "mongodb",Windows = "windows",ActiveDirectory = "active-directory"}diff --git a/backend/src/ee/services/pam-resource/pam-resource-factory.ts b/backend/src/ee/services/pam-resource/pam-resource-factory.tsindex 5142542faa..06f9020431 100644--- a/backend/src/ee/services/pam-resource/pam-resource-factory.ts+++ b/backend/src/ee/services/pam-resource/pam-resource-factory.ts@@ -1,6 +1,7 @@import { activeDirectoryResourceFactory } from "./active-directory/active-directory-resource-factory";import { awsIamResourceFactory } from "./aws-iam/aws-iam-resource-factory";import { kubernetesResourceFactory } from "./kubernetes/kubernetes-resource-factory";+import { mongodbResourceFactory } from "./mongodb/mongodb-resource-factory";import { PamResource } from "./pam-resource-enums";import {TPamAccountCredentials,@@ -27,6 +28,7 @@ export const PAM_RESOURCE_FACTORY_MAP: Record<PamResource, TPamResourceFactoryIm[PamResource.Kubernetes]: kubernetesResourceFactory as TPamResourceFactoryImplementation,[PamResource.AwsIam]: awsIamResourceFactory as TPamResourceFactoryImplementation,[PamResource.Redis]: redisResourceFactory as TPamResourceFactoryImplementation,+ [PamResource.MongoDB]: mongodbResourceFactory as TPamResourceFactoryImplementation,[PamResource.Windows]: windowsResourceFactory as TPamResourceFactoryImplementation,[PamResource.ActiveDirectory]: activeDirectoryResourceFactory as TPamResourceFactoryImplementation};diff --git a/backend/src/ee/services/pam-resource/pam-resource-fns.ts b/backend/src/ee/services/pam-resource/pam-resource-fns.tsindex c4adbc525d..6a05f52663 100644--- a/backend/src/ee/services/pam-resource/pam-resource-fns.ts+++ b/backend/src/ee/services/pam-resource/pam-resource-fns.ts@@ -6,6 +6,7 @@ import { decryptAccountCredentials } from "../pam-account/pam-account-fns";import { getActiveDirectoryResourceListItem } from "./active-directory/active-directory-resource-fns";import { getAwsIamResourceListItem } from "./aws-iam/aws-iam-resource-fns";import { getKubernetesResourceListItem } from "./kubernetes/kubernetes-resource-fns";+import { getMongoDBResourceListItem } from "./mongodb/mongodb-resource-fns";import { getMsSQLResourceListItem } from "./mssql/mssql-resource-fns";import { getMySQLResourceListItem } from "./mysql/mysql-resource-fns";import { TPamResource, TPamResourceConnectionDetails, TPamResourceInternalMetadata } from "./pam-resource-types";@@ -22,6 +23,7 @@ export const listResourceOptions = () => {getAwsIamResourceListItem(),getKubernetesResourceListItem(),getRedisResourceListItem(),+ getMongoDBResourceListItem(),getWindowsResourceListItem(),getActiveDirectoryResourceListItem(),getSshResourceListItem()diff --git a/backend/src/ee/services/pam-resource/pam-resource-types.ts b/backend/src/ee/services/pam-resource/pam-resource-types.tsindex 6d4eee0566..dbb356ac72 100644--- a/backend/src/ee/services/pam-resource/pam-resource-types.ts+++ b/backend/src/ee/services/pam-resource/pam-resource-types.ts@@ -26,6 +26,12 @@ import {TKubernetesResource,TKubernetesResourceConnectionDetails} from "./kubernetes/kubernetes-resource-types";+import {+ TMongoDBAccount,+ TMongoDBAccountCredentials,+ TMongoDBResource,+ TMongoDBResourceConnectionDetails+} from "./mongodb/mongodb-resource-types";import {TMsSQLAccount,TMsSQLAccountCredentials,@@ -76,6 +82,7 @@ export type TPamResource =| TAwsIamResource| TKubernetesResource| TRedisResource+ | TMongoDBResource| TWindowsResource| TActiveDirectoryResource;export type TPamResourceWithFavorite = TPamResources & { isFavorite: boolean };@@ -87,6 +94,7 @@ export type TPamResourceConnectionDetails =| TKubernetesResourceConnectionDetails| TAwsIamResourceConnectionDetails| TRedisResourceConnectionDetails+ | TMongoDBResourceConnectionDetails| TWindowsResourceConnectionDetails| TActiveDirectoryResourceConnectionDetails;export type TPamResourceInternalMetadata = TSSHResourceInternalMetadata | TWindowsResourceInternalMetadata;@@ -100,6 +108,7 @@ export type TPamAccount =| TAwsIamAccount| TKubernetesAccount| TRedisAccount+ | TMongoDBAccount| TWindowsAccount| TActiveDirectoryAccount;@@ -111,6 +120,7 @@ export type TPamAccountCredentials =| TKubernetesAccountCredentials| TAwsIamAccountCredentials| TRedisAccountCredentials+ | TMongoDBAccountCredentials| TWindowsAccountCredentials| TActiveDirectoryAccountCredentials;diff --git a/docs/docs.json b/docs/docs.jsonindex 33fb11328d..9685ef6450 100644--- a/docs/docs.json+++ b/docs/docs.json@@ -865,6 +865,7 @@"documentation/platform/pam/getting-started/resources/active-directory","documentation/platform/pam/getting-started/resources/aws-iam","documentation/platform/pam/getting-started/resources/kubernetes",+ "documentation/platform/pam/getting-started/resources/mongodb","documentation/platform/pam/getting-started/resources/mssql","documentation/platform/pam/getting-started/resources/mysql","documentation/platform/pam/getting-started/resources/postgresql",diff --git a/docs/documentation/platform/pam/getting-started/resources/mongodb.mdx b/docs/documentation/platform/pam/getting-started/resources/mongodb.mdxnew file mode 100644index 0000000000..e914b25d23--- /dev/null+++ b/docs/documentation/platform/pam/getting-started/resources/mongodb.mdx@@ -0,0 +1,195 @@+---+title: "MongoDB"+sidebarTitle: "MongoDB"+description: "Learn how to configure MongoDB access through Infisical PAM for secure, audited, and just-in-time access to your MongoDB databases."+---++Infisical PAM supports secure, just-in-time access to MongoDB databases.+This allows your team to access MongoDB without sharing long-lived credentials, while maintaining a complete audit trail of who accessed what and when.++## How It Works++MongoDB access in Infisical PAM uses an Infisical Gateway to securely proxy connections to your MongoDB server. When a user requests access, Infisical establishes a secure tunnel through the Gateway, enabling secure access without exposing your MongoDB instance directly.++```mermaid+sequenceDiagram+ participant User+ participant CLI as Infisical CLI+ participant Infisical+ participant Gateway as Infisical Gateway+ participant MongoDB as MongoDB Server++ User->>CLI: Request MongoDB access+ CLI->>Infisical: Authenticate & request session+ Infisical-->>CLI: Session credentials & Gateway info+ CLI->>CLI: Start local proxy+ CLI->>Gateway: Establish secure tunnel+ Gateway->>MongoDB: Establish connection+ Gateway->>MongoDB: Authenticate with credentials+ User->>CLI: Database queries+ CLI->>Gateway: Proxy requests+ Gateway->>MongoDB: Forward queries+ MongoDB-->>Gateway: Response+ Gateway-->>CLI: Return response+ CLI-->>User: Query output+```++### Key Concepts++1. **Gateway**: An Infisical Gateway deployed in your network that can reach the MongoDB server. The Gateway handles secure communication between users and your MongoDB instance.++2. **Authentication**: Credentials (username/password) are stored securely in Infisical and used by the Gateway to authenticate with MongoDB on behalf of the user. Authentication is performed against the `admin` database.++3. **Local Proxy**: The Infisical CLI starts a local proxy on your machine that intercepts MongoDB connections and routes them securely through the Gateway to your MongoDB instance.++4. **Session Tracking**: All access sessions are logged, including when the session was created, who accessed the MongoDB instance, session duration, and when it ended.++### Session Tracking++Infisical tracks:++- When the session was created+- Who accessed which MongoDB instance+- Session duration+- When the session ended++<Info>+ **Session Logs**: After ending a session (by stopping the proxy), you can view+ detailed session logs in the Sessions page.+</Info>++## Prerequisites++Before configuring MongoDB access in Infisical PAM, you need:++1. **Infisical Gateway** - A Gateway deployed in your network with access to the MongoDB server+2. **MongoDB Credentials** - Username and password for the MongoDB instance+3. **Infisical CLI** - The Infisical CLI installed on user machines++<Warning>+ **Gateway Required**: MongoDB access requires an Infisical Gateway to be+ deployed and registered with your Infisical instance. The Gateway must have+ network connectivity to your MongoDB server.+</Warning>++## Create the PAM Resource++The PAM Resource represents the connection between Infisical and your MongoDB instance.++<Steps>+ <Step title="Ensure Gateway is Running">+ Before creating the resource, ensure you have an Infisical Gateway running and registered with your Infisical instance. The Gateway must have network access to your MongoDB server.+ </Step>++ <Step title="Create the Resource in Infisical">+ 1. Navigate to your PAM project and go to the **Resources** tab+ 2. Click **Add Resource** and select **MongoDB**+ 3. Enter a **Name** for the resource (e.g., `production-mongo`, `staging-db`)+ 4. Select the **Gateway** that has access to this MongoDB instance+ 5. Enter the **Connection String** - a `mongodb://` or `mongodb+srv://` URI pointing to your MongoDB server (e.g., `mongodb://mongo.example.com:27017` or `mongodb+srv://cluster0.abc123.mongodb.net`). Do not include credentials or a database name in the URI — those are configured separately.+ 6. Enter the **Database Name** - the authentication database to connect to (default: `admin`)+ 7. Configure SSL/TLS options:+ - **Enable SSL**: Toggle to enable TLS/SSL connections (enabled by default)+ - **Reject Unauthorized**: Toggle to verify SSL certificates (enabled by default, recommended for production)+ - **CA Certificate**: Optional CA certificate for custom certificate authorities++ <Note>+ **SSL Configuration**: SSL is enabled by default. For self-signed certificates, you may need to provide the CA certificate or disable certificate validation (not recommended for production).+ </Note>++ </Step>+</Steps>++## Create PAM Accounts++Once you have configured the PAM resource, you'll need to configure a PAM account for your MongoDB resource.+A PAM Account represents a specific set of credentials that users can request access to. You can create multiple accounts per resource, each with different permission levels.++<Steps>+ <Step title="Navigate to Resource">+ Go to the **Resources** tab in your PAM project and open the MongoDB resource you created.+ </Step>++ <Step title="Add New Account">+ Click **Add Account**.+ </Step>++ <Step title="Fill in Account Details">+ Fill in the account details:++ <ParamField path="Name" type="string" required>+ A friendly name for this account (e.g., `readonly-user`, `admin-access`)+ </ParamField>++ <ParamField path="Description" type="string">+ An optional description for this account.+ </ParamField>++ <ParamField path="Username" type="string" required>+ The MongoDB username.+ </ParamField>++ <ParamField path="Password" type="string" required>+ The MongoDB password.+ </ParamField>++ <ParamField path="Require MFA for Access" type="boolean">+ When enabled, users must complete a multi-factor authentication (MFA) challenge before accessing this account. The MFA method used is determined by the organization's enforced method, the user's configured method, or email as a fallback.+ </ParamField>++ </Step>+</Steps>++## Access MongoDB Account++Once your resource and accounts are configured, users can request access through the Infisical CLI:++<Steps>+ <Step title="Get the Access Command">+ 1. Navigate to the **Resources** tab in your PAM project and open the MongoDB resource+ 2. In the resource's accounts section, find the account you want to access+ 3. Click the **Access** button for that account+ 4. Copy the provided CLI command++ The command follows this format:+ ```bash+ infisical pam db access --resource <resource-name> --account <account-name> --project-id <project-id> --duration <duration> --domain <infisical-url>+ ```++ </Step>++ <Step title="Run the Access Command">+ Run the copied command in your terminal.++ The CLI will:+ 1. Authenticate with Infisical+ 2. Establish a secure connection through the Gateway+ 3. Start a local proxy on your machine+ 4. Display a local connection URI you can use to connect++ </Step>++ <Step title="Connect to MongoDB">+ Once the proxy is running, connect to MongoDB using the connection URI displayed by the CLI. You can use any MongoDB client — no password is needed, as the Gateway injects the real credentials on your behalf.++ **Using mongosh:**+ ```bash+ mongosh "<connection-uri>"+ ```++ **Using other clients:**++ You can also use GUI clients such as MongoDB Compass, Studio 3T, DataGrip, or NoSQLBooster. Use the connection URI shown in the CLI output, or point them to `localhost` on the port shown. Leave the password field empty.++ </Step>++ <Step title="End the Session">+ When you're done, stop the proxy by pressing `Ctrl+C` in the terminal where it's running. This will:+ - Close the secure tunnel+ - End the session+ - Log the session details to Infisical++ You can view session logs in the **Sessions** page of your PAM project.++ </Step>+</Steps>diff --git a/frontend/src/hooks/api/pam/types/index.ts b/frontend/src/hooks/api/pam/types/index.tsindex 5c1e02a681..3e49bb535c 100644--- a/frontend/src/hooks/api/pam/types/index.ts+++ b/frontend/src/hooks/api/pam/types/index.ts@@ -10,6 +10,7 @@ import {import { TActiveDirectoryAccount, TActiveDirectoryResource } from "./active-directory-resource";import { TAwsIamAccount, TAwsIamResource } from "./aws-iam-resource";import { TKubernetesAccount, TKubernetesResource } from "./kubernetes-resource";+import { TMongoDBAccount, TMongoDBResource } from "./mongodb-resource";import { TMsSQLAccount, TMsSQLResource } from "./mssql-resource";import { TMySQLAccount, TMySQLResource } from "./mysql-resource";import { TPostgresAccount, TPostgresResource } from "./postgres-resource";@@ -20,6 +21,7 @@ import { TWindowsAccount, TWindowsResource } from "./windows-server-resource";export * from "./active-directory-resource";export * from "./aws-iam-resource";export * from "./kubernetes-resource";+export * from "./mongodb-resource";export * from "./mssql-resource";export * from "./mysql-resource";export * from "./postgres-resource";@@ -32,6 +34,7 @@ export type TPamResource =| TMySQLResource| TMsSQLResource| TRedisResource+ | TMongoDBResource| TSSHResource| TAwsIamResource| TKubernetesResource@@ -43,6 +46,7 @@ export type TPamAccount =| TMySQLAccount| TMsSQLAccount| TRedisAccount+ | TMongoDBAccount| TSSHAccount| TAwsIamAccount| TKubernetesAccountdiff --git a/frontend/src/hooks/api/pam/types/mongodb-resource.ts b/frontend/src/hooks/api/pam/types/mongodb-resource.tsnew file mode 100644index 0000000000..1c746bd29b--- /dev/null+++ b/frontend/src/hooks/api/pam/types/mongodb-resource.ts@@ -0,0 +1,26 @@+import { PamResourceType } from "../enums";+import { TBasePamAccount } from "./base-account";+import { TBasePamResource } from "./base-resource";++export type TMongoDBConnectionDetails = {+ connectionString: string;+ database: string;+ sslEnabled: boolean;+ sslRejectUnauthorized: boolean;+ sslCertificate?: string;+};++export type TMongoDBCredentials = {+ username: string;+ password: string;+};++// Resources+export type TMongoDBResource = TBasePamResource & { resourceType: PamResourceType.MongoDB } & {+ connectionDetails: TMongoDBConnectionDetails;+};++// Accounts+export type TMongoDBAccount = TBasePamAccount & {+ credentials: TMongoDBCredentials;+};diff --git a/frontend/src/pages/pam/PamAccountByIDPage/components/PamAccountCredentialsSection.tsx b/frontend/src/pages/pam/PamAccountByIDPage/components/PamAccountCredentialsSection.tsxindex 218c43fcb1..c6f96a9ac3 100644--- a/frontend/src/pages/pam/PamAccountByIDPage/components/PamAccountCredentialsSection.tsx+++ b/frontend/src/pages/pam/PamAccountByIDPage/components/PamAccountCredentialsSection.tsx@@ -114,6 +114,7 @@ const CredentialsContent = ({ account }: { account: TPamAccount }) => {case PamResourceType.Postgres:case PamResourceType.MySQL:case PamResourceType.MsSQL:+ case PamResourceType.MongoDB:case PamResourceType.Redis:return <SqlCredentialsContent credentials={account.credentials as TBaseSqlCredentials} />;case PamResourceType.SSH:@@ -217,6 +218,7 @@ const getSensitiveFieldDefs = (account: TPamAccount): SensitiveFieldDef[] => {case PamResourceType.Postgres:case PamResourceType.MySQL:case PamResourceType.MsSQL:+ case PamResourceType.MongoDB:case PamResourceType.Redis:case PamResourceType.Windows:case PamResourceType.ActiveDirectory:diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamAccessAccountModal.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamAccessAccountModal.tsxindex 14ef7a4a83..1c60cf568c 100644--- a/frontend/src/pages/pam/PamAccountsPage/components/PamAccessAccountModal.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamAccessAccountModal.tsx@@ -74,6 +74,7 @@ export const PamAccessAccountModal = ({ isOpen, onOpenChange, account, projectIdcase PamResourceType.Postgres:case PamResourceType.MySQL:case PamResourceType.MsSQL:+ case PamResourceType.MongoDB:return `infisical pam db access --resource ${account.resource.name} --account ${account.name} --project-id ${projectId} --duration ${cliDuration} --domain ${siteURL}`;case PamResourceType.Redis:return `infisical pam redis access --resource ${account.resource.name} --account ${account.name} --project-id ${projectId} --duration ${cliDuration} --domain ${siteURL}`;diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/MongoDBAccountForm.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/MongoDBAccountForm.tsxnew file mode 100644index 0000000000..b364848569--- /dev/null+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/MongoDBAccountForm.tsx@@ -0,0 +1,76 @@+import { FormProvider, useForm } from "react-hook-form";+import { zodResolver } from "@hookform/resolvers/zod";+import { z } from "zod";++import { Button, SheetFooter } from "@app/components/v3";+import { PamResourceType, TMongoDBAccount } from "@app/hooks/api/pam";+import { UNCHANGED_PASSWORD_SENTINEL } from "@app/hooks/api/pam/constants";++import { BaseSqlAccountSchema } from "./shared/sql-account-schemas";+import { SqlAccountFields } from "./shared/SqlAccountFields";+import { GenericAccountFields, genericAccountFieldsSchema } from "./GenericAccountFields";+import { MetadataFields } from "./MetadataFields";+import { RequireMfaField } from "./RequireMfaField";++type Props = {+ account?: TMongoDBAccount;+ resourceId?: string;+ resourceType?: PamResourceType;+ onSubmit: (formData: FormData) => Promise<void>;+ closeSheet: () => void;+};++const formSchema = genericAccountFieldsSchema.extend({+ credentials: BaseSqlAccountSchema,+ requireMfa: z.boolean().nullable().optional()+});++type FormData = z.infer<typeof formSchema>;++export const MongoDBAccountForm = ({ account, onSubmit, closeSheet }: Props) => {+ const isUpdate = Boolean(account);++ const form = useForm<FormData>({+ resolver: zodResolver(formSchema),+ defaultValues: account+ ? {+ ...account,+ credentials: {+ ...account.credentials,+ password: UNCHANGED_PASSWORD_SENTINEL+ }+ }+ : undefined+ });++ const {+ handleSubmit,+ formState: { isSubmitting, isDirty }+ } = form;++ return (+ <FormProvider {...form}>+ <form className="flex flex-1 flex-col overflow-hidden" onSubmit={handleSubmit(onSubmit)}>+ <div className="flex min-h-0 flex-1 shrink flex-col gap-4 overflow-y-auto p-4 pb-8">+ <GenericAccountFields />+ <SqlAccountFields isUpdate={isUpdate} />+ <RequireMfaField />+ <MetadataFields />+ </div>+ <SheetFooter className="shrink-0 border-t">+ <Button+ isPending={isSubmitting}+ isDisabled={isSubmitting || !isDirty}+ variant="neutral"+ type="submit"+ >+ {isUpdate ? "Update Account" : "Add Account"}+ </Button>+ <Button onClick={() => closeSheet()} variant="outline" className="mr-auto" type="button">+ Cancel+ </Button>+ </SheetFooter>+ </form>+ </FormProvider>+ );+};diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/PamAccountForm.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/PamAccountForm.tsxindex 9c1701df27..e440e6afd6 100644--- a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/PamAccountForm.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/PamAccountForm.tsx@@ -10,6 +10,7 @@ import { DiscriminativePick } from "@app/types";import { ActiveDirectoryAccountForm } from "./ActiveDirectoryAccountForm";import { AwsIamAccountForm } from "./AwsIamAccountForm";import { KubernetesAccountForm } from "./KubernetesAccountForm";+import { MongoDBAccountForm } from "./MongoDBAccountForm";import { MsSQLAccountForm } from "./MsSQLAccountForm";import { MySQLAccountForm } from "./MySQLAccountForm";import { PostgresAccountForm } from "./PostgresAccountForm";@@ -94,6 +95,15 @@ const CreateForm = ({resourceType={resourceType}/>);+ case PamResourceType.MongoDB:+ return (+ <MongoDBAccountForm+ onSubmit={onSubmit}+ closeSheet={closeSheet}+ resourceId={resourceId}+ resourceType={resourceType}+ />+ );case PamResourceType.Redis:return (<RedisAccountForm@@ -192,6 +202,10 @@ const UpdateForm = ({ account, closeSheet }: UpdateFormProps) => {return (<MsSQLAccountForm account={account as any} onSubmit={onSubmit} closeSheet={closeSheet} />);+ case PamResourceType.MongoDB:+ return (+ <MongoDBAccountForm account={account as any} onSubmit={onSubmit} closeSheet={closeSheet} />+ );case PamResourceType.Redis:return (<RedisAccountFormdiff --git a/frontend/src/pages/pam/PamResourceByIDPage/components/PamResourceConnectionSection.tsx b/frontend/src/pages/pam/PamResourceByIDPage/components/PamResourceConnectionSection.tsxindex d40f89f2db..d5b69a210a 100644--- a/frontend/src/pages/pam/PamResourceByIDPage/components/PamResourceConnectionSection.tsx+++ b/frontend/src/pages/pam/PamResourceByIDPage/components/PamResourceConnectionSection.tsx@@ -25,16 +25,41 @@ const SSLStatusBadge = ({ enabled }: { enabled: boolean }) => (const SqlConnectionDetails = ({connectionDetails}: {- connectionDetails: { host: string; port: number; database: string; sslEnabled: boolean };+ connectionDetails: { host: string; port?: number; database: string; sslEnabled: boolean };}) => (<><Detail><DetailLabel>Host</DetailLabel><DetailValue>{connectionDetails.host}</DetailValue></Detail>+ {connectionDetails.port != null && (+ <Detail>+ <DetailLabel>Port</DetailLabel>+ <DetailValue>{connectionDetails.port}</DetailValue>+ </Detail>+ )}<Detail>- <DetailLabel>Port</DetailLabel>- <DetailValue>{connectionDetails.port}</DetailValue>+ <DetailLabel>Database</DetailLabel>+ <DetailValue>{connectionDetails.database}</DetailValue>+ </Detail>+ <Detail>+ <DetailLabel>SSL</DetailLabel>+ <DetailValue>+ <SSLStatusBadge enabled={connectionDetails.sslEnabled} />+ </DetailValue>+ </Detail>+ </>+);++const MongoDBConnectionDetails = ({+ connectionDetails+}: {+ connectionDetails: { connectionString: string; database: string; sslEnabled: boolean };+}) => (+ <>+ <Detail>+ <DetailLabel>Connection String</DetailLabel>+ <DetailValue>{connectionDetails.connectionString}</DetailValue></Detail><Detail><DetailLabel>Database</DetailLabel>@@ -190,6 +215,8 @@ const ConnectionDetailsContent = ({ resource }: Props) => {case PamResourceType.MySQL:case PamResourceType.MsSQL:return <SqlConnectionDetails connectionDetails={resource.connectionDetails} />;+ case PamResourceType.MongoDB:+ return <MongoDBConnectionDetails connectionDetails={resource.connectionDetails} />;case PamResourceType.SSH:return <SSHConnectionDetails connectionDetails={resource.connectionDetails} />;case PamResourceType.Redis:diff --git a/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/MongoDBResourceForm.tsx b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/MongoDBResourceForm.tsxnew file mode 100644index 0000000000..717e11e327--- /dev/null+++ b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/MongoDBResourceForm.tsx@@ -0,0 +1,265 @@+import { Controller, FormProvider, useForm } from "react-hook-form";+import { zodResolver } from "@hookform/resolvers/zod";+import { InfoIcon } from "lucide-react";+import { z } from "zod";++import {+ Button,+ Field,+ FieldContent,+ FieldError,+ FieldLabel,+ Label,+ SheetFooter,+ Switch,+ TextArea,+ Tooltip,+ TooltipContent,+ TooltipTrigger,+ UnstableInput+} from "@app/components/v3";+import { PamResourceType, TMongoDBResource } from "@app/hooks/api/pam";++import { GenericResourceFields, genericResourceFieldsSchema } from "./GenericResourceFields";+import { MetadataFields } from "./MetadataFields";++type Props = {+ resource?: TMongoDBResource;+ onSubmit: (formData: FormData) => Promise<void>;+ closeSheet: () => void;+};++const formSchema = genericResourceFieldsSchema.extend({+ resourceType: z.literal(PamResourceType.MongoDB),+ connectionDetails: z.object({+ connectionString: z+ .string()+ .trim()+ .min(1, "Connection string required")+ .superRefine((val, ctx) => {+ // 1. Protocol check (regex instead of new URL() to support comma-separated replica set hosts)+ const protocolMatch = val.match(/^mongodb(?:\+srv)?:\/\//i);+ if (!protocolMatch) {+ ctx.addIssue({+ code: z.ZodIssueCode.custom,+ message:+ "Invalid MongoDB connection string. Must start with mongodb:// or mongodb+srv://"+ });+ return;+ }++ const rest = val.slice(protocolMatch[0].length);+ const hostAndPath = rest.split("?")[0];++ // 2. Credentials check — userinfo appears before @ in the authority+ if (hostAndPath.includes("@")) {+ ctx.addIssue({+ code: z.ZodIssueCode.custom,+ message:+ "Credentials should not be included in the connection string — they are managed separately per account"+ });+ return;+ }++ // 3. Database in path — anything after the first / beyond the hosts+ const slashIndex = hostAndPath.indexOf("/");+ if (slashIndex !== -1 && hostAndPath.length > slashIndex + 1) {+ ctx.addIssue({+ code: z.ZodIssueCode.custom,+ message:+ "Database should not be included in the connection string — use the Database field instead"+ });+ }+ }),+ database: z+ .string()+ .trim()+ .min(1, "Database required")+ .regex(+ /^[a-zA-Z0-9_-]+$/,+ "Database name can only contain letters, numbers, underscores, and hyphens"+ )+ .default("admin"),+ sslEnabled: z.boolean().default(true),+ sslRejectUnauthorized: z.boolean().default(true),+ sslCertificate: z+ .string()+ .trim()+ .transform((value) => value || undefined)+ .optional()+ })+});++type FormData = z.infer<typeof formSchema>;++export const MongoDBResourceForm = ({ resource, onSubmit, closeSheet }: Props) => {+ const isUpdate = Boolean(resource);++ const form = useForm<FormData>({+ resolver: zodResolver(formSchema),+ defaultValues: resource+ ? {+ ...resource,+ gateway: resource.gatewayId ? { id: resource.gatewayId, name: "" } : undefined,+ connectionDetails: resource.connectionDetails+ }+ : {+ resourceType: PamResourceType.MongoDB,+ gateway: undefined,+ connectionDetails: {+ connectionString: "",+ database: "admin",+ sslEnabled: true,+ sslRejectUnauthorized: true,+ sslCertificate: undefined+ }+ }+ });++ const {+ handleSubmit,+ control,+ watch,+ formState: { isSubmitting, isDirty }+ } = form;++ const sslEnabled = watch("connectionDetails.sslEnabled");++ return (+ <FormProvider {...form}>+ <form+ onSubmit={handleSubmit((data) => onSubmit(data as FormData))}+ className="flex flex-1 flex-col overflow-hidden"+ >+ <div className="flex min-h-0 flex-1 shrink flex-col gap-4 overflow-y-auto p-4 pb-8">+ <GenericResourceFields />++ {/* Connection */}+ <div className="flex flex-col gap-3">+ <Label>Connection</Label>++ <Controller+ name="connectionDetails.connectionString"+ control={control}+ render={({ field, fieldState: { error } }) => (+ <Field>+ <FieldLabel>+ Connection String+ <Tooltip>+ <TooltipTrigger asChild>+ <InfoIcon className="mb-0.5 inline-block size-3 text-accent" />+ </TooltipTrigger>+ <TooltipContent>+ Supports mongodb:// and mongodb+srv:// URIs. Do not include credentials or+ database in the URI.+ </TooltipContent>+ </Tooltip>+ </FieldLabel>+ <FieldContent>+ <UnstableInput+ {...field}+ placeholder="mongodb+srv://cluster0.abc.mongodb.net"+ isError={Boolean(error)}+ />+ <FieldError errors={[error]} />+ </FieldContent>+ </Field>+ )}+ />+ <Controller+ name="connectionDetails.database"+ control={control}+ render={({ field, fieldState: { error } }) => (+ <Field>+ <FieldLabel>Database Name</FieldLabel>+ <FieldContent>+ <UnstableInput {...field} isError={Boolean(error)} />+ <FieldError errors={[error]} />+ </FieldContent>+ </Field>+ )}+ />+ </div>++ {/* SSL */}+ <div className="flex flex-col gap-3">+ <Label>SSL</Label>++ <Controller+ name="connectionDetails.sslEnabled"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <Field orientation="horizontal">+ <FieldLabel>Enable SSL</FieldLabel>+ <Switch variant="project" checked={value} onCheckedChange={onChange} />+ <FieldError errors={[error]} />+ </Field>+ )}+ />++ <Controller+ name="connectionDetails.sslCertificate"+ control={control}+ render={({ field, fieldState: { error } }) => (+ <Field>+ <FieldLabel>CA Certificate</FieldLabel>+ <FieldContent>+ <TextArea+ {...field}+ placeholder="-----BEGIN CERTIFICATE-----..."+ disabled={!sslEnabled}+ />+ <FieldError errors={[error]} />+ </FieldContent>+ </Field>+ )}+ />++ <Controller+ name="connectionDetails.sslRejectUnauthorized"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <Field orientation="horizontal">+ <FieldLabel>+ Reject Unauthorized+ <Tooltip>+ <TooltipTrigger asChild>+ <InfoIcon className="mb-0.5 inline-block size-3 text-accent" />+ </TooltipTrigger>+ <TooltipContent>+ If enabled, Infisical will only connect to the server if it has a valid,+ trusted SSL certificate.+ </TooltipContent>+ </Tooltip>+ </FieldLabel>+ <Switch+ variant="project"+ disabled={!sslEnabled}+ checked={sslEnabled ? value : false}+ onCheckedChange={onChange}+ />+ <FieldError errors={[error]} />+ </Field>+ )}+ />+ </div>++ <MetadataFields />+ </div>+ <SheetFooter className="shrink-0 border-t">+ <Button+ isPending={isSubmitting}+ isDisabled={isSubmitting || !isDirty}+ variant="neutral"+ type="submit"+ >+ {isUpdate ? "Update Details" : "Create Resource"}+ </Button>+ <Button onClick={closeSheet} variant="outline" className="mr-auto" type="button">+ Cancel+ </Button>+ </SheetFooter>+ </form>+ </FormProvider>+ );+};diff --git a/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/PamResourceForm.tsx b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/PamResourceForm.tsxindex 2fbf59190e..efca8f24be 100644--- a/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/PamResourceForm.tsx+++ b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/PamResourceForm.tsx@@ -12,6 +12,7 @@ import { PamResourceHeader } from "../PamResourceHeader";import { ActiveDirectoryResourceForm } from "./ActiveDirectoryResourceForm";import { AwsIamResourceForm } from "./AwsIamResourceForm";import { KubernetesResourceForm } from "./KubernetesResourceForm";+import { MongoDBResourceForm } from "./MongoDBResourceForm";import { MsSQLResourceForm } from "./MsSQLResourceForm";import { MySQLResourceForm } from "./MySQLResourceForm";import { PostgresResourceForm } from "./PostgresResourceForm";@@ -66,6 +67,8 @@ const CreateForm = ({ resourceType, closeSheet, projectId }: CreateFormProps) =>return <MySQLResourceForm onSubmit={onSubmit} closeSheet={closeSheet} />;case PamResourceType.MsSQL:return <MsSQLResourceForm onSubmit={onSubmit} closeSheet={closeSheet} />;+ case PamResourceType.MongoDB:+ return <MongoDBResourceForm onSubmit={onSubmit} closeSheet={closeSheet} />;case PamResourceType.Redis:return <RedisResourceForm onSubmit={onSubmit} closeSheet={closeSheet} />;case PamResourceType.SSH:@@ -119,6 +122,10 @@ const UpdateForm = ({ resource, closeSheet }: UpdateFormProps) => {return <MySQLResourceForm resource={resource} onSubmit={onSubmit} closeSheet={closeSheet} />;case PamResourceType.MsSQL:return <MsSQLResourceForm resource={resource} onSubmit={onSubmit} closeSheet={closeSheet} />;+ case PamResourceType.MongoDB:+ return (+ <MongoDBResourceForm resource={resource} onSubmit={onSubmit} closeSheet={closeSheet} />+ );case PamResourceType.Redis:return <RedisResourceForm resource={resource} onSubmit={onSubmit} closeSheet={closeSheet} />;case PamResourceType.SSH:diff --git a/frontend/src/pages/pam/PamResourcesPage/components/ResourceTypeSelect.tsx b/frontend/src/pages/pam/PamResourcesPage/components/ResourceTypeSelect.tsxindex 5353cb0d58..fc8ec6d17b 100644--- a/frontend/src/pages/pam/PamResourcesPage/components/ResourceTypeSelect.tsx+++ b/frontend/src/pages/pam/PamResourcesPage/components/ResourceTypeSelect.tsx@@ -17,7 +17,6 @@ type Props = {const COMING_SOON_RESOURCES = [{ name: "OracleDB", resource: PamResourceType.OracleDB },{ name: "SQLite", resource: PamResourceType.SQLite },- { name: "MongoDB", resource: PamResourceType.MongoDB },{ name: "Cassandra", resource: PamResourceType.Cassandra },{ name: "CockroachDB", resource: PamResourceType.CockroachDB },{ name: "DynamoDB", resource: PamResourceType.DynamoDB },diff --git a/frontend/src/pages/pam/PamSessionsByIDPage/components/PamSessionLogsSection.tsx b/frontend/src/pages/pam/PamSessionsByIDPage/components/PamSessionLogsSection.tsxindex f4313a4f8e..576c78d23d 100644--- a/frontend/src/pages/pam/PamSessionsByIDPage/components/PamSessionLogsSection.tsx+++ b/frontend/src/pages/pam/PamSessionsByIDPage/components/PamSessionLogsSection.tsx@@ -24,6 +24,7 @@ export const PamSessionLogsSection = ({ session }: Props) => {session.resourceType === PamResourceType.Postgres ||session.resourceType === PamResourceType.MySQL ||session.resourceType === PamResourceType.MsSQL ||+ session.resourceType === PamResourceType.MongoDB ||session.resourceType === PamResourceType.Redis;const isHttpSession = session.resourceType === PamResourceType.Kubernetes;const isAwsIamSession = session.resourceType === PamResourceType.AwsIam;