diff --git a/CHANGELOG.md b/CHANGELOG.md index 0014aa18..a75d2f78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,20 @@ What changed in each version of Embed CMS, from 3.0.0 on, newest first. The vers ## [Unreleased] +## [3.2.0] - 2026-10-12 + +### Added + +- **A token field.** `input: 'token'` holds a key or a secret that two systems share. Type it, paste it, or make a random one with the **Generate** button, and copy it with **Copy**. `options.length` (random bytes), `options.prefix` and `options.format` (`base64url` or `hex`) shape what Generate makes, and `options.autoGenerate` gives a new record a token by itself, in the admin and over the API. See [token](docs/reference/fields/token.md). +- **The Token under This CMS in the Sync settings is a token field.** It has a Generate and a Copy button, so the secret no longer has to be invented by hand. + +### Changed + +- **Replication is live, and needs no port of its own.** A node keeps a link open to each peer it receives a resource from: the peer sends what the node lacks, then each change as it is written, and the link connects again by itself after an outage. Records go over a websocket on the HTTP port of the CMS, at `/_replicator` next to the REST API, so they travel over `wss://` when the CMS is served over HTTPS; files still go over the REST API. A node a peer connects to only sends, so a connecting peer can no longer write anything. With MongoDB or PostgreSQL, a node pulls again every `replication.pollInterval` (30 seconds). **To upgrade:** remove `netPort`, give each peer the `url` of its REST API, set `replication.secret` on every node, and list on each node the peers it receives from. `settleDelay` and `POST /replicator/sync/:resource/:id` are gone. See [REPLICATION.md](docs/operations/REPLICATION.md#moving-from-31-or-earlier). +- **The resources of the CMS stay out of the global peers list.** `_users`, `_groups`, `_settings`, `_sync` and `_xlsx` now replicate only when `replication.peersByResource` names them. Every node makes its own `admins` group and `localAdmin` on its first start, and a node that fetched another node's `admins` group could no longer update it, so its admin login stopped working. See [REPLICATION.md](docs/operations/REPLICATION.md#users-groups-and-settings). +- **The Replicator page shows the replication, live, and starts nothing.** For each resource that replicates, it shows the peers this node pulls it from, the state of each link (live, reconnecting with the error and the next try) and its last change, and the peers that pull it from here. The Sync all and Sync a record buttons are gone. The page moved from the System menu to the CMS menu, and is drawn with the plugin kit. +- **A record made on another node says so in the editor.** Its form showed "All changes saved" above fields that can't be edited. It now reads "Read-only, made on" and the `mid` of the node to edit it on. See [REPLICATION.md](docs/operations/REPLICATION.md#records-of-another-node). + ## [3.1.1] - 2026-10-11 ### Changed @@ -230,7 +244,8 @@ The release that turned node-cms into a project that stands on its own: the firs - The bugs the component tests found: a new record opens a blank editor again, a refused request is not logged as a server error, record names and labels after the mustache 4 update, a record whose id overlaps the machine id can be changed and removed, and `remove` and `update` throw instead of failing silently. - A delete goes to the replication peers right away again, `cms-import` prints no empty progress bars into logs, the xlsx import answers `400` without a file. -[Unreleased]: https://github.com/xiaodoudou/embed-cms/compare/v3.0.5...HEAD +[Unreleased]: https://github.com/xiaodoudou/embed-cms/compare/v3.2.0...HEAD +[3.2.0]: https://github.com/xiaodoudou/embed-cms/compare/v3.1.1...v3.2.0 [3.1.1]: https://github.com/xiaodoudou/embed-cms/compare/v3.1.0...v3.1.1 [3.1.0]: https://github.com/xiaodoudou/embed-cms/compare/v3.0.7...v3.1.0 [3.0.7]: https://github.com/xiaodoudou/embed-cms/compare/v3.0.6...v3.0.7 diff --git a/SECURITY.md b/SECURITY.md index 77710ee1..16a9a840 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -63,7 +63,7 @@ Each protection is one setting in the `security` block of `cms.json`. All of the | `limits.json` | `"100kb"` | Size of a JSON request body, on every route (REST, sync, import, the admin): it is the only JSON limit. A larger body answers `413` with a JSON message naming this setting. 100kb is what every route accepted before the option existed | | `limits.upload` | `{ fileSize: "256mb", files: 20, fields: 200, fieldSize: "1mb", parts: 260 }` | Limits of multipart uploads; a value given here replaces the matching default | | `restrictRemoteUrls` | `true` | `importFromRemote` only fetches attachments from the remote it imports from (and `allowedHosts` of its `remote` block) | -| `strictReplication` | `true` | The replication port needs `replication.secret`, peers may only ask for resources this node has, changes from a peer are validated | +| `strictReplication` | `true` | Peers may only ask for resources this node has, and each record a node pulls from a peer is validated before it is stored. The replication websocket always needs `replication.secret` | | `wsAuth` | `true` | The record update websocket needs a login and a same-origin (or listed) page | | `wsMaxPayload` | `16384` | Largest message a websocket client may send | | `authCacheTtl` | `60000` | Milliseconds a verified password stays verified in memory (Basic authentication runs the hash once per minute, not per request); `0` turns it off | @@ -75,13 +75,13 @@ Each protection is one setting in the `security` block of `cms.json`. All of the | `trustProxy` | not set | Passed to Express `trust proxy`: `req.ip`, `req.secure` and the login lockout follow the proxy chain. Set it to the number of proxies in front of the CMS; without it the address of the TCP peer is used | | `imageConcurrency` | number of cores | Image operations (resize, crop, smart crop) that run at once; the others wait. `0` means no limit. At most 100 may wait, the next request gets 503 | | `attachmentCleanupGrace` | `300000` | Milliseconds a file must have been idle before `cleanAttachment` may remove it as an orphan | -| `replication.secret` | not set | Shared secret of the replication port. Both sides prove they know it with an HMAC-SHA256 challenge before any resource is named | -| `replication.strictTypes` | `false` | Read the type (`normal`, `upstream`, `downstream`) of a resource from its options, so the direction rules of `replication.peers` apply. Off, every resource counts as `normal`, as in earlier releases | -| `replication.settleDelay` | `2000` | Milliseconds `replicate()` waits for a peer to flush before it syncs attachments | +| `replication.secret` | not set | Shared secret of the replication websocket (`/_replicator` on the HTTP port). Both sides prove they know it with an HMAC-SHA256 challenge before any resource is named; without it the node doesn't listen for peers | +| `replication.strictTypes` | `false` | Read the type (`normal`, `upstream`, `downstream`) of a resource from its options, so the `direction` of each peer is checked against it. Off, every peer is used for every resource | +| `replication.pollInterval` | `30000` | Milliseconds between two pulls from a peer whose store can't keep a link open (MongoDB, PostgreSQL) | | `replication.maxRecordBytes` | `4194304` | Largest record accepted from a peer with `strictReplication` | | `importFromRemote.remote.restrictUrls` / `.allowedHosts` | `false` / `[]` | Per remote, in addition to `restrictRemoteUrls` | -`replication.strictTypes` is worth a word. The replication manager reads the type of a resource from its options. Off, every resource counts as `normal` and the `direction` of a peer never matters. With the option on, a `downstream` resource (`_users`, `_groups`, `_settings` and the resources you declared so) is only synced with peers whose `direction` is `upstream` or `normal`, and an `upstream` resource with peers of direction `downstream` or `normal`. A peer without `direction` then stops syncing typed resources. Give every peer a direction before turning it on. +`replication.strictTypes` is worth a word. A node pulls each resource from the peers it lists, except a resource of type `upstream`, which it only sends. Off, a node opens a link to every peer it lists. With the option on, it opens links only to peers whose `direction` is `upstream` or `normal`, the peers it takes from; a peer without `direction` then gets no link. Give every peer a direction before turning it on. A peer that connects to a node can pull from it but never writes to it, with or without the option. [REPLICATION.md](docs/operations/REPLICATION.md#directions) explains the types and the directions. ### Always on @@ -157,7 +157,7 @@ The values that depend on your setup: - `trustProxy` is the number of reverse proxies in front of the CMS; change `1` to the real number. - `allowedOrigins` takes the origin of the admin app when it is served from another host than the API. - `limits.json` is `"100kb"`, the size of the largest JSON body (a record, an import); raise it when a record is bigger. -- `replication.strictTypes` is on, so every peer needs a `direction`, or it stops syncing `_users`, `_groups` and `_settings`. +- `replication.strictTypes` is on, so every peer needs a `direction`, or it syncs `normal` resources only. - `localAdmin` is off. A `localAdmin` record that already exists stays, and every boot logs an error while it has its default password: change that password or delete the account. - `safeAttachments` and `strictUploads` are on. Turning `safeAttachments` off displays HTML and SVG attachments inline, with the privileges of the site for whoever opens them. Turning `strictUploads` off removes the file name sanitising, the content-based type and the upload limits. @@ -176,7 +176,7 @@ Run with `NODE_ENV=production`, then check: 3. Password hashes. Leave `passwordHash` on `scrypt`. If nodes replicate `_users`, upgrade every node first: a node that runs an earlier release cannot verify an scrypt hash. 4. Proxy. Behind a reverse proxy, set `trustProxy` to the number of proxies, forward `X-Forwarded-Proto`, and serve the admin app over https (cookies get `Secure`, HSTS is sent). 5. CSRF and origins. If the admin app is served from another origin than the API, list it in `allowedOrigins`. -6. Replication. Set the same `replication.secret` on every node, firewall the replication port to the peers, and set a `direction` on every peer before turning on `replication.strictTypes`. +6. Replication. Set the same `replication.secret` on every node, serve the CMS over HTTPS so peers replicate over `wss://`, and set a `direction` on every peer before turning on `replication.strictTypes`. 7. Uploads. Tune `limits.upload` to what your editors need. Do not add `text/html` or `image/svg+xml` to `inlineTypes` unless you trust everyone who can upload. 8. Configuration. `cms.json` is not editable from the admin: nothing on the web can read or rewrite the secrets. 9. Logs. `/api/_syslog` shows the log to every user who can log in: keep secrets out of log lines (the backend does not write passwords or tokens) and give the `plugins` right of the group only to administrators. The log page and the log file are bounded by `syslog.maxLineLength`, `syslog.maxFileSize` and `syslog.maxClientBuffer`. @@ -185,7 +185,7 @@ Run with `NODE_ENV=production`, then check: ## Not covered - The frontend (`src/`) was not changed by this work. Its own protections (DOMPurify) are separate. -- Transport encryption of the replication port: the shared secret authenticates the peers, it does not encrypt what they exchange. Run the replication port on a private network or through a tunnel. +- Transport encryption of the replication: the shared secret authenticates the peers, it does not encrypt what they exchange. Serve the CMS over HTTPS (peers then use `wss://`), or keep the nodes on a private network or a tunnel. - MongoDB and PostgreSQL servers are configured by their operators; the CMS only guarantees the queries it sends. - Regular expressions are checked, not sandboxed: a pattern that passes the check can still be slow on a very long text field. If that matters to you, keep `limits.json` small and consider a regular expression engine with a linear time guarantee in front of the query filter. @@ -206,7 +206,7 @@ Options added, with defaults (see the tables above): - `strongSecrets`, `generateSecrets`, `localAdmin`, `passwordHash`, `hideCredentials`, `genericLockout`, `csrf`, `allowedOrigins`, `cookies`, `strictSessions`, `redactConfig`, `strictAdmin`, `headers`, `contentSecurityPolicy`, `sseCors`, `safeRegex`, `uniformErrors`, `safeAttachments`, `inlineTypes`, `strictUploads`, `restrictRemoteUrls`, `strictReplication`, `wsAuth`, `wsMaxPayload`, `authCacheTtl`, `limits.json`, `limits.upload` - top level: `trustProxy`, `imageConcurrency`, `attachmentCleanupGrace`; `blockRetry: false` turns the lockout off -- `replication.secret`, `replication.strictTypes`, `replication.settleDelay`, `replication.maxRecordBytes` +- `replication.secret`, `replication.strictTypes`, `replication.pollInterval`, `replication.maxRecordBytes` - `importFromRemote.remote.restrictUrls`, `importFromRemote.remote.allowedHosts` Files written by the backend: `/.secrets.json` (only with `generateSecrets`), `/.revoked-tokens.json`, `//json/db.json.corrupt-