mirror of
https://github.com/thegeneralist01/archivr
synced 2026-12-04 18:56:44 +01:00
Document the entry-visibility rules, run link and lockout guard
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
74a7703ca5
commit
2258b77ae1
3 changed files with 19 additions and 0 deletions
|
|
@ -148,6 +148,7 @@ No CI is configured; no rustfmt.toml/clippy.toml — default `cargo fmt`/`clippy
|
|||
- `crates/archivr-server/src/token_scope.rs` — middleware that enforces read-scope tokens (GET/HEAD/OPTIONS only).
|
||||
- `crates/archivr-server/src/jobs.rs` — capture job list and detail (`created_by` filter, `items_truncated` at 200 items), with the `created_by` visibility rule.
|
||||
- `crates/archivr-server/src/effective_config.rs` — `GET /api/admin/effective-config`, the `ENV_VARS` registry and its drift test, and `GET /api/archives/:id/info`.
|
||||
- `crates/archivr-server/src/entry_access.rs` — router tests for entry visibility. Every handler that takes an entry uid (or a blob sha) must call `routes::ensure_entry_visible` (or `database::caller_can_access_blob`) so a hidden entry answers 404 like a missing one.
|
||||
- `crates/archivr-server/src/test_support.rs` — shared test helpers (router, auth DB and user/session setup) for the `oneshot` tests.
|
||||
- `crates/archivr-core/src/capture.rs` — `perform_capture()`, `Source` enum, shorthand parsing; tweet titles prefer an X Article's `article.title` (`<title> — @handle`).
|
||||
- `crates/archivr-core/src/downloader/ytdlp.rs` — every yt-dlp shell-out (playlist/channel probe and download, sync mode, subtitle planning/args/staging, the combined media+subtitle call with its media-only retry, and the subtitles-only `download_subtitles`) **plus** the binary resolver: `resolve_yt_dlp()`, `state_dir()`, `probe_version()`.
|
||||
|
|
|
|||
|
|
@ -422,6 +422,12 @@ pending or failed; rows with no completed summary contribute no summary-derived
|
|||
|
||||
**Capture job visibility.** `capture_jobs.created_by` stores the creator's `user_uid`. Job endpoints show a caller only jobs they created unless they hold ADMIN; rows with no creator are admin-only. `GET /api/archives/:id/runs` follows access: admins see all runs, other callers see runs whose job they created or that produced at least one entry they can see.
|
||||
|
||||
**Entry visibility.** An entry is visible to a logged-in caller when ADMIN/OWNER, or when the caller's role bits overlap `collection_entries.visibility_bits` of one of its collections (or of its parent entry's). List and search use `database::entry_visible_to_caller_sql`; every by-uid endpoint (detail, artifacts, summary, tags, collections, media token, favicon, patch/delete, rearchive, thread title) calls `routes::ensure_entry_visible`, which answers `404` for a hidden entry so it cannot be told apart from a missing one. `/blobs/:sha256` applies the same rule through the entries that use the blob, and `list_tag_tree` counts only visible entries (tag names themselves stay visible to every signed-in user). Guests keep the separate `is_entry_publicly_accessible` rule. Signed-in role bits always include the guest bit, so custom roles start at bit 16. A non-admin cannot change or remove a collection membership in a way that leaves the entry invisible to their own roles (`apply_without_self_lockout`, `400`). Media tokens are capability URLs valid for two hours and are not revoked when an entry is hidden afterwards.
|
||||
|
||||
**Capture job to run link.** `CaptureConfig.job_uid` is set by the server for API captures; the run is written onto `capture_jobs.run_uid` the moment it is created (`database::link_capture_job_run`), so the creator can see an in-progress run. Rearchive passes `None`.
|
||||
|
||||
**Default collection.** `_default_` cannot be deleted (`400`), nor can entries be added to or removed from it by hand.
|
||||
|
||||
**File locators.** `POST /api/archives/:id/captures` accepts `file://` only for a file staged under `temp/uploads/`, so an API caller cannot capture and read back arbitrary server files. The CLI reads local paths directly and is unaffected.
|
||||
|
||||
**Inert settings.** `public_index_enabled`, `public_entry_content_enabled` and `open_registration_enabled` are stored and returned by the instance-settings endpoints, but no server logic reads them yet.
|
||||
|
|
|
|||
|
|
@ -273,3 +273,15 @@ A `read` token cannot create tokens, change passwords, or capture (all non-GET).
|
|||
## 4. Test requirements (all streams)
|
||||
|
||||
Follow the `oneshot` style in `routes.rs` `mod tests`, helpers from `test_support.rs`. For every new endpoint: guest 401, USER 403, ADMIN 200/201/204. For user-targeting endpoints additionally: ADMIN-vs-OWNER 403, ADMIN-vs-ADMIN 403, self 409, last-owner 409 where applicable. Regressions: user delete after assigning roles (FK `assigned_by_user_id`), `session_uid` never in any response body, secret canary env value absent from effective-config, back-dated `expires_at` -> 401, read-scope token 403 on POST, job and run scoping between two users, `file:///etc/hosts` capture -> 400, disabled/deleted user's tokens and sessions stop working.
|
||||
|
||||
## 5. Entry access rules (added after review of the first implementation)
|
||||
|
||||
The first implementation hid entries only in lists and search; fetching by uid still worked. These rules close that gap.
|
||||
|
||||
1. **Hidden means 404.** For a logged-in caller who is neither ADMIN nor OWNER, every endpoint that takes an entry uid answers `404 entry not found` when none of the entry's collection memberships (or its parent entry's) has `visibility_bits & caller_bits != 0`. This covers entry detail, artifacts, summary (GET and POST), tags (GET, POST, DELETE), entry collections, media token, favicon, PATCH and DELETE entry, thread title, rearchive, and collection add, remove and visibility. `GET /api/archives/:id/blobs/:sha256` allows a blob when at least one entry that uses it is visible. Guests keep `is_entry_publicly_accessible`. Rearchive of an unknown entry is `404` for everyone.
|
||||
2. **Tag counts.** `GET .../tags` counts only entries the caller can see. Tag names remain visible to every signed-in user.
|
||||
3. **No self-lockout.** A non-admin whose `PATCH .../collections/:c/entries/:uid` or `DELETE` would leave the entry invisible to the caller's own roles gets `400` and nothing changes. Admins and owners are exempt.
|
||||
4. **Run link at job start.** `CaptureConfig.job_uid` carries the job into the capture; `capture_jobs.run_uid` is written as soon as the run exists, so `GET .../runs` shows the creator an in-progress run (rule J3). Rearchive passes no job uid.
|
||||
5. **Default collection.** `DELETE .../collections/<default>` answers `400`.
|
||||
6. **Known limit.** A media token issued before an entry was hidden stays valid until it expires (two hours).
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue