forge
Explore
Log in

Don't you dare go Hollow

iz

Clone
★ 0

0 watching0 forksRust567.3 KiBdbbbc05Tahinli1 month ago30 commits

README.md

iz

iz is the family task board. It has columns, cards (with one level of subtasks, dependencies and assignees), projects (tags), deadlines with meeting times and reminders, comments, attachments with in-page viewers (images, media, PDF, spreadsheets, slides), an activity trail, and admin-defined mail rules with a durable outbox. Sign-in goes through the family's im identity provider. Cards keep a manual order (the default sort), an administrator can restore tasks deleted in the last 30 days, and an im administrator is an administrator in iz whatever role is stored here.

Design notes are in docs/architecture.md. The HTTP contracts with im and in are in docs/contracts.md, and the code conventions are in docs/conventions.md.

Build

cargo build --release -p iz-web

The binary is target/release/iz. Nothing in the build or the runtime uses Node. Use bun for any JavaScript tooling.

Configuration

Copy the example and edit it:

cp config/iz.example.toml config/iz.toml

Or pass any path with --config <path>. The config path is chosen in this order: the --config flag, then the IZ_CONFIG environment variable, then config/iz.toml. If the file does not exist, iz writes the example there on first run.

Keys:

Key Meaning
database SQLite database file. Its -wal and -shm files sit next to it.
data_dir Directory for iz.key, the lock file, attachments and other local files.
listen HTTP listen address. Keep it on 127.0.0.1 behind the reverse proxy.
base_url Public URL used in links and mail. https:// or http://, no trailing slash.
trusted_proxies Peers whose X-Forwarded-For is trusted for client IPs. IPs or CIDR networks. Behind Ferron on the same host, ["127.0.0.1/32"]; left empty there, every visitor counts as the proxy.
[oidc] issuer (the im origin, no trailing slash; https:// outside a local test), client_id, client_secret_file. Remove the section to run without sign-in.
[in_store] enabled. Stores attachments in the in Files service instead of local disk. Off by default.
[backup] dir (backup sets go here), interval_hours (1 to 720, default 24), keep (1 to 365, default 14), healthcheck_url (optional, pinged after each good backup). Remove the section to turn scheduled backups off.

Unknown keys are an error at boot, so a typo stops the start instead of being ignored.

Secrets are never in the TOML:

  • The OIDC client secret goes in the file named by client_secret_file. The file must be mode 0600 or 0400, owned by the service user. iz reads it at boot.
  • The SMTP password is entered in the /settings page. iz seals it in the database.

Production layout

The example unit and reverse proxy config assume this layout:

  • /usr/local/bin/iz: the binary.
  • /etc/iz/iz.toml: the config. data_dir = "/var/lib/iz/data" and database = "/var/lib/iz/data/iz.db".
  • /etc/iz/oidc_client_secret: the client secret, mode 0600, owned by iz.
  • /var/lib/iz: the working directory. The data lives in /var/lib/iz/data. Backups can go in /var/lib/iz/backups. The unit makes all of /var/lib/iz writable and nothing else.

The reverse proxy example is deploy/ferron.conf. The unit is deploy/iz.service.

First run

  1. Create the service user and directories:

    sudo useradd --system --home-dir /var/lib/iz --shell /usr/sbin/nologin iz
    sudo install -d -m 0750 -o iz -g iz /var/lib/iz /var/lib/iz/data
    sudo install -d -m 0750 -o root -g iz /etc/iz
    
  2. Install the binary and the config:

    sudo install -m 0755 target/release/iz /usr/local/bin/iz
    sudo install -m 0640 -o root -g iz config/iz.toml /etc/iz/iz.toml
    

    Edit /etc/iz/iz.toml so data_dir, database and base_url match the layout above.

  3. Register the client at im and write its secret file (see the next section).

  4. Install the unit by hand. Nothing enables it for you:

    sudo install -m 0644 deploy/iz.service /etc/systemd/system/iz.service
    sudo systemctl daemon-reload
    sudo systemctl enable --now iz
    
  5. Check it answers: curl -fsS http://127.0.0.1:7654/healthz should print ok <build sha>.

On the first run iz creates iz.key in data_dir (32 random bytes, mode 0600). Sealed secrets in the database, including the SMTP password, cannot be read without this key. Back up iz.key together with the database, and store the copy somewhere other than the server. Losing iz.key means re-entering the SMTP password and the sealed values, and any backup that lacks the key cannot restore those secrets.

Registering the client at im

iz is a client of im. Register it on the machine where im runs, with the im tools:

im client add --name iz --family-key iz \
  --redirect-uri https://iz.example.com/auth/callback \
  --post-logout-uri https://iz.example.com/ \
  --backchannel-uri https://iz.example.com/auth/backchannel-logout \
  --scopes "openid profile email directory.read files.service"

Replace https://iz.example.com with your base_url. If the flags differ, run im client add --help.

  • im prints client_id and client_secret. The secret is shown once. Save it into the file named by client_secret_file, mode 0600, owned by iz.
  • im generates the client_id itself. Copy the printed value into client_id in iz.toml.
  • The scopes must include openid profile email for sign-in, directory.read for the people directory and files.service when attachments are stored in in.
  • The redirect, post-logout and back-channel URLs are the paths iz serves: {base_url}/auth/callback, {base_url}/ and {base_url}/auth/backchannel-logout.

Then set the [oidc] section in iz.toml:

[oidc]
issuer = "https://im.example.com"
client_id = "<the client_id im printed>"
client_secret_file = "/etc/iz/oidc_client_secret"

Restart iz after changing the config. im client list shows the registered clients, and im client disable <client_id> turns one off.

Backups

With a [backup] section, iz checks every minute whether a backup is due and writes a set into dir when the last attempt (recorded in the database, so restarts do not reset it) is at least interval_hours old, or when none was made yet. A failed attempt is retried at the interval, not every minute. It keeps the newest keep sets. A set is a directory with:

  • iz.db: a consistent copy of the database,
  • attachments/: the local attachment files,
  • manifest.json: a SHA-256 for each file, and
  • manifest.mac: an HMAC-SHA256 of manifest.json, keyed from iz.key.

While the server runs, an administrator can start a backup from the Settings page with the "Back up now" button (it appears when [backup] dir is set). The running backup worker writes the set in the background. Only one run is pending or running at a time: a press while one is pending or running starts nothing. The button is audited.

Backups do not copy iz.key. Keep that copy separately, as described in First run. A set can only be checked and restored with the same iz.key that wrote it; a set without a valid manifest.mac is refused.

Restore with the server stopped:

sudo systemctl stop iz
iz restore --from /var/lib/iz/backups/<set dir>
sudo systemctl start iz

iz restore checks the set's manifest.mac, then the files against manifest.json, before it writes anything. A set that fails the check is not restored. Do not copy the live database file by hand: it is written while iz runs.

Command line

Run these as the iz user, or with sudo -u iz, using the same config as the server.

  • iz serve: run the server. This is the default when no command is given.
  • iz export --out DIR: write an export into DIR. It never writes outside DIR.
  • iz restore --from <set dir>: restore a backup set. The server must be stopped.
  • iz fsck: check the database and files. It is read-only.

export, restore and fsck refuse to run while the server holds the lock file data_dir/iz.lock. Stop the service first. Exit status is 0 for success, 1 for a failure, and 2 for a usage error.

Logs go to stderr at info level. Set RUST_LOG to change the level. Under systemd, read them with journalctl -u iz.

Where to read more

  • docs/architecture.md: modules, data model, routes, workers and rules.
  • docs/contracts.md: the HTTP contracts shared with im (sign-in, logout, directory) and in (object store).
  • docs/conventions.md: boot order, config rules, store and deploy rules.