This is the first step of moving apps to Pocket ID (id.nul.ie). It replaces nginx-sso with oauth2-proxy and adds a way to declare Pocket ID clients in Nix.
my.pocket-id
Declares user groups and OIDC clients: callback URLs, PKCE, allowed groups and the secret (a whole file, or a key in an env file).
pocket-id-sync (nixos/modules/pocket-id/sync.py, standard library only) is a oneshot that applies them through Pocket ID's API using STATIC_API_KEY. It creates or updates on top of the current client, so logos set in the UI are kept, and it replaces the client's secret only when the secret changes.
Clients and groups that aren't declared are left alone.
Group membership is still managed in the UI.
nginx strips X-API-Key from requests to id.nul.ie from outside, so the static admin key only works from inside middleman.
I tested it against a local Pocket ID 2.19:
The first run created the group, the client and its secret.
A second run changed nothing.
After the secret was rotated, only the new secret was left.
oauth2-proxy in place of nginx-sso
The sso client is restricted to the new admins group.
ssoServer [ "admins" ] gates netdata-colony, torrents, jackett, radarr, sonarr and pront with auth_request.
Host-only cookies: each gated vhost serves its own /oauth2/ endpoints and gets a host-only session cookie, unlike nginx-sso's cookie on .nul.ie. Other .nul.ie sites, such as Jellyfin, Home Assistant and the future *.slop.nul.ie previews, never receive it, so they can't replay it. Pocket ID's own session (60 minutes by default) makes signing in to the next gated vhost an automatic redirect. The client's callback URLs are derived from the gated vhosts.
Week-long sessions, checked hourly: with offline_access and cookie.refresh = 1h, oauth2-proxy uses a refresh token every hour to check back with Pocket ID. There's no redirect or passkey prompt, and it picks up current groups. nginx passes the refreshed cookie on from the auth check.
Pocket ID checks access again on every refresh.
A disabled account gets invalid_grant, and oauth2-proxy drops the session at the next check.
Someone removed from a group gets access_denied. oauth2-proxy treats that as a transient error and keeps the session until the access token from the last refresh expires, an hour at most.
I tested all of this locally against Pocket ID 2.19 and oauth2-proxy 7.15.6, signing in with curl and a one-time login token. The session cookie, refresh token included, is a single 2.8 KB cookie, under the 4 KB point where oauth2-proxy would split it.
Return after sign-in: a 401 is an internal redirect to /oauth2/start, and nginx passes the original URI in X-Auth-Request-Redirect. That avoids an unescaped rd= URL, and oauth2-proxy only ever redirects within the same host.
I wrote the nginx glue here instead of using the nixpkgs integration. That integration forces recommendedProxySettings for the whole box, which would duplicate the Host header in every location that uses proxyHeaders.
id.nul.ie resolves to the container itself, so oauth2-proxy reaches Pocket ID through the local nginx.
Removed: the nginx-sso module, its secret, its Google client and the sso.nul.ie vhost.
The nginx config builds and passes NixOS's validation. This hasn't been deployed.
After deploying
Add yourself to the admins group in Pocket ID. Until you're a member, the six gated vhosts refuse everyone.
After rotating a client secret, restart pocket-id-sync.
Next
Separate PRs will follow, one per app, built on my.pocket-id: Gitea, HedgeDoc, PhotoPrism, Synapse and Headscale (replacing Google).
This is the first step of moving apps to Pocket ID (`id.nul.ie`). It replaces nginx-sso with oauth2-proxy and adds a way to declare Pocket ID clients in Nix.
## `my.pocket-id`
- Declares user groups and OIDC clients: callback URLs, PKCE, allowed groups and the secret (a whole file, or a key in an env file).
- `pocket-id-sync` (`nixos/modules/pocket-id/sync.py`, standard library only) is a oneshot that applies them through Pocket ID's API using `STATIC_API_KEY`. It creates or updates on top of the current client, so logos set in the UI are kept, and it replaces the client's secret only when the secret changes.
- Clients and groups that aren't declared are left alone.
- Group membership is still managed in the UI.
- nginx strips `X-API-Key` from requests to `id.nul.ie` from outside, so the static admin key only works from inside `middleman`.
- I tested it against a local Pocket ID 2.19:
- The first run created the group, the client and its secret.
- A second run changed nothing.
- After the secret was rotated, only the new secret was left.
## oauth2-proxy in place of nginx-sso
- The `sso` client is restricted to the new `admins` group.
- `ssoServer [ "admins" ]` gates `netdata-colony`, `torrents`, `jackett`, `radarr`, `sonarr` and `pront` with `auth_request`.
- **Host-only cookies:** each gated vhost serves its own `/oauth2/` endpoints and gets a host-only session cookie, unlike nginx-sso's cookie on `.nul.ie`. Other `.nul.ie` sites, such as Jellyfin, Home Assistant and the future `*.slop.nul.ie` previews, never receive it, so they can't replay it. Pocket ID's own session (60 minutes by default) makes signing in to the next gated vhost an automatic redirect. The client's callback URLs are derived from the gated vhosts.
- **Week-long sessions, checked hourly:** with `offline_access` and `cookie.refresh = 1h`, oauth2-proxy uses a refresh token every hour to check back with Pocket ID. There's no redirect or passkey prompt, and it picks up current groups. nginx passes the refreshed cookie on from the auth check.
- Pocket ID checks access again on every refresh.
- A disabled account gets `invalid_grant`, and oauth2-proxy drops the session at the next check.
- Someone removed from a group gets `access_denied`. oauth2-proxy treats that as a transient error and keeps the session until the access token from the last refresh expires, an hour at most.
- I tested all of this locally against Pocket ID 2.19 and oauth2-proxy 7.15.6, signing in with curl and a one-time login token. The session cookie, refresh token included, is a single 2.8 KB cookie, under the 4 KB point where oauth2-proxy would split it.
- **Return after sign-in:** a 401 is an internal redirect to `/oauth2/start`, and nginx passes the original URI in `X-Auth-Request-Redirect`. That avoids an unescaped `rd=` URL, and oauth2-proxy only ever redirects within the same host.
- I wrote the nginx glue here instead of using the nixpkgs integration. That integration forces `recommendedProxySettings` for the whole box, which would duplicate the `Host` header in every location that uses `proxyHeaders`.
- `id.nul.ie` resolves to the container itself, so oauth2-proxy reaches Pocket ID through the local nginx.
- Removed: the nginx-sso module, its secret, its Google client and the `sso.nul.ie` vhost.
- The nginx config builds and passes NixOS's validation. This hasn't been deployed.
## After deploying
- **Add yourself to the `admins` group in Pocket ID.** Until you're a member, the six gated vhosts refuse everyone.
- After rotating a client secret, restart `pocket-id-sync`.
## Next
Separate PRs will follow, one per app, built on `my.pocket-id`: Gitea, HedgeDoc, PhotoPrism, Synapse and Headscale (replacing Google).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Gate the vhosts without their own sign-in with oauth2-proxy, which
signs in with Pocket ID and allows members of the `admins` group.
Each gated vhost serves its own `/oauth2/` endpoints with a host-only
session cookie, so other `.nul.ie` sites never receive it. Sessions
last a week, and a refresh token lets oauth2-proxy check back with
Pocket ID every hour without a passkey.
Add `my.pocket-id`, which declares Pocket ID groups and OIDC clients
in Nix; `pocket-id-sync` applies them through the API with a static
API key that nginx keeps from outside requests. This lets apps move
to Pocket ID with their client defined next to them, with secrets
from `slop secret generate`.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
This is the first step of moving apps to Pocket ID (
id.nul.ie). It replaces nginx-sso with oauth2-proxy and adds a way to declare Pocket ID clients in Nix.my.pocket-idpocket-id-sync(nixos/modules/pocket-id/sync.py, standard library only) is a oneshot that applies them through Pocket ID's API usingSTATIC_API_KEY. It creates or updates on top of the current client, so logos set in the UI are kept, and it replaces the client's secret only when the secret changes.X-API-Keyfrom requests toid.nul.iefrom outside, so the static admin key only works from insidemiddleman.oauth2-proxy in place of nginx-sso
ssoclient is restricted to the newadminsgroup.ssoServer [ "admins" ]gatesnetdata-colony,torrents,jackett,radarr,sonarrandprontwithauth_request./oauth2/endpoints and gets a host-only session cookie, unlike nginx-sso's cookie on.nul.ie. Other.nul.iesites, such as Jellyfin, Home Assistant and the future*.slop.nul.iepreviews, never receive it, so they can't replay it. Pocket ID's own session (60 minutes by default) makes signing in to the next gated vhost an automatic redirect. The client's callback URLs are derived from the gated vhosts.offline_accessandcookie.refresh = 1h, oauth2-proxy uses a refresh token every hour to check back with Pocket ID. There's no redirect or passkey prompt, and it picks up current groups. nginx passes the refreshed cookie on from the auth check.invalid_grant, and oauth2-proxy drops the session at the next check.access_denied. oauth2-proxy treats that as a transient error and keeps the session until the access token from the last refresh expires, an hour at most./oauth2/start, and nginx passes the original URI inX-Auth-Request-Redirect. That avoids an unescapedrd=URL, and oauth2-proxy only ever redirects within the same host.recommendedProxySettingsfor the whole box, which would duplicate theHostheader in every location that usesproxyHeaders.id.nul.ieresolves to the container itself, so oauth2-proxy reaches Pocket ID through the local nginx.sso.nul.ievhost.After deploying
adminsgroup in Pocket ID. Until you're a member, the six gated vhosts refuse everyone.pocket-id-sync.Next
Separate PRs will follow, one per app, built on
my.pocket-id: Gitea, HedgeDoc, PhotoPrism, Synapse and Headscale (replacing Google).🤖 Generated with Claude Code
b5fb70b636to6c4c930a326c4c930a32to9556e076039556e07603to48923e7844