Files
hassio-addons/calibre_web/config.yaml
Alexandre 9204b31af8 fix(calibre-web): trust the supervisor range for the ingress auth header (#3010)
* fix(calibre-web): trust the supervisor range for the ingress auth header

Reimplements #3004 from the code as it stood before it, in one statement.

#3004 derived the addon's own address and wrote it unconditionally on every
start. That address changes across restarts, so the value had to be rewritten
each boot, which erased anything the user had added to the same field from the
calibre-web admin page -- and a follow-up that preserved their entries needed a
merge pass and a record of what had been injected, because a preserved stale
address stays trusted after supervisor hands it to another addon.

Trusting 172.30.32.0/23 removes the reason for all of it: the range covers
whichever address the addon gets, so the value is constant and can be written
once. Both forms are listed because calibre-web listens dual-stack and an ipv4
entry never matches an ipv4-mapped address; /119 is the mapped equivalent of
/23.

The WHERE clause is what keeps it out of the user's way. The list is written
only when the range is absent, which is true on a fresh 0.6.27 install and on
an install still carrying #3004's per-address list, and false afterwards -- so
an entry added in the admin page for a reverse proxy outside the supervisor
network survives every later start.

The trade-off is that any addon on the supervisor network can now present
X-WebAuth-User to port 8083 and be logged in. Maintainer's call, taken
knowingly in preference to the machinery the narrow list required.

The tolerated failure from #3004 is kept: the column only exists once
calibre-web 0.6.27+ has migrated app.db and cont-init runs first, so the
statement is allowed to fail and the next start applies it. The sqlite error
is now included in the warning rather than dropped.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(calibre-web): guard on the mapped range and keep existing entries

Addresses the review on #3010, both findings inside the one statement.

Codex, Copilot and CodeRabbit all noted the WHERE clause tested only
172.30.32.0/23, so a value carrying the ipv4 range without the mapped form
would skip the update forever while ingress stayed rejected -- a plausible
state, since that is exactly what someone adds by hand after reading that the
supervisor network is the source. Rather than test both, the guard now tests
::ffff:172.30.32.0/119 alone. That is the form ingress actually needs, given
calibre-web listens dual-stack, and the form nobody types by hand, so it
serves as the marker that this already ran. One substring either way.

Copilot and CodeRabbit also noted the assignment replaced the whole column,
losing an administrator entry on the first start. The required list is now
prepended to the existing value instead of replacing it. No case expression
is needed for the empty and NULL cases : the trailing comma that leaves
behind is an empty entry, which calibre-web's parser skips.

Both together cost one `||coalesce(...)` and a different substring. The
statement still runs at most once, and the duplicates it can leave behind are
entries calibre-web skips, or addresses inside the range now trusted anyway.

Checked against a transcription of cps/reverse_proxy_auth.py from 0.6.27 :
every produced value parses with nothing ignored, ::ffff:172.30.33.10 is
trusted and ::ffff:192.168.1.99 is not.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-23 15:08:03 +02:00

121 lines
2.1 KiB
YAML

arch:
- aarch64
- amd64
description: Browsing, reading and downloading eBooks using an existing Calibre database
devices:
- /dev/dri
- /dev/dri/card0
- /dev/dri/card1
- /dev/dri/renderD128
- /dev/vchiq
- /dev/video10
- /dev/video11
- /dev/video12
- /dev/video13
- /dev/video14
- /dev/video15
- /dev/video16
- /dev/ttyUSB0
- /dev/sda
- /dev/sdb
- /dev/sdc
- /dev/sdd
- /dev/sde
- /dev/sdf
- /dev/sdg
- /dev/nvme
- /dev/nvme0
- /dev/nvme0n1
- /dev/nvme0n1p1
- /dev/nvme0n1p2
- /dev/nvme0n1p3
- /dev/nvme1n1
- /dev/nvme1n1p1
- /dev/nvme1n1p2
- /dev/nvme1n1p3
- /dev/nvme2n1
- /dev/nvme2n1p1
- /dev/nvme2n1p2
- /dev/nvme2n3p3
- /dev/mmcblk
- /dev/fuse
- /dev/sda1
- /dev/sdb1
- /dev/sdc1
- /dev/sdd1
- /dev/sde1
- /dev/sdf1
- /dev/sdg1
- /dev/sda2
- /dev/sdb2
- /dev/sdc2
- /dev/sdd2
- /dev/sde2
- /dev/sdf2
- /dev/sdg2
- /dev/sda3
- /dev/sdb3
- /dev/sda4
- /dev/sdb4
- /dev/sda5
- /dev/sda6
- /dev/sda7
- /dev/sda8
- /dev/nvme0
- /dev/nvme1
- /dev/nvme2
environment:
DOCKER_MODS: linuxserver/mods:universal-calibre
FM_HOME: /config
HOME: /config
PGID: "0"
PUID: "0"
calibre-web_CONFIG_DIRECTORY: /config
shm_size: 1gb
hassio_api: true
image: ghcr.io/alexbelgium/calibre_web-{arch}
ingress: true
init: false
map:
- addon_config:rw
- all_addon_configs:rw
- homeassistant_config:rw
- media:rw
- share:rw
- ssl
name: Calibre-web
options:
env_vars: []
PGID: 0
PUID: 0
panel_admin: false
panel_icon: mdi:library
ports:
8083/tcp: 8084
ports_description:
8083/tcp: Calibre-web webui (Not required for Ingress)
privileged:
- SYS_ADMIN
- DAC_READ_SEARCH
- NET_ADMIN
schema:
env_vars:
- name: match(^[A-Za-z0-9_]+$)
value: str?
DOCKER_MODS: str?
OAUTHLIB_RELAX_TOKEN_SCOPE: str?
PGID: int
PUID: int
TZ: str?
cifsdomain: str?
cifspassword: str?
cifsusername: str?
ingress_user: str?
localdisks: str?
networkdisks: str?
slug: calibre-web
udev: true
url: https://github.com/alexbelgium/hassio-addons/tree/master/calibre_web
version: "0.6.27.2"
video: true