Skip to content

Support MongoDB targets - #2579

Open
chenmortal wants to merge 9 commits into
warp-tech:mainfrom
chenmortal:feature-mongodb
Open

chenmortal wants to merge 9 commits into
warp-tech:mainfrom
chenmortal:feature-mongodb

Conversation

@chenmortal

@chenmortal chenmortal commented Sep 13, 2026

Copy link
Copy Markdown

Closes #2577

Description

Based on my own project mongowire (a Mongo wire protocol parser), I've implemented MongoDB protocol proxying for Warpgate, integrated it into the main Warpgate codebase, added frontend support, and completed end-to-end test verification.
...

AI Usage

Choose the level of AI involvement for this PR.

  • Fully vibe coded
  • AI-designed, AI-coded, manually checked
  • Human-designed, AI-coded
  • Human-designed, human-coded (includes AI autocompletions and boilerplate gen)

This is not to block AI contributions but rather to speed up PR review (saves time on trying to deduce the logic behind AI hallucinations).
front web
image
mongsh connect warpgate server
image
warpgate server log
image
mongsh command find
image
warpgate server log
image

chenmortal and others added 7 commits September 13, 2026 02:16
New protocol crate proxying OP_MSG between MongoDB clients and targets,
built on the mongowire crates (wire parsing, framing, BSON, SCRAM client).

Client auth is PLAIN over mandatory TLS (warpgate terminates it with the
standard shared DbAuthAuthorization flow, user#target selectors); the
upstream connection authenticates with the target's stored credentials
via SCRAM-SHA-256. OP_QUERY is answered for the legacy hello/isMaster
handshake only; OP_COMPRESSED and pre-3.6 opcodes are rejected.

Integration: Protocol::Mongo, TargetMongoOptions (serde "mongodb"),
MongoConfig listener (default :37017), TargetKind::Mongo, credential
policy and MFA matrix entries, tls_listener wiring.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Admin: MongoDB in the target-kind chooser and target create defaults,
the per-kind target form (host, port, username, password, auth source,
TLS), protocol reference docs, target list labels, and a MongoDB row in
the per-protocol credential policy editor. Gateway: target list labels
and mongosh connection instructions (?authMechanism=PLAIN&tls=true with
the user#target selector). Session lists show the MongoDB protocol name.

Regenerated OpenAPI schemas; PortsInfo/ExternalHostsInfo gained a mongo
entry so the gateway surfaces the listener port.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Adds the --mongo-port flag to unattended setup and an interactive
"Accept MongoDB connections?" prompt (with the usual endpoint question),
mirroring the MySQL/PostgreSQL flow, and copies the instance TLS
certificate into the mongo listener config.

Co-Authored-By: Claude Code <noreply@anthropic.com>
The client-facing leg now sniffs the first bytes of each connection: a
valid MongoDB wire header means plaintext, anything else goes through
the TLS handshake (its bytes are replayed into the TLS layer). This
matches MongoDB's tlsMode=prefer and stops clients without ?tls=true
from hanging on repeated TLS handshake failures. Plaintext connections
are logged with a warning since PLAIN then sends credentials
unencrypted; the target-side TLS setting keeps governing only the
warpgate-to-upstream leg. UI copy updated to match.

Co-Authored-By: Claude Code <noreply@anthropic.com>
An upstream "Authentication failed." on its own does not say which
credential was tried; the proxy error now carries the target username
and auth source so a misconfigured target is diagnosable from the log.

Co-Authored-By: Claude Code <noreply@anthropic.com>
)
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
@chenmortal chenmortal changed the title Support MongoDB targets #2577 Support MongoDB targets Sep 13, 2026
The workspace cranky profile denies clippy::expect_used,
clippy::unwrap_used and clippy::indexing_slicing; parse the first-chunk
header through get() into a fixed-size buffer instead.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@chenmortal

Copy link
Copy Markdown
Author

Build / Config schema check (pull_request), I've added MongoDB support to the config file, as was necessary.

@chenmortal

Copy link
Copy Markdown
Author

Code scanning results / CodeQL This is a misreading — the PBKDF2-HMAC-SHA-256 here is not password storage. SCRAM-SHA-256 (RFC 7677) mandates it for computing the challenge-response proof sent to the upstream MongoDB server at auth time; it can't be swapped for argon2id because the server verifies it against its own SCRAM credentials. Warpgate's at-rest password storage is still argon2id. I've updated the comment to make this explicit.

@chenmortal
chenmortal marked this pull request as draft September 13, 2026 11:05
@chenmortal
chenmortal marked this pull request as ready for review September 13, 2026 11:05
@chenmortal

Copy link
Copy Markdown
Author

Test / Tests (pull_request) The test job is failing due to Docker image pull access issues in the integration tests.

@Eugeny

Eugeny commented Sep 14, 2026

Copy link
Copy Markdown
Member

Thank you for the PR! Currently there is a large backlog so expect a delay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support MongoDB targets

2 participants