Anvil Connect: Why I Built My Own Passkey Gateway for My Homelab
Follow one request from a browser to an app on my own hardware through Anvil Connect, and see why only the gateway decides who gets in.
Sekou M. Doumbouya
Listen to this article
The views expressed here are my own and do not represent those of any current or former employer.
Part 1 of a six-part series on Anvil Connect.
The first people I tried to bring onto my AI workstation were my wife and a few friends. I wanted them in Open WebUI. What I got instead was a back and forth with no end in sight: install Tailscale, now connect it, now go in and add this address, now come to this address on my system.
There was no way to hand-hold them in. And once they did get there, “there was an issue with their sessions not having the right tools associated to them.” I had a name for what I had built: “an incomplete integration story.”
Two Agents, One Gateway covers how Anvil Connect got built. This series covers everything after getting in, starting with why I built the door myself at all.
Every way in had a price
Every way to reach a homelab from outside costs something. The only question is who pays.
Expose ports, and every app faces the internet with whatever login it shipped with. My security is then exactly as good as the weakest login in the rack, and I do not get to pick which one that is.
Stay VPN only, and every device and every person needs the VPN client. That is the bill my wife and my friends paid. A VPN client is a fine tool for someone like me and a locked gate for everyone else, and the people I most wanted feedback from were everyone else.
Rent a hosted tunnel, and identity, admission and audit move to someone else’s terms. Their dashboard decides who is allowed. Their logs say who came in.
Meanwhile, every app grows its own accounts. That is how one homelab ends up with six credentials.
Hosted tools give you a phone view of work in their cloud. Connect gives me the same thing for work on my own machine, without a VPN, without open ports, and without handing identity to a vendor. The models run on my hardware. The agents run on my hardware. The front door should too.
The brief was three constraints
The idea grew out of a question about mutual TLS, a story I told in the origin post. My brief was short. It had to be open source. It could not lean on open-core services, where the part you actually need sits behind a paid tier. And it had to teach me cloud systems engineering, because building the thing was also the course.
Three candidate designs came back from the AI tools I was working with. I put all three through a mock design interview, picked the third, and it shipped that night. On September 9, I accepted all 23 Anvil tasks against 13 requirements, with strict evidence checks, and then merged.
One request, walked end to end
Here is the path a tester’s request takes:
- The browser, on any device, with no client installed.
- Cloudflare, kept only as the public front door.
- A wstunnel reverse tunnel, outbound only, that carries the request to my hardware.
- Caddy, terminating TLS with a certificate authority I own and stripping any identity headers the browser tried to send.
- The Anvil Connect gateway, which signs the person in, checks the request against its limits, and decides.
- The origin connector, running beside the apps.
- The app, still bound to loopback.
Think of it as a building. Cloudflare is the street address: DNS and the first TLS hop, nothing private. The tunnel is a private hallway that my own side opened from the inside, which is why no inbound port on my network has to listen for strangers. Caddy is the coat check: whatever identity you walked in claiming gets taken at the door.
The gateway is the doorman with the guest list, and it is the only one in the building who decides who gets in. On a first visit it walks you to the front desk, Authelia, my own OIDC identity provider, where you sign in with a passkey. Then the gateway issues the session. A browser signs in once, and every published app accepts that session. The origin connector is the service elevator: it pulls traffic from the gateway and forwards it to the apps. Each resource declares its host, its path, its methods and its limits, and the gateway enforces them on every request. Exposing an app is a line in one closed manifest, not a change to the app. Apps take identity three ways. Unmodified apps sit behind the edge. OIDC-native apps federate directly. Apps that verify users themselves get a signed identity handoff instead of a raw header they would have to take on faith.
That is the design. The real edge had opinions about it.
My tests passed against synthetic fixtures. Then I tested against real Caddy and real Authelia in Chromium, and two assumptions broke. The login callback carries iss and scope, which my code did not expect. And the user subject is an opaque UUID, not anything a person would recognize. Then the assembled tunnel exposed a casing bug: wstunnel sends a lowercase Connection: upgrade header, and my Caddy matcher expected Upgrade with a capital U. (Of all the bugs to chase, a capital letter is the most humbling.)
The lesson is the one I keep relearning. Synthetic fixtures prove the code agrees with itself. The real edge proves it agrees with the world.
Members see what they are shown
Once a tester can get in, the next question is what they should see. My answer was two roles, and the reason was simple. I needed a view of the whole system. A tester only needed what I was showing them.
Between September 10 and 20, the old Observatory became Anvil Workbench, one control plane with Connect access under its Settings. Then came tiles on a new home page, grants for every user, full user deletion so a username can be reused, and roles enforced on the server. Each published app grants a role per resource, such as workbench:member or workbench:admin.
Admins see everything. Members see only the tiles they are granted, and members do not see the Pi tool in Workbench. Being in the admins group does not grant other services or operator powers by itself, and the last enabled admin cannot be removed. Inviting someone means creating the account with its grants. Authelia emails a short-lived password-setup link, they add a passkey, and no starter password is ever sent. Underneath all of it is what I call entitlement: each user connected to which resources, and at which level of access.
Not all of it went cleanly. The first Workbench build was far off the design mocks, because the agent kept the old UI. I ruled that the mocks are permanent requirements, not suggestions. Grafana did not sign users in automatically. Test cleanup kept triggering sign-in pop-ups.
The roles model proved itself in November. Between November 9 and 13, I built an admin portal, a Kanban board for Anvil’s stages, and published it as an admin-only Connect app. A non-admin who reaches it gets a 403 with no backend calls made, and I checked that with test accounts. I did not need a second front door for my own tools. The guest list already knew who was staff.
On November 16 came the hardening that only matters once real people depend on the door: per-client login limits so anonymous traffic cannot block sign-in, anti-framing headers, and Sigstore keyless signing with installer verification. Real people do depend on it now: these days my friends just jump in and ask whatever they want to ask.
What it does not do
Connect has hard edges, and I want them on the record.
Disabling a user at the identity provider does not end sessions already issued. Revocation happens at the gateway. If I need someone out right now, the gateway is where I act.
Windows and macOS runtimes for the gateway are unsupported, and macOS gets a local client only.
Recovery restores Connect’s own authority, not Authelia’s database.
The implementation record says Connect has not replaced my installed Tailscale edge. Tailscale still sits beside Connect, and the Hermex iPhone app needs it, which I cover in Hermes in a sandbox.
Own the door, build for the guest
When the work runs on your own hardware, the front door belongs to you too. Renting it means renting the answer to who gets in, what they see, and who keeps the record, and those are the three answers that define what you actually own. So own the door. Then build it for the person who will never care how it works, the one who just wants the result waiting on the other side.
What that person actually ran into is the subject of The People Who Couldn’t Get In.
Co-authored with AI, based on the author's working sessions, dictations, and notes.
Explore the source
fakoli/anvil-serving
This article discusses an open-source project. Star it, fork it, or open an issue.