feat(pam): add MongoDB support#5817
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Greptile SummaryThis PR adds MongoDB as a fully supported PAM resource type, wiring it into the existing SQL resource factory infrastructure (gateway proxy, SSL/TLS handling, account CRUD endpoints) and adding the corresponding frontend forms and UI integration. The change is well-structured and follows the patterns established by the existing SQL adapters (Postgres, MySQL, MSSQL). Key changes:
Issues found:
Confidence Score: 3/5Not ready to merge — the hardcoded The overall integration is well-structured and follows established patterns. However, the hardcoded
Important Files Changed
Reviews (3): Last reviewed commit: "Fix URL injection in MongoDB connection ..." | Re-trigger Greptile |
Reuse BaseSqlResourceConnectionDetailsSchema for MongoDB connection details and add MongoDB as a case in makeSqlConnection, eliminating the dedicated mongodb-resource-factory.ts (250 lines).
|
@greptile could you review this again? pay attention to the latest updates (changes and replies to the previous comments) |
1 similar comment
|
@greptile could you review this again? pay attention to the latest updates (changes and replies to the previous comments) |
…mongodb-resources-in-pam # Conflicts: # frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/PamAccountForm.tsx # frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/PamResourceForm.tsx # frontend/src/pages/pam/PamResourcesPage/components/ResourceTypeSelect.tsx
…e hack Users with MongoDB SRV hosts (mongodb+srv://) no longer need to enter 0 as the port. Leaving the port empty now signals an SRV connection. The backend resolves SRV only during resource/account validation; session credentials pass the original host to the CLI which handles SRV natively.
…mongodb-resources-in-pam # Conflicts: # backend/package-lock.json
|
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
|---|---|---|---|---|---|
| 29206045 | Triggered | Generic Password | 2334268 | backend/src/ee/services/pki-scep/pki-scep-service.ts | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secret safely. Learn here the best practices.
- Revoke and rotate this secret.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
|
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
|---|---|---|---|---|---|
| 29206045 | Triggered | Generic Password | 2334268 | backend/src/ee/services/pki-scep/pki-scep-service.ts | View secret |
| 28944329 | Triggered | PostHog Project API Key | 4d5a8c0 | docs/docs.json | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secrets safely. Learn here the best practices.
- Revoke and rotate these secrets.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
|
Also, testing with Atlas did not work |
MongoDB doesn't use knex and isn't a SQL database — give it its own factory following the Redis/SSH pattern. Also replaces auth error string matching with MongoServerError error code 18.
Support MongoDB URIs (mongodb+srv://, mongodb://) in the host field so users can specify authSource and other connection options directly. Remove the separate port field since it's now part of the host. - Remove port from MongoDB schema, types, and form - Accept full MongoDB URIs in host field with relay-routing extraction - Extract authSource from URI for validation connections (default: admin) - Merge host/port into single URI-capable field in frontend form
Replaces the freeform host field with a proper connectionString field validated by the mongodb-connection-string-url library. Rejects embedded credentials and database in the URI path. Adds allowlist regex to the database field. Updates frontend forms and display components accordingly.
Validate MongoDB connection strings client-side so errors display inline in the form instead of as a toast/modal notification.
…ssword - Replace new URL() with regex-based parsing in the frontend MongoDB form to support comma-separated replica set hosts - Require non-empty password in MongoDBAccountCredentialsSchema to match other resource schemas and prevent silent credential omission

Context
Adds MongoDB support to PAM
Related Infisical/cli#162
Screenshots
Steps to verify the change
Type
Checklist
type(scope): short description(scope is optional, e.g.,fix: prevent crash on syncorfix(api): handle null response).