Make login optional and fix 403 on changes

- CASHBOOK_PASSWORD is now optional; without it there's no login and
  the server logs a warning
- Origin check compares host names only, and also accepts
  X-Forwarded-Host and CASHBOOK_ALLOWED_HOSTS, so changes work when the
  app is reached by IP, on another port or through a proxy; refusals
  are logged with the reason and explained in the error
- Add a favicon so browsers stop requesting a missing /favicon.ico

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jimmyandClaude Opus 5.5 committed 2026-10-24 17:41:01 +13:00
1 parent 5dac554050
commit 17b48f25e8
4 files changed
+39 -13

No files matched your search

+5 -2
View File
@@ -15,10 +15,13 @@ services:
ports:
- "${CASHBOOK_BIND:-127.0.0.1}:${CASHBOOK_PORT:-8765}:8765"
# Browser login (HTTP Basic). Set CASHBOOK_PASSWORD in .env; compose won't start without it.
# Browser login (HTTP Basic): set CASHBOOK_PASSWORD in .env. Leave it unset to turn
# the login off; then anyone who can reach the port can see and change your books.
environment:
CASHBOOK_USERNAME: "${CASHBOOK_USERNAME:-cashbook}"
CASHBOOK_PASSWORD: "${CASHBOOK_PASSWORD:?set CASHBOOK_PASSWORD in .env}"
CASHBOOK_PASSWORD: "${CASHBOOK_PASSWORD:-}"
# other host names you reach it by, if the proxy doesn't pass Host through
CASHBOOK_ALLOWED_HOSTS: "${CASHBOOK_ALLOWED_HOSTS:-}"
volumes:
# cashbooks and statements/ (uploads go there too)