diff --git a/docs/wiki/HTTP-API.md b/docs/wiki/HTTP-API.md index 877d35f..3b42ef4 100644 --- a/docs/wiki/HTTP-API.md +++ b/docs/wiki/HTTP-API.md @@ -1,10 +1,10 @@ -The BBS has an HTTP API for programs and web front ends: REST for -accounts, message areas, mail and files; server-sent events; and -WebSockets for chat, in JSON or protobuf. A web client is a node like -any other: it shows in *Who's online*, chats with terminal callers, gets -node messages and can page the sysop. +The BBS has an HTTP API for programs and web front ends. It has REST for +accounts, message areas, mail and files, server-sent events, and +WebSockets for chat, in JSON or protobuf. A web client is a node, as all +other clients are. It shows in *Who's online*, chats with terminal +callers, gets node messages and can page the sysop. -It is on when `bbs.conf` has an `[http]` section: +The API is enabled when `bbs.conf` has an `[http]` section: ```ini [http] @@ -17,29 +17,29 @@ key_file = /etc/bbs/tls/key.pem | Setting | Default | What it sets | |---|---|---| -| `address` | `:8443` | where it listens | -| `tls` | `yes` | TLS needs `cert_file` and `key_file`. `tls = no` is for `127.0.0.1` behind a proxy that has TLS; `bbs check` warns about it on any other address | -| `trusted_proxies` | (none) | reverse proxies in front (addresses or CIDR ranges, by spaces or commas), believed when they say whose a request is: [below](#behind-a-proxy) | -| `secure_cookies` | as `tls` | the forum's and image boards' login cookies go over HTTPS only; say `yes` when a proxy in front has the TLS | +| `address` | `:8443` | the address on which it listens | +| `tls` | `yes` | TLS must have `cert_file` and `key_file`. `tls = no` is for `127.0.0.1` behind a proxy that has TLS. `bbs check` gives a warning about it on all other addresses | +| `trusted_proxies` | (none) | reverse proxies in front (addresses or CIDR ranges, with spaces or commas between them). The server believes them when they tell the source of a request: [below](#behind-a-proxy) | +| `secure_cookies` | as `tls` | the login cookies of the forum and image boards go over HTTPS only. Set `yes` when a proxy in front has the TLS | | `anonymous` | `yes` | `/system` and `/who` without a token | -| `cors` | (none) | one browser origin allowed to call the API (no `*`); WebSockets are accepted only from it and the API's own host | +| `cors` | (none) | one browser origin that can call the API (no `*`). The API accepts WebSockets only from this origin and from its own host | | `metrics` | (none) | an address for Prometheus metrics, `/metrics` (keep it private) | -| `max_per_ip` | `20` | connections at once from one address | -| `rate`, `burst` | `10`, `20` | requests a second per token (per address without one), and how many may come at once | -| `session_hours` | `24` | how long a login's token lasts | +| `max_per_ip` | `20` | the maximum number of connections at one time from one address | +| `rate`, `burst` | `10`, `20` | requests each second for each token (for each address without a token), and the number that can come at one time | +| `session_hours` | `24` | the validity of the token of a login | | `terminal` | `yes` | the web terminal page (below) | -| `forum`, `forum_guests`, `forum_theme`, `forum_flags` | `yes`, `yes`, `ipb3`, `yes` | the [web forum](Web-Forum), guests reading it, and its theme (`ipb3`, `ipb5`, `ipb4`, `ipb2`, `ipb1`, `ikon`, `vb6`, `vb5`, `vb4`, `vb3`, `vb2`, `vblite`, `xf23`, `xf2`, `xf1`, `mybb18`, `mybb16`, `mybb12`, `pun14`, `flux15`, `pun12`, `yabb25`, `yabb2`, `yabb1`, `smf30`, `smf21`, `smf20`, `smf1`, `phpbb33`, `phpbb32`, `phpbb31`, `phpbb30`, `phpbb2` or `phpbb1`) | -| `chan` | `yes` | the [image boards](Image-Boards) at `/chan/` (set up in `[chan]`) | +| `forum`, `forum_guests`, `forum_theme`, `forum_flags` | `yes`, `yes`, `ipb3`, `yes` | the [web forum](Web-Forum), guest access to it, and its theme (`ipb3`, `ipb5`, `ipb4`, `ipb2`, `ipb1`, `ikon`, `vb6`, `vb5`, `vb4`, `vb3`, `vb2`, `vblite`, `xf23`, `xf2`, `xf1`, `mybb18`, `mybb16`, `mybb12`, `pun14`, `flux15`, `pun12`, `yabb25`, `yabb2`, `yabb1`, `smf30`, `smf21`, `smf20`, `smf1`, `phpbb33`, `phpbb32`, `phpbb31`, `phpbb30`, `phpbb2` or `phpbb1`) | +| `chan` | `yes` | the [image boards](Image-Boards) at `/chan/` (configured in `[chan]`) | The OpenAPI 3.1 description is at `/api/v1/openapi.json`. ## Behind a proxy -The server can sit behind a reverse proxy (nginx, Caddy, HAProxy, a load -balancer) that handles TLS. Every request then comes from the proxy's -address, so list the proxy in `trusted_proxies`, and the server will -trust it to say which caller each request is from: +The server can be behind a reverse proxy (nginx, Caddy, HAProxy, a load +balancer) that does the TLS. Then all requests come from the address of +the proxy. Thus, put the proxy in `trusted_proxies`. Then the server +trusts the proxy to tell the caller of each request: ```ini [http] @@ -60,89 +60,91 @@ location / { } ``` -The caller's address is the last address in `X-Forwarded-For` (or else -`Forwarded`'s `for=`, or else `X-Real-IP`) that is not a trusted proxy. -Any addresses before it are whatever the caller sent, and are not -trusted. That address is then used for the request everywhere: rate -limits, logins and the logs, the forum, the web terminal's throttling, the -[image boards](Image-Boards)' flood control and bans, and the -`[security]` deny lists and bans (a refused caller gets 403). Connections -from a trusted proxy are not held to `max_per_ip`, because they carry -many callers. Requests from anywhere else are taken as they come, and -their forwarding headers are ignored. +The address of the caller is the last address in `X-Forwarded-For` (or +the `for=` of `Forwarded`, or `X-Real-IP`) that is not a trusted proxy. +The caller sent the addresses before it, and the server does not trust +them. The server then uses that address for the request in all +functions: rate limits, logins and the logs, the forum, the throttling +of the web terminal, the flood control and bans of the +[image boards](Image-Boards), and the `[security]` deny lists and bans +(a refused caller gets 403). Connections from a trusted proxy do not +count against `max_per_ip`, because they carry many callers. The server +accepts requests from all other sources as they come, and ignores their +forwarding headers. ## Tokens and scopes -Every request but `/login`, `/openapi.json` and (when `anonymous = yes`) -`/system` and `/who` needs a token: `Authorization: Bearer bbs_...`. +All requests except `/login`, `/openapi.json` and (when +`anonymous = yes`) `/system` and `/who` must have a token: +`Authorization: Bearer bbs_...`. - A **session**: `POST /api/v1/login` with `{"name": ..., "password": ...}` - (and `"scopes"`, to have fewer) returns `{"token": ..., "expires": ...}`. + (and `"scopes"`, for fewer scopes) gives `{"token": ..., "expires": ...}`. `POST /api/v1/logout` ends it. - An **API key**, for a program: `bbs token add alice -scope read,post - -expires 90 -name "my bot"` prints it once. `bbs token list [USER]` and - `bbs token revoke ID` manage them, and users see and revoke their own at - `/api/v1/me/tokens`. + -expires 90 -name "my bot"` prints it one time. `bbs token list [USER]` + and `bbs token revoke ID` manage them. Users see and revoke their own + keys at `/api/v1/me/tokens`. -Only a hash of a token is kept. A locked user's tokens stop working. +The BBS keeps only a hash of a token. The tokens of a locked user stop. | Scope | Allows | |---|---| | `read` | the account, users, message areas and messages, last read | -| `post` | posting | -| `mail` | reading, sending and deleting mail | -| `chat` | the event stream, WebSockets, node messages, paging | -| `files` | file areas, uploading and downloading | -| `sysop` | `/admin/...` (only for a sysop's tokens) | +| `post` | posts | +| `mail` | read, send and delete mail | +| `chat` | the event stream, WebSockets, node messages, pages | +| `files` | file areas, uploads and downloads | +| `sysop` | `/admin/...` (only for the tokens of a sysop) | ## REST -Every endpoint is under `/api/v1` and takes and returns JSON (except +All endpoints are under `/api/v1`. They accept and give JSON (except uploads and downloads). Errors are `{"error": "...", "code": "..."}`. | Request | What it does | Scope | |---|---|---| -| `POST /login`, `POST /logout` | a session token; ending it | (none), any | +| `POST /login`, `POST /logout` | gives a session token. Ends it | (none), any | | `GET /system` | the name, sysop, counts, features | anonymous | -| `GET /who` | who is online (with each `terminal`, as it said what it is, and `country`, ISO 3166, where it is known) | anonymous | +| `GET /who` | the users who are online (with each `terminal`, as it identified itself, and `country`, ISO 3166, if known) | anonymous | | `GET /callers?limit=` | the last callers, newest first | read | -| `GET`, `PATCH /me` | your account, access and settings; change your location, a line about yourself (`about`), password or settings (`{"prefs": {"ansi": "off"}}`; `""` forgets one) | read | -| `GET /me/tokens`, `DELETE /me/tokens/{id}` | your tokens; revoke one | any | +| `GET`, `PATCH /me` | your account, access and settings. Change your location, a line about yourself (`about`), password or settings (`{"prefs": {"ansi": "off"}}`. `""` removes one) | read | +| `GET /me/tokens`, `DELETE /me/tokens/{id}` | your tokens. Revokes one | any | | `GET /me/keys` | your SSH keys | read | -| `POST /me/keys`, `DELETE /me/keys/{id}` | add an SSH key (`{"key": "ssh-ed25519 ..."}`, from a login's session only); delete one | any | +| `POST /me/keys`, `DELETE /me/keys/{id}` | adds an SSH key (`{"key": "ssh-ed25519 ..."}`, from the session of a login only). Deletes one | any | | `GET /users`, `/users/{name}` | users | read | -| `GET /areas`, `/areas/{id}` | message areas, with your unread | read | -| `GET /areas/{id}/messages?after=&limit=&body=no` | messages after an id (200 at most) | read | -| `POST /areas/{id}/messages` | post: `{"subject", "body", "reply_to", "alias": true, "poll": ["answer", ...]}` | post | -| `PUT /areas/{id}/lastread` | mark read up to a message | read | +| `GET /areas`, `/areas/{id}` | message areas, with your unread messages | read | +| `GET /areas/{id}/messages?after=&limit=&body=no` | messages after an id (a maximum of 200) | read | +| `POST /areas/{id}/messages` | posts: `{"subject", "body", "reply_to", "alias": true, "poll": ["answer", ...]}` | post | +| `PUT /areas/{id}/lastread` | marks the area as read up to a message | read | | `GET /messages/{id}` | a message | read | -| `GET /mail`, `GET`, `DELETE /mail/{id}` | your inbox; a mail (marked read); delete it | mail | -| `POST /mail` | send: to a user, or `Name@zone:net/node` as netmail | mail | -| `GET /qwk?mark=no` | your [QWK packet](Offline-Mail) (`X-QWK-Messages`: how many); its messages then count as read, unless `mark=no` | mail | +| `GET /mail`, `GET`, `DELETE /mail/{id}` | your inbox. A mail (marked as read). Deletes it | mail | +| `POST /mail` | sends: to a user, or `Name@zone:net/node` as netmail | mail | +| `GET /qwk?mark=no` | your [QWK packet](Offline-Mail) (`X-QWK-Messages`: the number of messages). Its messages then count as read, unless `mark=no` | mail | | `POST /qwk/rep` | a REP packet (the body): `{"posted", "mailed", "duplicates", "errors"}` | mail and post | | `GET /fileareas`, `/fileareas/{id}/files`, `/files/{id}` | file areas and files | files | -| `POST /fileareas/{id}/files?name=&description=` | upload: the body is the file | files | -| `GET /files/{id}/content` | download (ranges work) | files | -| `GET /messages/{id}/thread` | the message's thread from its start, with each one's depth | read | -| `POST /messages/{id}/vote`, `POST /messages/{id}/answer` | vote (`{"value": 1}`, -1, 0); answer a poll (`{"answer": 0}`) | post | +| `POST /fileareas/{id}/files?name=&description=` | uploads: the body is the file | files | +| `GET /files/{id}/content` | downloads (ranges operate) | files | +| `GET /messages/{id}/thread` | the thread of the message from its start, with the depth of each message | read | +| `POST /messages/{id}/vote`, `POST /messages/{id}/answer` | votes (`{"value": 1}`, -1, 0). Answers a poll (`{"answer": 0}`) | post | | `GET /files?q=` or `?since=` | files by words in their names and descriptions, or added since a time (RFC 3339), newest first | files | -| `GET /admin/bans`, `DELETE /admin/bans/{ip}` | addresses banned for failed logins; lift a ban | sysop | -| `GET /admin/hacklog?lines=` | the hack log's last lines | sysop | -| `GET /admin/events`, `POST /admin/events/{name}/run` | the scheduled events; run one now | sysop | -| `PUT /admin/available` | `{"available": false}`: pages reach no sysop | sysop | -| `GET /files/{id}/listing` | what is in an archive (ZIP, tar, tar.gz); 422 for another file | files | +| `GET /admin/bans`, `DELETE /admin/bans/{ip}` | addresses banned for failed logins. Removes a ban | sysop | +| `GET /admin/hacklog?lines=` | the last lines of the hack log | sysop | +| `GET /admin/events`, `POST /admin/events/{name}/run` | the scheduled events. Runs one now | sysop | +| `PUT /admin/available` | `{"available": false}`: pages go to no sysop | sysop | +| `GET /files/{id}/listing` | the contents of an archive (ZIP, tar, tar.gz). 422 for other files | files | | `GET /chat/rooms` | chat rooms in use | chat | -| `POST /nodes/{n}/message`, `POST /page` | a line to a node; page the sysop (both need an open stream) | chat | +| `POST /nodes/{n}/message`, `POST /page` | a line to a node. Pages the sysop (the two must have an open stream) | chat | | `GET /events` | server-sent events | chat or read | | `GET /ws`, `GET /ws/proto` | WebSockets | chat | -| `GET /admin/pages`, `POST /admin/pages/{node}/answer` | pages waiting; answer one (node 0: the longest waiting) | sysop | -| `POST /admin/users`, `PATCH /admin/users/{name}` | add a user; lock, unlock, make sysop, set password, `level`, `flags`, `qwk_node` | sysop | -| `POST /admin/areas`, `PATCH /admin/areas/{id}` | add an area; set its newsgroup, echo tag, `read_require`, `post_require` | sysop | -| `POST /admin/nodes/{n}/kick` | throw a caller off | sysop | -| `GET /admin/fido`, `POST /admin/fido/poll` | FidoNet links and outbound; call them now | sysop | -| `GET /admin/news`, `POST /admin/news/sync` | news peers; sync now | sysop | -| `GET /admin/qwknet`, `POST /admin/qwknet/call?net=` | [QWK networks](Offline-Mail#qwk-networks); call their hubs now | sysop | +| `GET /admin/pages`, `POST /admin/pages/{node}/answer` | the pages that wait. Answers one (node 0: the page that waited longest) | sysop | +| `POST /admin/users`, `PATCH /admin/users/{name}` | adds a user. Lock, unlock, make sysop, set password, `level`, `flags`, `qwk_node` | sysop | +| `POST /admin/areas`, `PATCH /admin/areas/{id}` | adds an area. Sets its newsgroup, echo tag, `read_require`, `post_require` | sysop | +| `POST /admin/nodes/{n}/kick` | disconnects a caller | sysop | +| `GET /admin/fido`, `POST /admin/fido/poll` | FidoNet links and outbound. Calls them now | sysop | +| `GET /admin/news`, `POST /admin/news/sync` | news peers. Syncs now | sysop | +| `GET /admin/qwknet`, `POST /admin/qwknet/call?net=` | [QWK networks](Offline-Mail#qwk-networks). Calls their hubs now | sysop | ```sh TOKEN=$(curl -s https://bbs.example.org:8443/api/v1/login \ @@ -154,51 +156,52 @@ curl -s -H "Authorization: Bearer $TOKEN" https://bbs.example.org:8443/api/v1/ar ## Streams and nodes -The event stream and each WebSocket take a node, just as a caller does -(`Via` is `web`). The node counts against `max_nodes`, shows in *Who's -online*, and receives the node's events: lines said in its chat room, -node messages, pages (for sysops), new mail and notices. The node ends -when the connection does. `POST /nodes/{n}/message`, `/page` and answering a -page are done from the token's open stream (409 without one). A page -that reaches no sysop is 503 (`unavailable`), as the WebSocket's Page -request answers it, and is not left waiting. +The event stream and each WebSocket take a node, as a caller does (`Via` +is `web`). The node counts against `max_nodes`, shows in *Who's online*, +and gets the events of the node: lines in its chat room, node messages, +pages (for sysops), new mail and notices. The node ends when the +connection ends. You must send `POST /nodes/{n}/message`, `/page` and +the answer to a page from the open stream of the token (409 without +one). A page that gets to no sysop gives 503 (`unavailable`), as the +Page request of the WebSocket answers it. The page does not wait. ### Server-sent events -`GET /api/v1/events` (with the `Authorization` header; a browser does -this with `fetch`, as `EventSource` cannot send headers) starts with -`event: welcome` (its node and user), then sends each event as +`GET /api/v1/events` (with the `Authorization` header. A browser does +this with `fetch`, because `EventSource` cannot send headers) starts +with `event: welcome` (its node and user). Then it sends each event as `event: said` (`emoted`, `joined`, `left`, `private`, `paged`, `notice`, -`mail`) with the event as JSON in `data:`, and a comment every 25 -seconds to keep it open. +`mail`), with the event as JSON in `data:`. It sends a comment every 25 +seconds to keep the connection open. ## WebSockets -Two endpoints speak the same protocol, `bbs.v1`, defined in +Two endpoints use the same protocol, `bbs.v1`, defined in [`proto/bbs.proto`](https://github.com/D-Modem/bbs/blob/HEAD/proto/bbs.proto): | Endpoint | Subprotocol | Frames | |---|---|---| -| `/api/v1/ws` | `bbs.v1.json` | text: protobuf's JSON mapping (lowerCamelCase fields, enums by name, RFC 3339 times) | +| `/api/v1/ws` | `bbs.v1.json` | text: the JSON mapping of protobuf (lowerCamelCase fields, enums by name, RFC 3339 times) | | `/api/v1/ws/proto` | `bbs.v1.proto` | binary: protobuf | -The client sends `ClientMessage`s with an `id` of its choosing; each is -answered by `ServerMessage`s with that `id`: `ok` (with `room` when the -client's room changed), `error` (`code` and `message`), or what was asked -for. Events and the welcome come with id 0. +The client sends `ClientMessage`s with an `id` that it selects. The +server answers each with `ServerMessage`s with that `id`: `ok` (with +`room` when the room of the client changed), `error` (`code` and +`message`), or the requested data. Events and the welcome come with id +0. -A browser cannot set headers on a WebSocket, so unless the upgrade had an -`Authorization` header the first message must be `auth`, within 10 -seconds. The token needs the `chat` scope. +A browser cannot set headers on a WebSocket. Thus, unless the upgrade +had an `Authorization` header, the first message must be `auth`, within +10 seconds. The token must have the `chat` scope. | Request | Answer | |---|---| | `auth {token}` | `welcome {bbs, user, node, scopes}` | -| `join {room}` | `lines` (the room's last lines), then `ok {room}` | +| `join {room}` | `lines` (the last lines of the room), then `ok {room}` | | `leave {}` | `ok` | -| `say {text, emote}` | `ok`; the room gets the line | +| `say {text, emote}` | `ok`. The room gets the line | | `nodeMessage {node, text}` | `ok` | -| `page {reason}` | `ok {room}`: the private room to wait in (the client is put in it) | +| `page {reason}` | `ok {room}`: the private room in which to wait (the server puts the client in it) | | `answer {node}` | sysops: `lines`, `ok {room}` | | `command {line}` | a line as typed in chat (`/who`, `/rooms`, `/msg`, `/join` ...): `lines`, `ok` | | `who {}` | `nodes {nodes: [{node, user, via, since, doing}]}` | @@ -220,7 +223,8 @@ A session in JSON (`>` from the client): ``` Clients of the protobuf endpoint generate code from `proto/bbs.proto` -(`protoc --go_out=...`, `--python_out=...` and so on). In JavaScript: +(`protoc --go_out=...`, `--python_out=...` and other options). In +JavaScript: ```js const ws = new WebSocket("wss://bbs.example.org:8443/api/v1/ws", "bbs.v1.json"); @@ -232,57 +236,66 @@ ws.onmessage = (m) => { }; ``` -The server pings every 30 seconds. Frames are at most 16 KB; a frame -that does not read is answered by an error, and the same limits as on a -terminal apply (200 characters a line, 8 lines in 10 seconds). +The server pings every 30 seconds. Frames have a maximum of 16 KB. The +server answers a frame that it cannot read with an error. The same limits +as on a terminal apply (200 characters for each line, 8 lines in 10 +seconds). ## The web terminal -`/terminal` (and `/`, which goes there when the [web forum](Web-Forum) is off) is the BBS in a browser: a page -with [xterm.js](https://xtermjs.org/) (5.5, MIT licensed, built into the -`bbs` binary: nothing is loaded from elsewhere) whose terminal is joined -to the text BBS by a WebSocket, `/terminal/ws`. The caller is a node like -a telnet caller (*Who's online* says `web terminal`) and logs in at the -BBS's own prompt, as on telnet: no token. They get ANSI colour and UTF-8 -(ANSI art's CP437 shown as Unicode), menus, messages, mail, chat, paging -and doors; not file transfers (download files by the API or FTP). Its -xterm.js has the image addon, so the [image boards](Image-Boards)' -pictures (sixel) show in it. +`/terminal` is the BBS in a browser. (`/` goes there when the +[web forum](Web-Forum) is disabled.) It is a page with +[xterm.js](https://xtermjs.org/) (5.5, MIT licensed, part of the `bbs` +binary: the page loads nothing from other locations). A WebSocket, +`/terminal/ws`, connects its terminal to the text BBS. The caller is a +node, as a telnet caller is (*Who's online* says `web terminal`). The +caller logs in at the prompt of the BBS, as on telnet: no token is +necessary. + +The caller gets ANSI colour and UTF-8 (the CP437 of ANSI art shows as +Unicode), menus, messages, mail, chat, paging and doors. The caller does +not get file transfers (download files by the API or FTP). Its xterm.js +has the image addon. Thus, the pictures (sixel) of the +[image boards](Image-Boards) show in it. | Path | What it serves | |---|---| | `GET /terminal` | the page | | `GET /terminal/xterm.js`, `addon-fit.js`, `addon-image.js`, `terminal.js`, `xterm.css`, `terminal.css`, `LICENSE.xterm` | its files | -| `GET /terminal/ws?cols=&rows=` | the WebSocket, subprotocol `bbs.terminal`: binary frames, the terminal's bytes both ways; the size the page fits its window to (40-255 columns, 10-200 rows), kept for the call | +| `GET /terminal/ws?cols=&rows=` | the WebSocket, subprotocol `bbs.terminal`: binary frames, the bytes of the terminal in the two directions. The size to which the page fits its window (40-255 columns, 10-200 rows), kept for the call | -The page allows scripts only from the BBS itself, cannot be framed, and +The page permits scripts only from the BBS, cannot be in a frame, and accepts WebSockets only from its own host (and the `cors` origin). -Connections count against `max_per_ip` and `rate`, and logins count -against the throttle as a terminal's do. Behind a proxy on 127.0.0.1 -without `trusted_proxies`, throttling is up to the proxy, because the BBS -sees every caller as the proxy. `terminal = no` turns the page off. +Connections count against `max_per_ip` and `rate`. Logins count against +the throttle, as the logins of a terminal do. Behind a proxy on +127.0.0.1 without `trusted_proxies`, the proxy must do the throttling, +because the BBS sees all callers as the proxy. `terminal = no` disables +the page. ## Metrics -With `metrics = 127.0.0.1:9100`, `/metrics` there has, in Prometheus's -text format: `bbs_nodes`, `bbs_nodes_by_via{via}`, `bbs_max_nodes`, -`bbs_users`, `bbs_messages`, `bbs_logins_total`, -`bbs_login_failures_total`, `bbs_posts_total`, `bbs_mail_total`, -`bbs_pages_total`, `bbs_chat_lines_total`, `bbs_pages_waiting` and -`bbs_fido_outbound_files{link}`. +With `metrics = 127.0.0.1:9100`, `/metrics` at that address has these +items, in the text format of Prometheus: `bbs_nodes`, +`bbs_nodes_by_via{via}`, `bbs_max_nodes`, `bbs_users`, `bbs_messages`, +`bbs_logins_total`, `bbs_login_failures_total`, `bbs_posts_total`, +`bbs_mail_total`, `bbs_pages_total`, `bbs_chat_lines_total`, +`bbs_pages_waiting` and `bbs_fido_outbound_files{link}`. ## Security -- TLS by default; tokens never go in URLs (only in the `Authorization` - header or a WebSocket's first message). -- Tokens are 32 random bytes; only their SHA-256 is stored. A wrong - token waits as a wrong password does, and failed logins are logged and - counted like a terminal's. -- Rate limits per token (per address without one), connections per - address, JSON bodies at most 64 KB with unknown fields refused, - uploads limited as on the BBS. -- No CORS unless one origin is named; WebSockets from origins other than - it and the API's own host are refused. Responses carry `nosniff` and `no-store`. -- What web clients say and post is cleaned as a terminal caller's is. +- TLS by default. Tokens never go in URLs (only in the `Authorization` + header or the first message of a WebSocket). +- Tokens are 32 random bytes. The BBS stores only their SHA-256. After + an incorrect token, the server waits as it does after an incorrect + password. The BBS logs and counts failed logins as for a terminal. +- Rate limits for each token (for each address without a token), + connections for each address, JSON bodies of a maximum of 64 KB with + unknown fields refused, and uploads with the same limits as on the + BBS. +- No CORS unless you name one origin. The server refuses WebSockets from + origins other than that origin and its own host. Responses have + `nosniff` and `no-store`. +- The BBS cleans the text that web clients send and post, as it cleans + the text of a terminal caller. **See also:** [Chat and paging](Chat-and-Paging), [Security](Security), [Configuration](Configuration)