The Simplest Way to Make Azure Active Directory and Mercurial Work Like They Should
Pairing azure active directory and mercurial lets your team use one cloud login for code. This setup stops password sharing and links every code change to a real person. Mercurial is a fast tool for tracking code changes across your team. It does not come with a built-in cloud login check. Azure Active Directory holds your company users, groups, and login rules. When you link them, your web server checks the directory before anyone reads or writes code. This gives your team safe code hosting wi
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.
Pairing azure active directory and mercurial lets your team use one cloud login for code. This setup stops password sharing and links every code change to a real person.
Mercurial is a fast tool for tracking code changes across your team. It does not come with a built-in cloud login check. Azure Active Directory holds your company users, groups, and login rules. When you link them, your web server checks the directory before anyone reads or writes code. This gives your team safe code hosting without extra user lists.
How logins and roles work with azure active directory and mercurial
Mercurial needs a web server or SSH host to share code over a network. The tool itself only cares about files and change history. Your host server handles the login step first. When a user runs a pull or push command, the server pauses the request. It asks the directory to check the user login and group role.
You can map directory groups to specific code folders on the server. A read group lets new hires pull code to their laptops. A write group lets senior coders push new changes back to the main branch. When someone leaves the company, you disable their account in the directory. They lose the ability to pull or push code right away.
Data flows in a straight line during every code task. The developer sends a request from their command line to your code host. The host checks the identity token against your cloud directory rules. Once the check passes, the host lets the file change happen on disk. It also writes the user email into the server log.
Common risks and how to fix them
Many teams fall back on shared SSH keys for their code servers. One shared account makes it fast to set up new laptops. Still, shared accounts wreck your audit trail. If a bad change breaks the build, you cannot tell who pushed it. If a laptop goes missing, you must change the key for the whole team.
Long-lived personal tokens cause another big headache for tech teams. Users save these tokens on their disks in plain text. If malware hits a laptop, an attacker can steal that saved token. They can then read your private code from anywhere. Broad tokens also give users write power to every repo on the host.
Active Directory + Azure RBAC: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
You can fix these risks by scoping roles and network paths. First, stop using shared accounts and give every user their own login. Next, break your code repos into small groups based on project needs. Map each repo group to a tight role in your cloud directory. Make sure no single role can write to every repo on the server.
Network rules also keep your code safe from outside attacks. Put your Mercurial host inside a private network subnet. Do not open your code server ports to the public internet. Require users to pass a directory check and multifactor check before reaching the host. Turn on full logging on both the directory and the code host.
Keeping server maintenance simple
Old scripts often sync user lists from the directory to text files on disk. These scripts break when network blips happen or when group names change. A broken script might lock out coders or leave an ex-worker with live keys. Direct checks against the cloud directory work better than local text files.
Review your directory groups once a month to keep roles clean. Remove people who moved to other teams or finished their short projects. Check your server logs to find tokens that no one uses anymore. Clean roles and tight logs keep your code safe every day.
Add runtime guardrails and masking beside your databases and APIs
Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.
Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.
Frequently asked questions
Can Mercurial check Azure Active Directory logins on its own?
No, Mercurial only manages code files and local change history. You must use a web server or SSH host to handle the cloud login check.
How do we handle automated build bots with this setup?
Create a dedicated service identity in your directory for each build bot. Give that identity read-only permissions to only the repos it needs to build.
What happens to local code commits when we link our directory?
Local commits on a laptop still use the name in the local config file. The server checks the directory login only when the user pushes changes up.
Related guides
In this post