Files
shelfmark/docs/users-and-requests.md
T
463ef49ac3 feat(search): let each user pick their own default book languages (#1255)
## Why

`BOOK_LANGUAGE` is a per-reader property, not a per-instance one. On a
shared install one household member searches in German while another
wants English and German — today whoever changes the setting changes it
for everyone, and the only escape is re-picking languages in the filter
on every single search.

The per-user override machinery already carries `SEARCH_MODE`, the
metadata providers and the default release sources, so the language
default mostly had to opt into it.

## What changed

**The field.** `BOOK_LANGUAGE` becomes `user_overridable` and moves from
the **General** tab to **Search Mode**, next to the other
user-overridable search defaults (per
[review](https://github.com/calibrain/shelfmark/pull/1255#issuecomment-5391189094)
— the first version had the Search section span two tabs, this one
doesn't). Admins set it per user in the user editor, users set it in
**My Account → Search Preferences**, and the Search Mode tab carries the
usual "N users override this" summary.

**No migration for the move.** `general` and `search_mode` both persist
into `settings.json`, and a field's value is resolved through
`load_config_file(tab)` for the tab it's declared on — so an install
that already stores `BOOK_LANGUAGE` keeps its value. Checked against a
`settings.json` written while the field still lived on General: the
stored value resolves unchanged, a fresh install still gets `["en"]`,
and `BOOK_LANGUAGE` in the environment still overrides both.

**The two places the default is read.**

- `/api/config` seeds the frontend's language filter, so it now resolves
`BOOK_LANGUAGE` for the session user.
- `build_release_search_plan` falls back to the default whenever a
request carries no language filter — which is exactly what the filter's
"Default" option sends. It takes an optional `user_id`, passed by
`/api/releases` from the session and by the Prowlarr retry path from
`task.user_id`, so a retry re-searches in the languages of whoever
queued the download.

**Validation.** Overrides go through `normalize_language()`, so
`"German"`, `"ger"` and `"de"` all store as `de`, and an unknown
language is rejected with a message naming it instead of being silently
searched for. An empty list stays an empty list (a deliberate "no
default filter"), `null` clears the override as everywhere else, and ENV
still wins: with `BOOK_LANGUAGE` set in the environment the field
reports `fromEnv` and overrides are ignored.

**Scope.** Only the language default becomes overridable. The two format
lists left behind under "Default Search Filters" stay admin-only — they
describe what the library and its post-processing accept, not what a
reader wants to read. There's a test pinning that.

## Verification

- 2681 unit tests pass (2670 before, 11 added)
- `ruff check`, `ruff format`, `basedpyright` over backend and tests,
and `vulture` all clean; frontend lint, format, typecheck and 126 unit
tests clean
- `docs/environment-variables.md` regenerated via
`scripts/generate_env_docs.py` (the `BOOK_LANGUAGE` row follows the
field into the Search Mode section)
- Manually against a two-user instance with builtin auth (first round,
before the tab move): with user A on German and user B on
English+German, `/api/config` returns each reader their own
`default_language` and an unfiltered `/api/releases` plans the matching
languages; an admin can set and read the same override for another user;
clearing it falls back to the global value; a stray `"klingon"` is
rejected; and `BOOK_LANGUAGE` in the environment overrides both users
with the field marked `fromEnv`
- After the tab move I re-ran the suites above plus the
stored-value/fresh-install/ENV check described under "No migration for
the move"; the behaviour it exercises is what the move could have broken

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Co-authored-by: CaliBrain <calibrain@l4n.xyz>
2026-08-24 17:57:21 -04:00

5.4 KiB

Users & Requests

Configure in Settings → Users & Requests.

Authentication Methods

Shelfmark supports four authentication methods, configured in Settings → Security.

Local

You create user accounts directly in Shelfmark with a username and password. At least one local admin account must exist before this mode can be enabled.

Proxy Authentication

Your reverse proxy handles authentication and passes the username to Shelfmark via a header (e.g. Remote-User). Accounts are created automatically on first sign-in. If a local user with the same username already exists, the proxy identity will be linked to that account rather than creating a duplicate. Admin status can optionally be derived from a groups header.

OIDC (OpenID Connect)

Users sign in through your identity provider. Accounts are created automatically on first login (unless auto-provisioning is disabled, in which case you need to pre-create them). If a local user with a matching verified email already exists, the OIDC identity will be linked to that account on first sign-in. Admin status can optionally be derived from a group claim.

A local admin account is required as a fallback. See OIDC for provider setup.

Calibre-Web Database

User accounts are synced from your Calibre-Web app.db. If a local user with a matching email already exists, the CWA identity will be linked to that account. Roles are kept in sync with CWA. Users removed from CWA are cleaned up on the next sync.

Requires mounting your Calibre-Web app.db to /auth/app.db.

Per-User Settings

Admins can configure per-user settings by editing a user in the user management panel. Non-admin users can also edit their own settings through My Account (accessible from the user menu). Admins control which sections are visible in My Account via the Visible Self-Settings Sections option.

There are four categories of per-user settings:

Delivery Preferences

Override where a user's downloads are sent. Options depend on the global output mode configuration:

  • Output mode — Folder, Email (SMTP), or BookLore (API)
  • Destination — A custom folder path for this user's ebook downloads
  • Audiobook destination — A custom folder path for audiobook downloads
  • BookLore library/path — Per-user BookLore target (when using BookLore output mode)
  • Email recipient — Per-user email address (when using Email output mode)

Search Preferences

Override how a user searches, on top of the global search defaults:

  • Search mode — Direct or Universal for this user
  • Default book languages — The languages a user's searches fall back to when they don't pick one themselves. Useful for a shared instance where readers want different languages.
  • Metadata providers — Book, audiobook, and combined-mode provider for this user
  • Default release sources — The release tab opened first for books and audiobooks

Notifications

Users can configure personal notification routes, separate from the global notification settings. Each route targets a URL (e.g. an Apprise-compatible endpoint) and can be scoped to specific event types or all events.

Request Policy (admin-only)

Admins can override the default ebook/audiobook modes and request rules for individual users. See Per-User Overrides below.


Requests

The request system controls whether users can download directly or need admin approval first.

Policy Modes

Each content type (ebook, audiobook) has a default mode that sets the baseline:

Mode Behaviour
Download Users download directly, no approval needed
Request Release Users pick a specific release, then submit it for admin approval
Request Book Users request the book itself — an admin picks the release and fulfils it
Blocked No downloads or requests allowed

Settings

Setting Description Default
Enable Requests Master toggle. When off, everyone downloads directly Off
Default Ebook Mode Baseline mode for all ebook sources Download
Default Audiobook Mode Baseline mode for all audiobook sources Download
Request Rules Per-source overrides (see below) None
Max Pending Requests Per User Open request limit per user 20
Allow Notes on Requests Let users attach a note when submitting On

Request Rules

The rules matrix lets you override the mode for specific source + content type combinations. Rules can only be equal to or more restrictive than the content-type default — they cannot grant more access than the baseline.

For example, if the default ebook mode is "Download", a rule can restrict a specific source to "Request Release" or "Blocked", but not the other way around. If no rule matches, the content-type default applies.

Per-User Overrides

Admins can override the default ebook/audiobook modes and request rules for individual users. Per-user rules are overlaid on the global rules, not replacing them.

Request Lifecycle

  1. User submits a request (book or release level, depending on the resolved policy mode)
  2. Request appears in the admin request queue as pending
  3. Admin either fulfils (queues a download) or rejects the request
  4. For fulfilled requests, delivery state is tracked through the download pipeline
  5. If delivery fails, an admin can reopen the request to try a different release
  6. Users can cancel their own pending requests