The Simplest Way to Make Kong and Mercurial Work Like They Should
You pair Kong and Mercurial in production to manage network traffic to source code repos. Kong handles incoming web requests and routes valid users to your Mercurial server. This workflow lets your team clone, pull, and push code over standard web ports. You get one entry point for all code traffic and clear rules for every user. Teams use this setup to keep internal code hosts off the public internet. It also gives admins one place to check logs and set rate limits. How Kong and Mercurial ha
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
You pair Kong and Mercurial in production to manage network traffic to source code repos. Kong handles incoming web requests and routes valid users to your Mercurial server.
This workflow lets your team clone, pull, and push code over standard web ports. You get one entry point for all code traffic and clear rules for every user. Teams use this setup to keep internal code hosts off the public internet. It also gives admins one place to check logs and set rate limits.
How Kong and Mercurial handle login and data flow
Data flows from the developer machine to Kong before it reaches the Mercurial host. A developer runs a push or pull command from their local terminal. The local client sends that web request to the public address on Kong. Kong checks the request headers to verify the user identity and key.
If the key is valid, Kong forwards the request to the backend Mercurial server. Mercurial reads the user identity and checks its own file rules for that repo. Then Mercurial sends the code changes back through Kong to the user. If the key fails the check, Kong drops the request right away.
This split keeps your code host safe from bad traffic and random web scans. Kong deals with web certs, rate limits, and basic login checks at the edge. Mercurial focuses on repo history, branch rules, and file locks on the backend. Both tools do what they do best without extra load on the repo host.
Common failure modes and how to scope roles
Many teams make mistakes when they link these two tools for the first time. The biggest failure mode is using one shared service account for all repo traffic. When Kong uses one static key to talk to Mercurial, you lose user logs. Every code push looks like it came from the same system user.
Broad tokens are another common risk in this setup. Developers often create long-lived keys with full write rights to every single repo. If a laptop gets lost, an attacker can read or delete all your code. Unlogged queries also cause problems during a security audit. If Kong only logs web status codes, you do not know which repo changed.
End-to-End Encryption + Kong Security Plugins: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
You can fix these gaps with strict role scoping and tight network paths. First, lock down the network so Mercurial only accepts traffic from your Kong nodes. Block all direct user traffic to the repo server with a firewall rule. Next, pass the real user identity from Kong to Mercurial in a trusted header.
Give each team member a unique role with read or write rules per repo. Build bots should only get read keys for the specific repos they need. Set short time limits on user keys so developers must log in again each day. Finally, turn on detailed request logs on both systems to track every clone and push.
Keeping repo rules and web routes in sync
As your team grows, you will add more repos and more web routes. Keep your route rules in version control so everyone can review changes. When you create a new Mercurial repo, map its path in Kong right away. Assign a specific team role to that route before anyone pushes code.
Test your setup with a regular user account, not an admin key. Try to pull from a private repo without a key to confirm Kong blocks it. Then try to push with a read-only key to confirm Mercurial stops the write. Regular checks keep your code safe and help your team ship work fast.
Check database and API queries on the wire
Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.
Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.
Frequently asked questions
Can Kong route traffic to multiple Mercurial repos at once?
Yes, Kong can route requests to many Mercurial repos using different URL paths. You set a rule for each path and point it to the right repo host.
How do we stop build scripts from using shared admin keys?
Create a separate bot identity for each build pipeline with read-only repo permissions. Rotate those bot keys on a set schedule and block write actions from build servers.
What should we log when developers push code through this setup?
Log the user identity, the repo path, the time, and the request method. Keep these logs in a central store so your security team can review them.
Related guides
In this post