Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Set every `CHANGE_*` value. The ones you cannot skip:
|---|---|
| `POSTGRES_DSN` | The database connection string. Change `CHANGE_DB_PASS` to a strong password. **The same password must go in `POSTGRES_PASSWORD` in `docker-compose.yml`.** |
| `MQTT_BROKER_1_URL`, `_USERNAME`, `_PASSWORD` | Your MeshCore MQTT broker and the subscriber account on it. The template also lists a second broker; if you have only one, clear `MQTT_BROKER_2_URL` (an empty URL disables that worker). |
| `DOMAIN` | Your public hostname, for example `beacon.example.com`. Caddy requests a Let's Encrypt certificate for it. |
| `DOMAIN` | Your public hostname, for example `beacon.example.com`. Caddy requests a Let's Encrypt certificate for it. The server reads it too, for the links in account mail. |
| `VITE_API_BASE` | `https://<your-domain>/api/v1`. The browser calls this, so it must be the public domain, never `localhost`. |
| `VITE_WS_URL` | `wss://<your-domain>/ws` |

Expand Down Expand Up @@ -154,7 +154,7 @@ gone private; see [Troubleshooting](docs/troubleshooting.md#docker-compose-up-fa
- [Reverse proxy](docs/reverse-proxy.md): Caddy, nginx, Apache, rate limits, split origins, and an RSA certificate for observers.
- [Securing a deployment](docs/security.md): the admin key, the listener, origins, bans.
- [Day-to-day operations](docs/operations.md): health, logs, retention, backup and restore.
- [Upgrading](docs/upgrading.md): 2.0.0 from 1.x, 2.1, 2.3.0 from 2.2.0, and routine upgrades.
- [Upgrading](docs/upgrading.md): 2.0.0 from 1.x, 2.1, 2.3.0 from 2.2.0, 2.3.1 from 2.3.0, and routine upgrades.
- [Troubleshooting](docs/troubleshooting.md): symptom, cause, fix.
- [Releases and versioning](docs/releases.md): image tags and how releases are cut.

Expand Down
24 changes: 21 additions & 3 deletions app_config/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,30 @@ MQTT_BROKER_2_URL=wss://mqtt2.meshcore.ca:443
MQTT_BROKER_2_USERNAME=CHANGE_NAME
MQTT_BROKER_2_PASSWORD=CHANGE_PASS

# ---- Public domain / TLS (service: caddy) -------------------
# Site address + automatic Let's Encrypt certificate.
# A name for each broker, shown on packets and observers instead of mqtt1 / mqtt2: 1 to 64 characters of
# a-z, 0-9, _ or -, and the two must differ. Data received before a change keeps the name it was stored under.
# MQTT_BROKER_1_NAME=mqtt1
# MQTT_BROKER_2_NAME=mqtt2

# Set for a broker that is a rebroadcaster: it forwards messages from other MeshCore brokers and tags each one
# with the broker it originally came from. Beacon then connects with MQTT 5 and reads the tags.
# observers -> MeshCore broker -> rebroadcaster <- Beacon subscribes here
# The rebroadcaster must leave topic and payload unchanged and set two MQTT 5 user properties on every message:
# source-broker short name of the source broker: a-z, 0-9, _ or -, up to 64 characters (e.g. letsmesh)
# source-host host the message arrived on, lowercase, no port (e.g. mqtt.example.net)
# Only the rebroadcaster should be able to publish to it. A message without the tags is still accepted and
# shows this connection's own name. Leave unset for a MeshCore broker that observers publish to directly.
# MQTT_BROKER_1_REBROADCAST=true
# MQTT_BROKER_2_REBROADCAST=true

# ---- Public domain / TLS (services: caddy, app) -------------
# Site address + automatic Let's Encrypt certificate. The server reads it too, as its own public
# address: for the links in account mail and for polling.foreign_claims.
DOMAIN=beacon.example.com

# Type 2 server host only: the web frontend's hostname. Caddy redirects everything that is
# not /api/*, /ws or /.well-known/beacon-push there. Not used by the all-in-one stack.
# not /api/*, /ws or /.well-known/beacon-push there, and the server uses it for the links in account
# mail. Not used by the all-in-one stack.
# WEB_DOMAIN=beacon.example.com

# ---- Frontend URLs (service: web) ---------------------------
Expand Down
13 changes: 12 additions & 1 deletion app_config/config.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,13 @@ cache:
# max_requests: 2 # poll attempts per repeater in each window; 1 to 3
# reading_retention: 744h # how long readings are kept; at least 1h (default 31 days)
# min_client_version: "" # oldest observer firmware allowed to poll, as X.Y.Z; empty allows all
# foreign_claims: off # off: every polling claim is treated as this server's own.
# # check: a claim is this server's own only when its signed poll_url names this
# # server's DOMAIN (from .env). Older observer firmware sends no poll_url; its
# # claim is judged by the broker it came through, which needs
# # MQTT_BROKER_n_REBROADCAST=true in .env on a rebroadcaster, and is its own
# # when that broker is in mqtt_hosts. A claim with neither is dropped.
# # Readings from other observers are kept and shown as foreign.
# excluded_nodes: [] # repeaters that are never polled; up to 16 public keys, 64 hex characters each
# paused: false # true tells every observer to stop polling, without turning the feature off
# authority: evidence # who can be chosen to poll. evidence: any observer, ranked by how well Beacon
Expand All @@ -474,14 +481,18 @@ cache:
# username: "" # SMTP login; empty sends without signing in
# from: "" # the sender people see, e.g. "Beacon <no-reply@example.org>"
# starttls: true # require an encrypted connection; the send fails if the server lacks STARTTLS
# tls_skip_verify: false # true accepts a certificate that cannot be verified (self-signed, private CA),
# # for a mail server you host yourself. The link stays encrypted but the server
# # is not checked, so use it only on a network you trust.

# User accounts: sign-in for the web app and the mobile app. Off by default; with it off
# no account route is served. Mode local sends mail through the mail block above.
# A web app on another origin than the API also needs cors.allowed_methods, cors.allowed_headers
# (with X-Beacon-CSRF) and cors.allow_credentials; same origin needs nothing.
# The links in mail use the server's public address, taken from DOMAIN in .env (WEB_DOMAIN when the web
# app is on another host). The old public_url key is no longer read.
#accounts:
# mode: off # off, or local for sign-up with username, email and password
# public_url: "" # https URL of the web app, no path; used in mailed links
# registration: open # open: anyone can sign up. closed: no new sign-ups, existing users still sign in

# Alerts: tell users when a radio on their Atlas needs attention. Needs accounts. Off by default.
Expand Down
16 changes: 10 additions & 6 deletions docs/accounts.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ mail:

accounts:
mode: local
public_url: https://beacon.example.org
registration: open
```

The server also needs to know its public address, for the links it mails. It builds it from the
environment: `https://` plus `WEB_DOMAIN`, or plus `DOMAIN` when `WEB_DOMAIN` is not set.
The Docker stacks already set `DOMAIN` in `.env`. Outside them, set it yourself.

Put the SMTP password in the environment, never in the file:

```
Expand All @@ -44,13 +47,13 @@ In the Docker stacks that is the `.env` of the host that runs the server. Then r
| Key | Default | What it does |
|---|---|---|
| `mode` | `off` | `off` or `local` (`portal` is for the project's own instance, see [Configuration](configuration.md#user-accounts)). Anything else stops startup. The rest of the block is not checked while this is `off`. |
| `public_url` | none | Required when `mode` is `local`. The address people use for the web app: `http` or `https`, no path, query, fragment or credentials. Plain `http` is allowed only for `localhost` and `127.0.0.1`. Every link in a mail is built from it, never from a request header. |
| `registration` | `open` | `open` or `closed`. When closed, `POST /auth/register` answers `403 registration_closed` and `features.registration` is `false`. People who already have an account keep signing in. |
| `mail.host` | none | Required. |
| `mail.port` | `587` | 1 to 65535. |
| `mail.username` | empty | Empty means no authentication. When set, Beacon uses AUTH PLAIN, and the server must offer AUTH. |
| `mail.from` | none | Required, one address, for example `"Beacon <no-reply@example.org>"`. |
| `mail.starttls` | `true` | When true the send fails if the server does not offer STARTTLS; Beacon never falls back to plain text. Set `false` only for a trusted local relay. |
| `mail.tls_skip_verify` | `false` | `true` accepts a mail server certificate that cannot be verified (self-signed, private CA, wrong name). The connection is still encrypted, but the server is not checked, so use it only for a mail server you run yourself on a network you trust. Applies to account mail and alert mail. Startup logs a warning while it is on. No effect with `starttls: false`. |

`BEACON_SMTP_PASSWORD` is the only account secret that comes from the environment. A mistake in the
block stops startup with an error naming the key. An `smtp` block left under `accounts` stops startup
Expand All @@ -68,19 +71,20 @@ this). Unset, blank or `BEACON` gives `Beacon`. When `mail.from` is a bare addre
sender's display name; an explicit display name in `mail.from` is kept as it is. Alert mail uses the same
name in its subject.

The mailed links are `<public_url>/?view=verify#token=...` and `<public_url>/?view=reset#token=...`
The mailed links are `<public address>/?view=verify#token=...` and `<public address>/?view=reset#token=...`
(an email-change link is a verify link). The token is in the URL fragment, which a browser never
sends to a server, so no proxy or access log sees a live token. Links mailed before this change used
`?token=...` and Beacon Web still accepts them. The links open the web app, so `public_url` must be
where Beacon Web is served.
`?token=...` and Beacon Web still accepts them. The links open the web app, so the public address
must be where Beacon Web is served: set `WEB_DOMAIN` when that is not `DOMAIN`. Every link is built
from it, never from a request header. Plain `http` is used only for `localhost` and `127.0.0.1`.

On a read-only server (`server.read_only`) every account write answers `503 read_only`, sign-in
included. The hourly cleanup and the operator user routes are off.

## Same site, and a web app on another origin

The session cookie is `beacon_session`. It is `HttpOnly`, `SameSite=Lax`, `Path=/`, has no `Domain`
and is `Secure` unless `public_url` is `http://localhost...` or `http://127.0.0.1...`. A browser sends
and is `Secure` unless the public address is `http://localhost...` or `http://127.0.0.1...`. A browser sends
it only to the host that set it, and `SameSite=Lax` means only from a page on the same site.

- **Same origin** (deployment type 1: the web app at `/` and the API at `/api/*` on one host):
Expand Down
2 changes: 1 addition & 1 deletion docs/alerts.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ clients can translate it. The codes are listed in the [API contract](api-contrac
## Email

One message per user for each evaluation pass: subject "Beacon: 1 alert" or "Beacon: n alerts",
one plain sentence per alert, and a link to `<public_url>/?tab=Atlas`. The alert sender sends it
one plain sentence per alert, and a link to `<public address>/?tab=Atlas`. The alert sender sends it
directly, not through the account mail queue, with a 30 second timeout for each message. A notice
counts as mailed only once the SMTP server accepted it, and a mail that went out is never sent again,
even when the push of the same notice is retried. A failed send is retried on the email channel's
Expand Down
Loading