From 60b492cca28a9e72c5ef07c1ebaf380256a93f66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 28 Oct 2026 10:51:31 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20settings=20and=20admin=20pa?= =?UTF-8?q?ges,=20audit,=20family=20switcher,=20backups=20(prune=20only=20?= =?UTF-8?q?manifest-holding=20sets),=20export/fsck/restore/quota=20CLI,=20?= =?UTF-8?q?systemd=20unit,=20Ferron=20example,=20README?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 15 + Cargo.toml | 2 + README.md | 148 ++++ config/in.example.toml | 9 + crates/in-core/src/backup.rs | 403 ++++++++++ crates/in-core/src/blob/mod.rs | 26 + crates/in-core/src/config.rs | 21 + crates/in-core/src/export.rs | 246 ++++++ crates/in-core/src/fsck.rs | 183 +++++ crates/in-core/src/lib.rs | 4 + crates/in-core/src/settings.rs | 256 +++++++ crates/in-core/src/store/audit.rs | 164 ++++ crates/in-core/src/store/members.rs | 20 + crates/in-core/src/store/mod.rs | 1 + crates/in-core/src/store/objects.rs | 20 + crates/in-core/src/store/settings.rs | 9 + crates/in-web/Cargo.toml | 2 + crates/in-web/src/api/machine_auth.rs | 13 +- crates/in-web/src/api/upload.rs | 21 +- crates/in-web/src/audit.rs | 50 ++ crates/in-web/src/auth.rs | 12 +- crates/in-web/src/backup.rs | 68 ++ crates/in-web/src/boot.rs | 71 +- crates/in-web/src/cli.rs | 210 ++++++ crates/in-web/src/directory.rs | 10 +- crates/in-web/src/family.rs | 149 ++++ crates/in-web/src/health.rs | 6 +- crates/in-web/src/i18n/admin.rs | 297 ++++++++ crates/in-web/src/i18n/mod.rs | 2 + crates/in-web/src/i18n/settings.rs | 95 +++ crates/in-web/src/live.rs | 9 +- crates/in-web/src/main.rs | 74 +- crates/in-web/src/pages/admin.rs | 947 ++++++++++++++++++++++++ crates/in-web/src/pages/drive.rs | 8 +- crates/in-web/src/pages/files.rs | 2 +- crates/in-web/src/pages/links.rs | 81 +- crates/in-web/src/pages/mod.rs | 2 + crates/in-web/src/pages/settings.rs | 176 +++++ crates/in-web/src/pages/share_dialog.rs | 2 +- crates/in-web/src/pages/shared.rs | 2 +- crates/in-web/src/pages/sign_in.rs | 12 +- crates/in-web/src/pages/trash.rs | 2 +- crates/in-web/src/pages/view.rs | 2 +- crates/in-web/src/state.rs | 3 + crates/in-web/src/sweeper.rs | 18 +- crates/in-web/src/views/mod.rs | 49 +- deploy/ferron.kdl | 6 + deploy/in.service | 47 ++ 48 files changed, 3839 insertions(+), 136 deletions(-) create mode 100644 README.md create mode 100644 crates/in-core/src/backup.rs create mode 100644 crates/in-core/src/export.rs create mode 100644 crates/in-core/src/fsck.rs create mode 100644 crates/in-core/src/settings.rs create mode 100644 crates/in-core/src/store/audit.rs create mode 100644 crates/in-web/src/audit.rs create mode 100644 crates/in-web/src/backup.rs create mode 100644 crates/in-web/src/cli.rs create mode 100644 crates/in-web/src/family.rs create mode 100644 crates/in-web/src/i18n/admin.rs create mode 100644 crates/in-web/src/i18n/settings.rs create mode 100644 crates/in-web/src/pages/admin.rs create mode 100644 crates/in-web/src/pages/settings.rs create mode 100644 deploy/ferron.kdl create mode 100644 deploy/in.service diff --git a/Cargo.lock b/Cargo.lock index 5040c46..e971124 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -588,6 +588,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa8876b300ab35ba921adea3dfd70157a46249b33f95c9084ae5709785478946" dependencies = [ "clap_builder", + "clap_derive", ] [[package]] @@ -602,6 +603,18 @@ dependencies = [ "strsim", ] +[[package]] +name = "clap_derive" +version = "4.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9c751b79415d4e559e3d1fcf128e09e720eb673a06d26cf6f392d37d75b66e0" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 3.0.9", +] + [[package]] name = "clap_lex" version = "1.1.1" @@ -1968,6 +1981,7 @@ name = "in-web" version = "0.1.0" dependencies = [ "base64 0.23.1", + "clap", "ed25519-dalek", "futures-util", "grass", @@ -1979,6 +1993,7 @@ dependencies = [ "jsonwebtoken", "rand 0.10.3", "reqwest", + "rustix 1.1.6", "serde", "serde_json", "serde_urlencoded", diff --git a/Cargo.toml b/Cargo.toml index 3c81460..0cae844 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,6 +44,7 @@ argon2 = "0.6.0" async-trait = "0.1.92" base64 = "0.23.1" bytes = "1.12.1" +clap = { version = "4.6.7", features = ["derive"] } chacha20poly1305 = "0.11.0" ed25519-dalek = "2.1.1" futures-util = "0.3.34" @@ -59,6 +60,7 @@ ipnet = "2.12.2" jsonwebtoken = { version = "11.1.0", default-features = false, features = ["rust_crypto"] } object_store = { version = "0.14.2", features = ["aws"] } rand = "0.10.3" +rustix = { version = "1.1.6", default-features = false, features = ["fs"] } reqwest = { version = "0.13.5", default-features = false, features = ["form", "rustls", "stream"] } serde = "1.0.229" serde_json = "1.0.154" diff --git a/README.md b/README.md new file mode 100644 index 0000000..0cc5210 --- /dev/null +++ b/README.md @@ -0,0 +1,148 @@ +# in + +`in` is the family's file drive. It keeps folders and files, resumable uploads, previews and thumbnails, a +trash, sharing with people and by link, and per-person quotas. It also stores bytes for the other family +apps through a machine API. It is one binary, `in`, with the web UI, the API, the background workers and the +operator commands. Files are plain files in a blob tree, and `in export` writes them out as an ordinary folder +tree that needs no `in` to read. + +`in` depends on `im` for sign-in (OpenID Connect) and the people directory. Once a person is signed in, their +files keep working while `im` is down. The shared contracts are in `docs/contracts.md`; the design is in +`docs/architecture.md`; the code rules are in `docs/conventions.md`. + +## Build + +You need Rust stable (edition 2024). The stylesheet is compiled from `style/` at build time, so there is no +Node step. + +```sh +cargo build --release -p in-web # binary: target/release/in +cargo test --workspace +``` + +Install the binary and the unit: + +```sh +sudo install -m 0755 target/release/in /usr/local/bin/in +sudo useradd --system --home-dir /var/lib/in --shell /usr/sbin/nologin in +sudo install -d -o in -g in -m 0700 /var/lib/in +sudo install -d -m 0755 /etc/in +sudo install -m 0644 deploy/in.service /etc/systemd/system/in.service +``` + +Do not enable the unit until the configuration and the `im` client below are in place. + +## Configuration + +`in` reads `--config `, then `IN_CONFIG`, then `config/in.toml`. A missing file is created from +`config/in.example.toml` on first run. Unknown keys are an error, so a typo fails at start-up. + +The file holds no secrets. The OIDC client secret and the S3 keys are read from files that only the service +user can read: + +| Key | Meaning | +|---|---| +| `database`, `data_dir` | Database file and data directory (blobs, staging, `in.key`, `in.lock`). The data directory is created with mode 0700. | +| `listen` | Address to bind. Keep it on loopback and put the reverse proxy in front. | +| `base_url` | Public origin with no trailing slash. An `https` origin turns on `Secure` cookies and HSTS. | +| `trusted_proxies` | Proxies whose `X-Forwarded-For` is believed. | +| `[oidc]` | `issuer` (the `im` origin), `client_id` (`in`), `client_secret_file`. | +| `[storage]` | `backend = "local"` (default) or `"s3"` with `[storage.s3]`. | +| `[backup]` | Optional. `dir`, `interval_hours`, `keep`, `healthcheck_url`. See *Backups*. | +| `[limits]` | Optional defaults the admin page may override: quotas, purge days, upload size, link length. | + +The admin page at `/admin` shows, next to each runtime value, whether it was set there, comes from the file, or +is the built-in default. A blank field on that page removes the page's value again. + +## First run + +1. Start the server once to create the configuration and the instance key, then stop it: + + ```sh + IN_CONFIG=/etc/in/in.toml in serve + ``` + +2. Register `in` as a client of `im` (run on the `im` host, where its data directory is). Replace `` with + the value of `base_url`: + + ```sh + im client add --name in \ + --redirect-uri "/auth/callback" \ + --post-logout-uri "/" \ + --backchannel-uri "/auth/backchannel-logout" \ + --family-key in + ``` + + `im` prints the client id and its secret once. Save the secret to the file named by `client_secret_file` + (`/var/lib/in/oidc_client_secret`, mode 0600, owned by `in`). The default scopes (`openid profile email`) are + what `in` needs; the family's `directory.read` scope is granted to every family client by default. + +3. Put the reverse proxy in front (see `deploy/ferron.kdl`, an example for Ferron that proxies + `https://in.example.com` to `127.0.0.1:7655`). Ferron must not buffer responses: the live update stream + depends on it. + +4. Start the service: + + ```sh + sudo systemctl enable --now in + curl -s http://127.0.0.1:7655/healthz # ok + ``` + + The first person who signs in becomes a member. Administrators are the people `im` marks as admins. + +The service unit runs `in serve` as the `in` user with systemd hardening (read-only system, no capabilities, +a system-call filter). Its writable paths are the state directory and, when `[backup]` is set, the backup +directory, which you add to `ReadWritePaths`. + +## Backups + +With `[backup]` set, `in serve` writes a backup set every `interval_hours`, keeps the newest `keep` sets, and +pings `healthcheck_url` after each good run (a failed ping is logged and nothing else). + +A set is a directory `set-