SSO and Identities (Kanidm)
Kanidm 🡕 is the network’s identity provider: a
single identity unlocks all services (SSO). The idm service runs on
the HCS (and, optionally, as a replica in each zone).
Identities and groups
Section titled “Identities and groups”Accounts and groups are provisioned in Kanidm from etc/config.yaml:
users: alice: profile: "nix-admin" groups: ["idm-admins", "idm-devs", "global"]- Groups control access to services.
- Two special groups:
idm-admins(administration),idm-devs(development).
Create a user account
Section titled “Create a user account”The Kanidm account is provisioned from etc/config.yaml : only its credentials
are defined by hand, with a reset link. Who defines them (administrator or user)
depends on the chosen alternative : see
Create a user account.
Logging in from outside
Section titled “Logging in from outside”Outside a zone, access to services goes through the Tailscale client. Nothing to distribute: everyone logs in with their Kanidm identity.
-
Administrator side
Give the user an administrator profile or a
zone-<zone>group, regenerate, then deploy the HCS:etc/config.yaml users:bob:groups: ["global", "zone-maison"]Fenêtre de terminal just generatejust apply hcs -
User side
Follow Connect an device.
For details, expiration and troubleshooting : VPN.
Connect a service (OIDC)
Section titled “Connect a service (OIDC)”OIDC-compatible services are linked to SSO automatically: Kanidm provisions an OAuth2 client per service, and its secret is managed by sops. Nothing to configure manually.
Protect a service without OIDC
Section titled “Protect a service without OIDC”A service without its own authentication (homepage, static site) can be
protected by placing a Kanidm login screen in front of it (oauth2-proxy +
Caddy). For the homepage, one setting on the gateway host
(usr/machines/<passerelle>/):
darkone.service.homepage.protect = true; # exige une session Kanidm| Option | Default | Effect |
|---|---|---|
protect | true | Homepage restricted to Kanidm users (users group) |
Multi-zone replication
Section titled “Multi-zone replication”The mode is inferred from where idm is declared:
idmon the HCS only → single instance, no replication.idmon a gateway without HCS → standalone instance in the zone.idmon the HCS and gateways → replication: the HCS provides, each gateway is a read-only replica.
Administration
Section titled “Administration”Administration is done from the command line on the HCS:
just enter hcskanidm person credential create-reset-token <login> --name idm_adminSee Create a user account and Reset a password.
Backing up Kanidm
Section titled “Backing up Kanidm”Every night at 22:00 UTC, Kanidm exports its database (compressed JSON) to
/var/lib/kanidm/backups and keeps the last 7 exports, then picked up by the
system backup restic.
Restore : kanidmd database restore <export>, service stopped (see the
Kanidm documentation 🡕).
Updating Kanidm
Section titled “Updating Kanidm”Kanidm maintains only one version at a time : a version reaches end-of-life 30 days after the next one is released, and only an upgrade one version at a time is supported. DNF therefore explicitly pins the package, in dnf/modules/service/idm.nix :
services.kanidm.package = pkgs.kanidm_1_12.withSecretProvisioning;Evaluation warns as soon as the pinned version is deprecated :
kanidm 1.11 is deprecated and will reach end-of-life on 2026-12-01After this date, nixpkgs marks the version as unmaintained and evaluation fails. The upgrade must therefore be planned before the deadline.
-
Compatibility check, on the HCS, before touching the version :
Fenêtre de terminal just enter hcssudo kanidmd domain upgrade-check -c /etc/kanidm/server.tomlRead-only operation.
domain_upgrade_levelmust equaldomain_current_level+ 1 (database migrated by the current version), and eachstatusmust returnPASS; aFAILmust be fixed before going further. -
Cold copy of the database, the only truly reliable rollback :
Fenêtre de terminal sudo systemctl stop kanidmsudo install -d -o kanidm -g kanidm /var/lib/kanidm/pre-upgradesudo cp -a /var/lib/kanidm/kanidm.db* /var/lib/kanidm/pre-upgrade/sudo kanidmd database backup /var/lib/kanidm/pre-upgrade/dump.json -c /etc/kanidm/server.tomlsudo chown -R kanidm:kanidm /var/lib/kanidmsudo systemctl start kanidmCopy the journal, not just the database. SQLite does not always merge its write-ahead log on closing : a
kanidm.db-walof several MB commonly survives the service stop. Copyingkanidm.dbalone would leave out the latest transactions. The*takes the triplet.db,.db-waland.db-shm, which is only valid taken together.The final
chownis not optional : the two previous commands run as root and would otherwise leave files that the service can no longer write. -
Move the pin to the next version, one only at a time, then deploy the HCS.
-
Check the service and the database consistency :
Fenêtre de terminal systemctl status kanidmsudo kanidmd database verify -c /etc/kanidm/server.tomlFinish with a real OIDC login on a network service.
On failure : set the pin back to the previous version, copy
pre-upgrade/kanidm.db* back into /var/lib/kanidm (service stopped, then chown
as in step 2), redeploy.