Files
pinpox 12207d4649
buildbot/nix-eval evaluation succeeded in 45s (1 warning)
Nix Flake Check / check (pull_request) Successful in 51s
Nix Flake Check / check (push) Successful in 1m7s
buildbot/nix-build 26 attributes built
gitea-mq Already up to date with target branch
pocket-id: declarative client secrets and groups
Client secrets now come from a clan vars generator per confidential client
(pocket-id-client-<id>) and are pushed via Pocket ID's custom-secret API,
replacing any other secrets on the client. Previously the reconciler minted a
new server-side secret on every boot (the /run copy is lost), leaving old
ones valid and failing once a client hit Pocket ID's 20-secret limit.

New `groups` option maps group names to client ids: missing groups are
created, and listed clients are restricted to exactly those groups.
isGroupRestricted is now always sent, since Pocket ID drops a client's
allowed groups on any update without it.
2026-10-17 17:39:52 +02:00
..

Pocket ID

Passkey-first, self-hosted OIDC identity provider. A drop-in alternative to the authelia service for the OIDC client half of the generic auth export type: any clan service that exports auth.client is automatically registered as an OIDC client in Pocket ID.

Unlike Authelia, Pocket ID owns its own user database (users authenticate with passkeys and are managed in the Pocket ID web UI), so this service does not consume auth.users.

Usage

inventory.instances = {
  # Deploy Pocket ID — apps that export auth.client are picked up automatically.
  main = {
    module.input = "clan-community";
    module.name = "pocket-id";
    roles.default.machines.my-server.settings = {
      publicHost = "id.example.com";

      # Optional: inline OIDC clients for non-clan-service apps. The attribute
      # key becomes the Pocket ID client id; the value is the raw Pocket ID
      # client spec (POST/PUT /api/oidc/clients).
      extraClients = {
        miniflux = {
          name = "Miniflux";
          callbackURLs = [ "https://news.example.com/oauth2/oidc/callback" ];
        };
      };

      # Optional: user groups, each mapped to the client ids its members may use.
      groups = {
        readers = [ "miniflux" ];
      };
    };
  };
};

Roles

default

The single Pocket ID server role. Aggregates auth.client exports from the entire clan inventory and reconciles them against the Pocket ID API.

OIDC client aggregation

Other clan services declare their OIDC client requirements via the auth export type. Set manifest.exports.out = [ "auth" ] in your service and emit:

exports = mkExports {
  auth.client = {
    clientId = "my-app";
    clientName = "My Application";
    redirectUris = [ "https://my-app.example.com/callback" ];
    scopes = [ "openid" "profile" "email" ];
    public = false;
  };
};

This is the same auth.client schema the authelia service consumes, so a consumer does not need to change when swapping IdPs. Pocket ID's secret is generated by this service (see below), so consumers do not declare an auth.varsGenerator for Pocket ID. scopes are ignored (Pocket ID has no per-client scope list).

Client reconciliation

Pocket ID has no declarative config file. Instead this service:

  1. Generates a stable STATIC_API_KEY and ENCRYPTION_KEY via clan vars.
  2. Generates one secret per confidential client via the clan vars generator pocket-id-client-<clientId>.
  3. Runs the pocket-id-clients.service oneshot (on boot and whenever the spec or a secret changes), which
    • creates every declared group that doesn't exist yet,
    • POST/PUTs each aggregated client to /api/oidc/clients (creating clients with a fixed, human-readable id rather than a random UUID),
    • sets each client's allowed groups,
    • replaces each confidential client's secrets with the generated one.

This is the mechanism from https://gist.github.com/zimbatm/452af35d047d810339c7279e8d59dc1c, adapted to clan vars and the auth.client export schema.

Groups

groups maps a group name to the client ids its members may use:

groups = {
  mail = [ "webmail" ];
  nextcloud = [ "nextcloud" ];
};

A client listed in any group is restricted to exactly its declared groups. A client listed in no group is unrestricted, and any allowed groups set in the UI are removed on the next reconcile (unless its extraClients spec sets isGroupRestricted = true, which keeps UI-managed groups). Groups are matched by name and only ever created, never renamed or deleted; group membership is managed in the Pocket ID UI.

Consuming a client secret

A consuming service on the Pocket ID host reads its secret from the vars generator, typically via LoadCredential:

systemd.services.my-app.serviceConfig.LoadCredential = [
  "oidc-secret:${config.clan.core.vars.generators."pocket-id-client-my-app".files.secret.path}"
];

Public clients (isPublic = true) have no secret. To rotate a secret, run clan vars generate <hostname> --generator pocket-id-client-<clientId> --regenerate and deploy; consumers must be restarted to pick up the new value.

Encryption key

ENCRYPTION_KEY is generated once via clan vars and kept stable across deploys — it encrypts Pocket ID data at rest, so changing it would invalidate existing encrypted data. Retrieve it (rarely needed) via:

clan vars get <hostname> pocket-id/encryption-key