diff --git a/docs/sites/colony/shill/containers/middleman.md b/docs/sites/colony/shill/containers/middleman.md index 3f1bc4d..0b7673c 100644 --- a/docs/sites/colony/shill/containers/middleman.md +++ b/docs/sites/colony/shill/containers/middleman.md @@ -2,8 +2,8 @@ The front-end reverse proxy for the colony's public web services — the single ingress that `estuary` DNATs HTTP/HTTPS (and Matrix federation on `:8448`) to. Terminates TLS with wildcard -certificates it issues itself, provides nginx-sso for gated vhosts, and runs a librespeed -backend and a Paseo relay. +certificates it issues itself, provides nginx-sso for gated vhosts, and runs the Pocket ID +identity provider, a librespeed backend and a Paseo relay. - **Source:** [`shill/containers/middleman/`](../../../../../nixos/boxes/colony/vms/shill/containers/middleman) (`default.nix`, `vhosts.nix`) @@ -38,6 +38,18 @@ The `generic` SSO instance at `sso.nul.ie` uses Google OAuth by default and also username/password provider. Its cookie domain is `.nul.ie`; gated vhosts include the generated `server-generic.conf` / `location-generic.conf` snippets from `/etc/nginx/includes/sso/`. +### Pocket ID + +[Pocket ID](https://pocket-id.org) (`services.pocket-id`) is a passkey-only OpenID Connect +provider at `id.nul.ie`, for apps that sign in with OIDC (first the `slop-broker` approvals web +app). It is meant to replace nginx-sso's Google sign-in later, with oauth2-proxy in front of apps +that lack OIDC. + +- Listens on `127.0.0.1:1411` behind nginx and keeps its SQLite database in `/var/lib/pocket-id` + (persisted by `my.tmproot`). The `middleman/pocket-id-encryption-key` secret encrypts it. +- The first admin is created at `/setup`; nginx only allows that page and its API from + internal networks (`lib.my.c.internalNets`). Further users are added from the admin UI. + ### librespeed The frontend and backend are published as `speed.nul.ie` and `librespeed.ams1.int.nul.ie`, both @@ -74,6 +86,7 @@ all vhosts are `onlySSL`, kTLS and HTTP/2. "SSO" = gated behind nginx-sso (`gene | `nul.ie` (`_`, default) | static | landing page (`index.html`, CV PDF, SSH pubkey); serves Matrix `.well-known`s and redirects `webfinger`/`nodeinfo`/`host-meta` → `toot.nul.ie`, `atproto-did` → `pds.nul.ie`; `forceSSL` (plain HTTP redirects to HTTPS) | | `localhost` | — | loopback-only VTS status page at `/status` (scraped by netdata); plain HTTP | | `sso.nul.ie` | `localhost:8082` | nginx-sso endpoint | +| `id.nul.ie` | `localhost:1411` | Pocket ID; `/setup` only from internal networks | | `netdata-colony.nul.ie` | `.ams1.int.nul.ie:19999` | netdata fan-out over `vm`, `fw`, `ctr`, `oci`, `http`, `jackflix-ctr`, `chatterbox-ctr`, `colony-psql-ctr`; **SSO** | | `pass.nul.ie` | `vaultwarden-ctr:8080` | [vaultwarden](vaultwarden.md); `/notifications/hub` proxied with websockets | | `matrix.nul.ie` | `chatterbox-ctr:8008` | [chatterbox](chatterbox.md) Synapse client + federation; also listens on `:8448` as federation `default_server`; `= /` redirects to Element; serves Matrix `.well-known`s | @@ -107,6 +120,6 @@ all vhosts are `onlySSL`, kTLS and HTTP/2. "SSO" = gated behind nginx-sso (`gene ## Notable config files -- [`nixos/boxes/colony/vms/shill/containers/middleman/default.nix`](../../../../../nixos/boxes/colony/vms/shill/containers/middleman/default.nix) — container definition: nginx, ACME, nginx-sso, librespeed, Paseo relay, secrets +- [`nixos/boxes/colony/vms/shill/containers/middleman/default.nix`](../../../../../nixos/boxes/colony/vms/shill/containers/middleman/default.nix) — container definition: nginx, ACME, nginx-sso, Pocket ID, librespeed, Paseo relay, secrets - [`nixos/boxes/colony/vms/shill/containers/middleman/vhosts.nix`](../../../../../nixos/boxes/colony/vms/shill/containers/middleman/vhosts.nix) — all virtual hosts, the SSO include helpers, and the `.well-known` tree - [`nixos/boxes/colony/vms/shill/containers/middleman/default.html`](../../../../../nixos/boxes/colony/vms/shill/containers/middleman/default.html) — default vhost landing page diff --git a/nixos/boxes/colony/vms/shill/containers/middleman/default.nix b/nixos/boxes/colony/vms/shill/containers/middleman/default.nix index 4aeb78f..8b8fcec 100644 --- a/nixos/boxes/colony/vms/shill/containers/middleman/default.nix +++ b/nixos/boxes/colony/vms/shill/containers/middleman/default.nix @@ -62,6 +62,8 @@ in group = "nginx"; }; "librespeed.toml" = { }; + # Pocket ID's database encryption key; it reads it through `LoadCredential` + "middleman/pocket-id-encryption-key" = { }; }; }; @@ -224,6 +226,19 @@ in }; services = { + # Passkey-only OpenID Connect provider at `id.nul.ie`, published by nginx + pocket-id = { + enable = true; + settings = { + APP_URL = "https://id.${pubDomain}"; + HOST = "127.0.0.1"; + PORT = 1411; + TRUST_PROXY = true; + ANALYTICS_DISABLED = true; + }; + credentials.ENCRYPTION_KEY = config.age.secrets."middleman/pocket-id-encryption-key".path; + }; + netdata = { enable = true; configDir = { diff --git a/nixos/boxes/colony/vms/shill/containers/middleman/vhosts.nix b/nixos/boxes/colony/vms/shill/containers/middleman/vhosts.nix index a27dd1b..3ba433e 100644 --- a/nixos/boxes/colony/vms/shill/containers/middleman/vhosts.nix +++ b/nixos/boxes/colony/vms/shill/containers/middleman/vhosts.nix @@ -416,6 +416,28 @@ in useACMEHost = pubDomain; }; + "id.${pubDomain}" = + let + pocketId = { + proxyPass = "http://127.0.0.1:${toString config.services.pocket-id.settings.PORT}"; + extraConfig = proxyHeaders; + }; + in + { + locations = { + "/" = pocketId; + # Creating the first admin account is only possible from inside + "~ ^/(setup|api/signup/setup)$" = pocketId // { + extraConfig = '' + ${concatStringsSep "\n" (map (n: "allow ${n};") (with lib.my.c.internalNets; v4 ++ v6))} + deny all; + ${proxyHeaders} + ''; + }; + }; + useACMEHost = pubDomain; + }; + "md.${pubDomain}" = { locations."/" = { proxyPass = "http://object-ctr.${domain}:3000"; diff --git a/nixos/modules/tmproot.nix b/nixos/modules/tmproot.nix index 1b09be1..1cce5f5 100644 --- a/nixos/modules/tmproot.nix +++ b/nixos/modules/tmproot.nix @@ -478,6 +478,7 @@ in ]; }) (persistSimpleSvc "headscale") + (persistSimpleSvc "pocket-id") (mkIf config.services.tailscale.enable { my.tmproot.persistence.config.directories = [ "/var/lib/tailscale" ]; }) diff --git a/secrets/middleman/pocket-id-encryption-key.age b/secrets/middleman/pocket-id-encryption-key.age new file mode 100644 index 0000000..33766b6 --- /dev/null +++ b/secrets/middleman/pocket-id-encryption-key.age @@ -0,0 +1,11 @@ +-----BEGIN AGE ENCRYPTED FILE----- +YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNzaC1lZDI1NTE5IFZGY3c1ZyB0eFJy +dmRXaWlwcnV4VEZTcGxublU0NUY1ZjBtYW5wME4xZGUrc08wQVdNCjNQVGZQcG5Q +b0ZGT0F1YTRHUWx4VHV4QXowR0JyVXI2bnpEN2ExVzR3WmsKLT4gWDI1NTE5IExN +a3ZNeVoyQ0lmL09RdHhpbXZidkVZOGs3MzZFZUFCOUFQZlZhNDFIbHMKc3RJZDZB +OUhPdWhtNi9rNGFRYW9pK1dDa0IwQTJjbEYvRWNSQVNkQ1Y3WQotPiA0QnkmKz8t +Z3JlYXNlCkJudjlTTnNWQXFKbDNrNjJEY2w2WmVWb1J0UHEyZwotLS0gby8wdHI0 +cW0xVHZSaGpLNlIvK29nRWVmM05ScG4weSttdnB6UUo0dWwvQQrALnTOrTSK+rUZ +K9DGS7BZmTs1xDQ1tBDOoSPXTlpXvTv4N49lcGP0x/+y5W3WeLwfSimIeSMqloQI +a8ebLs0n7bR8dHnfjtqhdIHD +-----END AGE ENCRYPTED FILE-----