Split the README into focused docs under docs/
The README had grown to 658 lines. It is now a short overview: what Überbringer is, a quick start, a table of the docs and the licence. Each topic it held has a document of its own: - docs/install.md: install.sh, what it leaves behind, and upgrading. - docs/docker.md: the image behind a reverse proxy, the env file, health checks, and the ntfy state volume and token file. - docs/configuration.md: loading, environment variables, a table of every key in every section, and what is logged. The list of log messages becomes a summary of what is logged and reported. - docs/security.md: the API secret, issuing tokens and their scopes, the header-file recipe that keeps tokens off command lines (moved from docs/api.md), the reverse proxy, image URLs, and what is never logged. - docs/ntfy.md: the ntfy subscriptions, securing the topics and the printer's token, with the token scripts unchanged. - docs/cli.md: the command line. - docs/development.md: running from source, the Go version, make targets, the gate, generated files, the layout, CI and releases. CLAUDE.md names the new docs: a config key is now documented in docs/configuration.md, and the layout and Go version in docs/development.md. docs/api.md, design.md and the job-store plan point to the docs that now hold what they referred to in the README. The release archives also carry the docs on running the daemon. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
80a65f6083
commit
3d451eb0b7
14 files changed
+934
-678
No files matched your search
@@ -0,0 +1,92 @@
|
||||
# Tokens and security
|
||||
|
||||
## Contents
|
||||
|
||||
- [The API secret](#the-api-secret)
|
||||
- [Issuing tokens](#issuing-tokens)
|
||||
- [Keeping tokens off command lines](#keeping-tokens-off-command-lines)
|
||||
- [Behind a reverse proxy](#behind-a-reverse-proxy)
|
||||
- [Image URLs](#image-urls)
|
||||
- [What is never logged](#what-is-never-logged)
|
||||
|
||||
## The API secret
|
||||
|
||||
`api.secret` signs every bearer token (HS256) and must be at least 32
|
||||
bytes. `uberbringer secret` prints a new random one. `install.sh` writes it
|
||||
into a config that only root and the daemon's group can read, and
|
||||
`uberbringer config get` never prints it.
|
||||
|
||||
A token stays valid until it expires, and a token issued without `--ttl`
|
||||
never does. Changing the secret invalidates every token signed with the old
|
||||
one, which is the only way to withdraw a token.
|
||||
|
||||
## Issuing tokens
|
||||
|
||||
All `/api/v1` routes need an `Authorization: Bearer <token>` header; a
|
||||
token in a query string is refused, since it would leak into proxy logs.
|
||||
On a host set up by `install.sh`, issue a token as root, naming the client:
|
||||
|
||||
```sh
|
||||
sudo uberbringer token --config /etc/uberbringer/config.toml --subject my-script
|
||||
```
|
||||
|
||||
What a token may do is set when it is issued ([token](cli.md#token)):
|
||||
|
||||
- Without flags, it may use every route but cannot print jobs with `raw`
|
||||
elements.
|
||||
- `--raw` lets it print them. Give it only to clients that send ESC/POS
|
||||
bytes of their own, since those bytes reach the printer as they are.
|
||||
- `--modules ntfy,notify` limits it to those modules. Give integrations,
|
||||
such as the [ntfy client](api.md#printing-from-the-ntfy-client), one of
|
||||
these, so that they cannot send printer commands.
|
||||
|
||||
[api.md](api.md#api) gives the routes each token may call and the `403`
|
||||
`token_scope` answer for the others.
|
||||
|
||||
## Keeping tokens off command lines
|
||||
|
||||
Keep a token off command lines, where other users of the machine can
|
||||
read it, and out of shell history. The examples in [api.md](api.md) send
|
||||
the header from a file only you can read, which curl 7.55 and later take
|
||||
as `-H @file`. Make it like this: the token passes through a shell
|
||||
variable, never a command's arguments or the terminal, and the file is
|
||||
written only if the token command succeeded. For a client on another
|
||||
machine, copy the file there.
|
||||
|
||||
```sh
|
||||
token=$(sudo uberbringer token --config /etc/uberbringer/config.toml --subject my-script) &&
|
||||
(umask 077; printf 'Authorization: Bearer %s\n' "$token" > ~/.uberbringer-auth)
|
||||
unset token
|
||||
```
|
||||
|
||||
[Printing from the ntfy client](api.md#printing-from-the-ntfy-client)
|
||||
does the same for the ntfy client's user, and [docker.md](docker.md) keeps
|
||||
the secret in an env file for a container.
|
||||
|
||||
## Behind a reverse proxy
|
||||
|
||||
The daemon serves no TLS and listens on `127.0.0.1` by default. A reverse
|
||||
proxy in front terminates HTTPS: Caddy, which `install.sh` sets up, or your
|
||||
own in front of the [Docker image](docker.md). The proxy sets `X-Real-IP`
|
||||
to the client's address, and the daemon reads it only from the addresses
|
||||
in `webserver.trusted_proxies`, so that each client has a rate limit of its
|
||||
own ([webserver](configuration.md#webserver)).
|
||||
|
||||
## Image URLs
|
||||
|
||||
Images are fetched by the worker, when the job prints. URLs that resolve to
|
||||
loopback, private or link-local addresses, cloud metadata endpoints
|
||||
included, are refused unless `images.allow_private_networks` is true or the
|
||||
host is in `images.allowed_hosts` ([images](configuration.md#images)). The
|
||||
address is checked when the connection is made, so a redirect or a DNS
|
||||
answer that changes cannot get round it.
|
||||
|
||||
## What is never logged
|
||||
|
||||
Print contents, tokens and the API secret never reach the logs or Sentry.
|
||||
Request bodies and the `Authorization` header are never sent to Sentry. An
|
||||
ntfy subscription never logs a message's text or its topic, and its
|
||||
`last_error` in `/healthz` leaves out the topics, since on a public server a
|
||||
topic's name can be all that keeps others from publishing to it.
|
||||
[Logs](configuration.md#logs) lists what is logged, and
|
||||
[ntfy.md](ntfy.md#securing-the-topics) how to keep strangers off your topics.
|
||||
Reference in new issue
Block a user