Skip to content

Authentication & Identities

The network is built on one identity per person, managed by Kanidm 🡕. This page explains how a service verifies who you are, following two integration paths, and what happens between the browser, the gateway, and Kanidm.

Everything starts from Kanidm, the network’s identity provider (IdP). A service connects to it in two ways, depending on whether it speaks OIDC or not.

PathWhich servicesMechanism
Native OIDCService that speaks OIDC (Forgejo, Immich, Grafana…)The service communicates directly with Kanidm
Authenticating reverse proxyService without auth (homepage, static site, bare UI)oauth2-proxy + Caddy protect the service upstream
Diagram

Accounts and groups are provisioned in Kanidm from etc/config.yaml : one account per person, groups that drive access. The users group contains all accounts ; idm-admins and idm-devs are the special administration and development groups. The tailnet group brings together administrators and members of a zone : it alone can connect a device to the VPN.

When a service supports OIDC, DNF integrates it automatically: Kanidm provisions one OAuth2 client per service, the secret is managed by sops, and the service redirects itself to Kanidm for login. Nothing to configure manually.

This is the preferred path: the service knows the person’s identity and groups, and can apply its own roles (admin, reader…).

A service without authentication (the homepage, a static site…) cannot verify an identity. DNF then places a Kanidm login screen in front of it, at the gateway’s reverse proxy level. Three components work together:

  • Caddy : the gateway’s reverse proxy. Before serving content, it delegates verification (forward auth) to oauth2-proxy.
  • oauth2-proxy : one daemon per gateway (listens locally), Kanidm’s OAuth2 client. It holds the session and drives the login flow.
  • Kanidm : issues the login screen and identity token.
Diagram

Once the person is logged in, access is filtered by Kanidm group. Caddy passes the list of allowed groups to oauth2-proxy; without membership, the response is 403 even if authenticated.

After login, oauth2-proxy sets a session cookie valid across the entire zone domain (.maison.domain.tld). All protected services in the zone therefore share the same session: you log in once. The flow endpoints (/oauth2/*) are hosted on the FQDN of the zone’s homepage, which serves as a common anchor.

The cookie carries only a ticket : the session is kept on the gateway (local Redis, redis-oauth2-proxy) and survives its restart.

Sessions last 7 days, but their groups are re-read from Kanidm every 15 minutes : a group addition or removal takes effect within that period, without signing in again. To force a new session : https://homepage.<zone>/oauth2/sign_out.

Protection can be limited to external access: internal clients (private LAN and tailnet VPN) reach the service without login, while access from the outside goes through the Kanidm login page. Useful for a portal open at home but protected on the Internet.

A native client (Android application) does not follow the redirect. An AI space service that declares proxy.tailnetIdentity then recognizes a personal device on the tailnet : Caddy asks tailscaled for its owner (tailscale.nginx-auth), then compares its email with the members of the space.

ClientResult
Member’s personal deviceAccess, owner identity
Personal device of another account403
Tagged machineKanidm redirect
Outside tailnetKanidm redirect

Caddy strips the identity headers sent by the client. Kanidm groups are not passed on this path : Headscale does not know them.

  • The oauth2-proxy client secret is shared with Kanidm via sops (a session secret is added as well).
  • The flow introduces no new hostname : it reuses the homepage FQDN, already covered by a TLS certificate of the network.