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:
1 parent
5dac554050
commit
17b48f25e8
4 files changed
+39
-13
No files matched your search
@@ -23,7 +23,7 @@ Everything runs on your machine; nothing is sent anywhere.
|
||||
### Docker Compose (recommended)
|
||||
|
||||
One-time setup, as the user who should own the books (uid 1000 by default).
|
||||
Create the data folder, then put a login password in `.env`:
|
||||
Create the data folder, then put a login password in `.env` (optional, see below):
|
||||
|
||||
```bash
|
||||
mkdir -p data
|
||||
@@ -40,7 +40,8 @@ docker compose up -d --build
|
||||
```
|
||||
|
||||
Open <http://127.0.0.1:8765> and log in as `cashbook` with the password from
|
||||
`.env`. Compose refuses to start if `CASHBOOK_PASSWORD` isn't set. Stop it with `docker compose down`, and check it with
|
||||
`.env`. With no `CASHBOOK_PASSWORD` set, there's no login: anyone who can reach the
|
||||
port can see and change your books, so only do that on a network you trust. Stop it with `docker compose down`, and check it with
|
||||
`docker compose ps` (it reports `healthy`) or `docker compose logs`.
|
||||
|
||||
**What the compose file sets up**
|
||||
@@ -48,7 +49,7 @@ Open <http://127.0.0.1:8765> and log in as `cashbook` with the password from
|
||||
- **Data:** `./data` is mounted at `/data` and holds the cashbooks and `statements/`
|
||||
(uploads go there). Back up this folder.
|
||||
- **Login:** HTTP Basic auth, with the password from the `CASHBOOK_PASSWORD`
|
||||
environment variable.
|
||||
environment variable. Leave it unset to turn the login off.
|
||||
- **Network:** published on `127.0.0.1:8765` only.
|
||||
- **Lockdown:**
|
||||
- read-only container filesystem, with scratch space only in `/tmp` (tmpfs);
|
||||
@@ -62,17 +63,23 @@ Open <http://127.0.0.1:8765> and log in as `cashbook` with the password from
|
||||
|
||||
| Variable | Default | Purpose |
|
||||
|---|---|---|
|
||||
| `CASHBOOK_PASSWORD` | *(required)* | login password |
|
||||
| `CASHBOOK_PASSWORD` | *(none)* | login password; unset means no login |
|
||||
| `CASHBOOK_USER` | `1000:1000` | uid:gid to run as; it should own `data/`. Use `0:0` with rootless Docker, which maps container root to you. |
|
||||
| `CASHBOOK_USERNAME` | `cashbook` | login name |
|
||||
| `CASHBOOK_BIND` | `127.0.0.1` | host address to publish on |
|
||||
| `CASHBOOK_PORT` | `8765` | host port |
|
||||
| `CASHBOOK_ALLOWED_HOSTS` | | extra host names you open the app by, comma-separated; see below |
|
||||
|
||||
**Reaching it from other machines:** keep it on `127.0.0.1` and put a reverse proxy
|
||||
with HTTPS in front (Caddy, nginx, Traefik). Basic auth sends the password with every
|
||||
request, so don't expose it over plain HTTP. The proxy must pass the original `Host`
|
||||
header through; uploads and changes are refused when the page's origin doesn't match
|
||||
it. For example, with Caddy:
|
||||
request, so don't expose it over plain HTTP.
|
||||
|
||||
To block other websites from making changes through your login, the app refuses
|
||||
changes whose page address doesn't match the server's host name. It checks the
|
||||
`Host` and `X-Forwarded-Host` headers. Caddy passes the original host through. With
|
||||
nginx, add `proxy_set_header Host $host;`. Otherwise, list the name you use in
|
||||
`CASHBOOK_ALLOWED_HOSTS`. A refused request shows up in `docker compose logs` with
|
||||
the reason. A Caddy example:
|
||||
|
||||
```
|
||||
cashbook.example.com {
|
||||
|
||||
Reference in new issue
Block a user