At the start of the year I was extremely dependent on Google’s products: email, calendar, maps, photos, drive, notes, YouTube. It was very convenient and I liked the apps a lot. Then at some point I ran out of free storage. I got Google One, the tier with AI included because I might use it. Then YouTube Premium, because YouTube Music costs barely less. It started adding up. All the while Google knows everything about me, which is a little bit eerie.
So I wondered: what would life look like without subscriptions? What if I didn’t have to give away all my data? And, most importantly, what if I could taylor the app experience to my own needs. Missing a feature? Just add it to the app! In the age of AI that can’t be that difficult! About thirty self-hosted services later, it mostly works. One particular focus point of mine was avoiding passwords at almost any cost: OIDC as much as possible. This is where Tailscale comes in extremely handy.
What Tailscale is, and why it’s great
Tailscale is a VPN that joins your devices into one private network, which is called a tailnet. You can invite your family and friends to your network, and you can roll out any services to that network. It works really well. I get:
- A private network with no public exposure. If I mess up the auth or end up running vulnerable software, there’s that extra step for people to protect my machines from bad actors.
- DNS that just works. I can give each service its own hostname and a Let’s Encrypt certificate for it, and Tailscale Serve does the rest for me.
- Identity at the network layer. This is the best part. Tailscale knows which user and device a request comes from, so an app can be told who is calling without a login page at all. Since all users will have to register and be added to my Tailscale network anyway, I can just use their Tailscale identity for SSO!
- Tags and ACLs. I can decide who can reach what service. I can make a secret service just for myself, or share a service with everyone, or define which services can access other services on a need-to-access basis.
- SSH and exit nodes for free. I can SSH to my server from anywhere without exposing SSH. And any node can be an exit node, which turned out to be a useful way to share a single VPN subscription between multiple people and services to access any country-restricted content.
- It is so fast to set something up. From the moment I start my docker containers I’m able to access them in less than a minute.
In other words, I am a big fan of Tailscale. At the same time, not everything worked smoothly the first time, and I want to share some of the struggles I had with integrating authentication with some of the services, and what I did to solve them.
tsidp does not do public clients
tsidp is an OIDC identity provider that runs as a node on the tailnet. Every app that speaks OIDC can trust it, which means “Sign in with Tailscale” and no passwords. It is not a Tailscale product though, and as such has limited capacity to add new features.
There are two types of clients in OIDC: confidential (ones who have a client secret) and public (those who don’t and instead depend on PKCE). tsidp doesn’t support the second case. Which is unfortunate, because it can be required by certain Android apps, such as Anchor which I like to use as my quick notes app.
Luckily, it’s not too hard to implement. In fact, someone already did in this pull request, it’s just not getting merged for some reason.
Until it is merged I need to host two versions of tsidp. One is the official version which is easy to keep up to date and get new features for. The other one has the PR patch applied to main; it might require more maintenance when doing upgrades since I might need to adjust the patch when updating. In the end, I use a Dockerfile that looks something like this:
ARG TSIDP_MAIN=<commit>
ARG TSIDP_PR182=<commit>
RUN git clone https://github.com/tailscale/tsidp.git . \
&& git checkout "$TSIDP_MAIN" \
&& git fetch origin "$TSIDP_PR182" \
&& git -c user.name=build -c user.email=build@localhost merge --no-edit FETCH_HEAD \
&& CGO_ENABLED=0 go build -o /tsidp-server .
I pin both commits instead of following the pull request, so a later push to it can’t change what I build, or break it.
The ID token and userinfo disagree
Once SSO works, the first thing you see in some apps is an account called userid:1234567890. Two properties of tsidp cause it:
- The ID token carries
sub,emailandusername, but the display name exists only in userinfo. subis not a login name. It is the raw user ID, rendered as the stringuserid:<hex>.
An app that builds its display name from the ID token alone finds no name and falls back to sub. Nextcloud’s fix is one setting, which makes it fold userinfo in as a fallback:
occ config:system:set user_oidc enrich_login_id_token_with_userinfo --value=true --type=boolean
That fixes the display name. The account name is still userid:<hex>, because it comes from sub. That is fine for the most part, since the most important thing is that the user id is unique, which it is. It can sometimes be annoying if you try to figure out who’s who from a user list, but that’s rarely necessary so I don’t bother changing the config further.
Navidrome: the tools around it still want a password
I run Navidrome for music. It is the odd one out in my setup when it comes to auth: it doesn’t support OIDC.
Navidrome speaks the Subsonic API, the protocol of an old music server called Subsonic that most music servers and apps have since copied. Its authentication is a username plus a password sent with every request. It is also the de facto standard: nearly every music client and tool targets it, so all of them assume that an account has a password. Subsonic has no “sign in with OIDC” of its own.
Most of my apps sign you in through tsidp, with a “Sign in with Tailscale” button. We can’t do that with Navidrome, but luckily it has a feature called external authentication. The Tailscale proxy in front of it adds a Tailscale-User-Login header with the name of the person on the other end (replacing any value a client sent), and Navidrome only believes that header when it comes from 127.0.0.1. So you open the page and you’re in. Accounts are created on first visit, named after your tailnet login.
Now most apps that you use will still assume that a password is involved, and you’ll need to type one in to use it. The beauty is that you can use any password and you’ll still log in. Tailscale already knows your identity and will let you log in regardless of what password you give it. So there’s no password to remember.
That covers people, music apps, and anything else on the user’s tailnet. The one exception is the recommendations engine Explo, which does per-user music recommendations and doesn’t sit on the user’s tailnet yet still needs to be able to log in as the user to update their recommendations. The solution is to run Explo in the same network namespace as Navidrome, so I can bypass Navidrome’s proxy entirely. Each person’s Explo talks to a small local Caddy listener, which forwards to Navidrome and adds that person’s Tailscale-User-Login header itself. This only works because the request comes from 127.0.0.1 bypassing Navidrome’s proxy; the proxy would otherwise log Explo in as its own identity instead of the user’s identity.
The password manager can’t work without a password
I would have liked SSO everywhere. For a password manager it turns out not to work. The master password is not a login credential, it is the vault’s encryption key. The client derives it locally and the server holds only ciphertext, so after a flawless SSO login the client still cannot open the vault. The mechanisms that would remove it (key connector, trusted device encryption, passkey unlock) are Bitwarden features that the self-hosted Vaultwarden server does not implement.
tsidp also adds nothing as a second factor, because it is an ambient IdP: it identifies you from the tunnel your request arrived on and never asks anything. On an already-joined device you click straight through. So SSO would add a dependency in front of the service I least want to be locked out of, and buy nothing.
n8n: OIDC is an Enterprise feature
n8n (as well as a few other apps that I have looked at, like OpenProject) have OIDC login as a feature, but they gate that feature behind an enterprise subscription. I’m not super keen about paying a subscription for something I self-host, and besides the terms of these subscriptions are often quite insane, requiring a minimum of 10 or more licenses to be bought when I could use just 1 or 2. So I needed a way around this.
Luckily for me, n8n has something called external hooks that allowed me to add OIDC login through Tailscale to the login page myself. I did not write it: it is a port of cweagans/n8n-oidc to the n8n version I run. It reaches into n8n internals, so I have to re-check it on every n8n update, but it has so far been reliable for me.
The different login setups in a nutshell
Every problem above came down to the same question: how does this app find out who I am? These are the options I have set up:
- No auth at all, if the app is only reachable from my tailnet and holds nothing I would mind losing. That is fine for trying something out, and I can add real auth later if it sticks around.
- A trusted header, if the app can be told to believe one. This is how Navidrome and Grafana work, and it is the nicest option, because there is nothing to click.
- OIDC through tsidp, if the app speaks OIDC. Before committing, I check how it builds the display name, and whether its mobile app needs a public client, in which case I point it at the patched version of tsidp.
- A hook or a plugin, if OIDC is locked behind a paid plan and the app lets me extend its login. That is the n8n route.
- The app’s own login, as a last resort. For Vaultwarden that is the right answer.
The list will likely get longer as new apps keep surprising me.