badmfck-api-server 6.0.12 → 6.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +103 -0
- package/README.md +213 -73
- package/dist/apiServer/APIService.d.ts +3 -1
- package/dist/apiServer/APIService.js +25 -1
- package/dist/apiServer/LogService.d.ts +2 -0
- package/dist/apiServer/LogService.js +10 -8
- package/dist/apiServer/MonitorService.d.ts +4 -1
- package/dist/apiServer/MonitorService.js +28 -5
- package/dist/apiServer/deployment/Bundler.d.ts +12 -0
- package/dist/apiServer/deployment/Bundler.js +178 -0
- package/dist/apiServer/deployment/ConfigService.d.ts +7 -0
- package/dist/apiServer/deployment/ConfigService.js +24 -1
- package/dist/apiServer/deployment/Deploy.js +96 -54
- package/dist/apiServer/deployment/DeployKeyWizard.d.ts +1 -0
- package/dist/apiServer/deployment/DeployKeyWizard.js +17 -1
- package/dist/apiServer/deployment/DeployerService.d.ts +4 -1
- package/dist/apiServer/deployment/DeployerService.js +87 -18
- package/dist/apiServer/deployment/HashPassword.js +2 -2
- package/dist/apiServer/deployment/MigrateConfigsWizard.js +9 -5
- package/dist/apiServer/deployment/ProjectConfigWizard.js +4 -2
- package/dist/apiServer/deployment/Restore.js +5 -5
- package/dist/apiServer/deployment/SecretsInjector.js +2 -1
- package/dist/apiServer/deployment/SetupConfigWizard.js +1 -1
- package/dist/apiServer/deployment/Status.js +1 -1
- package/dist/apiServer/deployment/Watchdog.js +1 -1
- package/dist/apiServer/deployment/Wizards.js +11 -11
- package/dist/apiServer/deployment/cli.js +25 -16
- package/dist/apiServer/deployment/cliCommon.d.ts +12 -0
- package/dist/apiServer/deployment/cliCommon.js +44 -0
- package/dist/apiServer/deployment/resolveConfig.d.ts +2 -0
- package/dist/apiServer/deployment/resolveConfig.js +10 -0
- package/dist/apiServer/external/MicroserviceClient.d.ts +7 -2
- package/dist/apiServer/external/MicroserviceClient.js +90 -10
- package/dist/apiServer/external/MicroserviceHost.d.ts +36 -8
- package/dist/apiServer/external/MicroserviceHost.js +166 -55
- package/dist/apiServer/helper/AppDataPath.d.ts +9 -0
- package/dist/apiServer/helper/AppDataPath.js +81 -0
- package/dist/apiServer/helper/ClientIp.d.ts +1 -0
- package/dist/apiServer/helper/ClientIp.js +5 -0
- package/dist/apiServer/helper/Trace.d.ts +8 -0
- package/dist/apiServer/helper/Trace.js +30 -0
- package/dist/apiServer/helper/Validator.d.ts +1 -0
- package/dist/apiServer/helper/Validator.js +21 -18
- package/dist/apiServer/http/Http.d.ts +1 -0
- package/dist/apiServer/http/Http.js +5 -2
- package/dist/apiServer/interceptors/InterceptorSignedAuth.d.ts +2 -1
- package/dist/apiServer/interceptors/InterceptorSignedAuth.js +1 -1
- package/dist/apiServer/monitor/MonitorAuth.js +8 -5
- package/dist/apiServer/monitor/ThreatMonitor.d.ts +8 -0
- package/dist/apiServer/monitor/ThreatMonitor.js +87 -1
- package/dist/apiServer/monitor/index.html +66 -66
- package/dist/apiServer/security/BlockedIps.js +10 -14
- package/dist/apiServer/structures/Interfaces.d.ts +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/package.json +21 -6
- package/bluegreen.help.md +0 -392
- package/cocroach.help.md +0 -191
- package/connections.help.md +0 -0
- package/monitoring.help.md +0 -350
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 6.0.14 — 2026-11-19
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- **Microservice callers limited by address.** `allowedIps` per caller in the host's `clients` (IPs and
|
|
8
|
+
subnets, IPv4/IPv6): a leaked key is useless from anywhere else. A call from another address gets 403
|
|
9
|
+
before its signature is checked, and the host logs the key id and address. Behind nginx the address
|
|
10
|
+
is `X-Real-IP`, believed only from `trustedProxies` (loopback by default). Without `allowedIps` any
|
|
11
|
+
address is accepted, as before; a malformed or empty list stops the host at startup.
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- **Deployer log flooded with "ignored" errors** (since 6.0.13). The project-name check also ran on
|
|
16
|
+
the deployer's own `<project>_state_.json` files and on `setup.json` when `setup_path` is the projects
|
|
17
|
+
folder, and logged an error for each at every rescan (once a minute). Files without `name` are now
|
|
18
|
+
skipped silently, and a config with a bad name is reported once, not every minute.
|
|
19
|
+
|
|
20
|
+
## 6.0.13 — 2026-11-19
|
|
21
|
+
|
|
22
|
+
### Before you upgrade
|
|
23
|
+
|
|
24
|
+
These change behaviour. Check each against your project.
|
|
25
|
+
|
|
26
|
+
- **Outgoing HTTP is no longer retried by default.** `Http` used to retry failed requests on its own,
|
|
27
|
+
which could send a payment twice. Retries are now off unless a call asks for them:
|
|
28
|
+
`{ retry: { enabled: true } }`. Multipart requests are never retried.
|
|
29
|
+
- **Validation bounds that were ignored are now enforced.** Two bugs are fixed:
|
|
30
|
+
- Bounds given as separate keys — `$__limit_min: 10`, `$__limit_max: 100` — were never applied.
|
|
31
|
+
They now are.
|
|
32
|
+
- A bound of `0` was treated as "no bound": `$__n: { min: 0 }` let `-1` through. It no longer does.
|
|
33
|
+
|
|
34
|
+
Requests that passed before can now get a 400. Review every `$__*_min`, `$__*_max` and `min: 0` /
|
|
35
|
+
`max: 0` in your models before upgrading.
|
|
36
|
+
- **Every response carries a trace id**: the `X-Request-Id` header and `traceId` in the JSON envelope.
|
|
37
|
+
Clients that compare the whole response body need to allow the new field.
|
|
38
|
+
- **Data now lives in `/var/bmfk/<project>/`** (see the README, "Data folder"): metrics history,
|
|
39
|
+
threats, blocked IPs, monitor 2FA enrollments and deployer secrets. Create the root once on each
|
|
40
|
+
server: `sudo mkdir /var/bmfk && sudo chown <app user> /var/bmfk`. Without it the app falls back to
|
|
41
|
+
a folder beside the code and says so at startup. Explicit settings (`metricsDir`, `blockedIps.file`,
|
|
42
|
+
`monitorAuthDir`, `secrets_dir`) still win, and a `blocked-ips` file at the old place keeps being used.
|
|
43
|
+
- **The deployer renames the deployed app.** On every deploy it writes its project name into the
|
|
44
|
+
deployed `package.json` and `package-lock.json` `"name"`. Your repository is not changed. If your code
|
|
45
|
+
reads `package.json` `"name"` at runtime, it now gets the deployer's project name.
|
|
46
|
+
- **Project names are validated.** A project config whose `name` is not lowercase letters, digits,
|
|
47
|
+
`.`, `_` and `-` (starting with a letter or digit, up to 100 characters) is ignored by the deployer,
|
|
48
|
+
with an error in its log. Run `npx bmfk migrate-configs` to list such configs before upgrading the
|
|
49
|
+
deployer.
|
|
50
|
+
- **`bundle` needs its tools installed in the project**: `npm i -D esbuild @babel/parser`. They are no
|
|
51
|
+
longer dependencies of the library (see Dependencies).
|
|
52
|
+
|
|
53
|
+
### Added
|
|
54
|
+
|
|
55
|
+
- **Signed microservice calls.** Each service has its own Ed25519 key pair (`npx bmfk ms-key`). The
|
|
56
|
+
caller signs every request, and the host signs every answer, bound to that request. Hosts list their
|
|
57
|
+
callers in `clients` with an allow-list of `requests`. An operation id (`op`) is kept across retries,
|
|
58
|
+
so the host runs an operation once, and reusing an `op` for a different request is refused.
|
|
59
|
+
`MicroserviceHost.currentCall()` tells a handler who is calling. Signed calls go over https only
|
|
60
|
+
(plain http only to localhost), and errors are returned without stack traces.
|
|
61
|
+
- **Request tracing.** Every request gets a trace id. It is in the response, in `req.traceId`, in every
|
|
62
|
+
log line written while handling the request, in the incoming and outgoing request logs, and in signed
|
|
63
|
+
microservice calls, where the host takes over the caller's id. An incoming `X-Request-Id` is accepted
|
|
64
|
+
only from a trusted proxy. `Trace` is exported.
|
|
65
|
+
- **Monitor: trace ids.** The Log, Net log and Outgoing journals have a TRACE column and search by
|
|
66
|
+
trace id. The detail view links to the same trace in the other journals. Monitor UI 1.0.30.
|
|
67
|
+
- **Metrics history survives restarts and deploys**, on by default. Only the live process writes it:
|
|
68
|
+
a blue-green standby and pm2 workers other than instance 0 keep counting in memory only. A slot that
|
|
69
|
+
becomes live first loads what the other slot wrote. `metricsDir: false` keeps metrics in memory.
|
|
70
|
+
- **Threats survive restarts and deploys**: `/var/bmfk/<project>/threats.json`, saved every minute and
|
|
71
|
+
on shutdown, by the live process only. It holds addresses, user agents and URLs, never request bodies.
|
|
72
|
+
- **`omitDev` in a project config**: install with `npm ci --omit=dev`, so devDependencies never reach
|
|
73
|
+
the server. Off by default. Check first that `npm start` and `npm run migrate` need nothing from
|
|
74
|
+
devDependencies.
|
|
75
|
+
- **`bmfk` CLI.** The command is now `bmfk`. `badmfck` still works, so existing scripts need no change.
|
|
76
|
+
- **Clearer deploy output**: one line per step with its duration, and the build's own output shown
|
|
77
|
+
only when the build fails.
|
|
78
|
+
- **Test suite**: `npm test` (node:test), 81 tests.
|
|
79
|
+
|
|
80
|
+
### Changed
|
|
81
|
+
|
|
82
|
+
- `resultModel` on an endpoint is documented as what it is: documentation only. It does not validate
|
|
83
|
+
or filter the response.
|
|
84
|
+
- Deployer health checks (liveness, readiness) keep retrying explicitly, since `Http` no longer does it
|
|
85
|
+
by default.
|
|
86
|
+
|
|
87
|
+
### Fixed
|
|
88
|
+
|
|
89
|
+
- Validation: `$__X_min` / `$__X_max` were never applied, and a bound of 0 was ignored (see above).
|
|
90
|
+
- v1 microservice calls: the payload is decrypted before the replay-cache lookup.
|
|
91
|
+
|
|
92
|
+
### Deprecated
|
|
93
|
+
|
|
94
|
+
- Microservice `securityKey` (v1, shared AES key): still accepted while services move to signed calls.
|
|
95
|
+
It will be removed.
|
|
96
|
+
- Microservice `password`: never used. Remove it from configs.
|
|
97
|
+
|
|
98
|
+
### Dependencies
|
|
99
|
+
|
|
100
|
+
- `npm audit`: 0 vulnerabilities. `undici` ^7.30.2.
|
|
101
|
+
- `esbuild` and `@babel/parser` are optional peer dependencies now, loaded only by `bundle`. Before,
|
|
102
|
+
every project and every server installed them, esbuild with a platform binary of about 10 MB.
|
|
103
|
+
- `@types/mysql` removed.
|
package/README.md
CHANGED
|
@@ -21,17 +21,18 @@ Node.js 21+ is required.
|
|
|
21
21
|
4. [Interceptors (authentication)](#interceptors-authentication)
|
|
22
22
|
5. [API documentation](#api-documentation)
|
|
23
23
|
6. [Outgoing HTTP client](#outgoing-http-client)
|
|
24
|
-
7. [
|
|
25
|
-
8. [
|
|
26
|
-
9. [
|
|
27
|
-
10. [
|
|
28
|
-
11. [
|
|
29
|
-
12. [
|
|
30
|
-
13. [
|
|
31
|
-
14. [
|
|
32
|
-
15. [
|
|
33
|
-
16. [
|
|
34
|
-
17. [
|
|
24
|
+
7. [Microservice calls](#microservice-calls)
|
|
25
|
+
8. [Logging and redaction](#logging-and-redaction)
|
|
26
|
+
9. [Monitor console (`sm/*`)](#monitor-console-sm)
|
|
27
|
+
10. [IP blocking](#ip-blocking)
|
|
28
|
+
11. [Authentication](#authentication)
|
|
29
|
+
12. [WebSocket server](#websocket-server)
|
|
30
|
+
13. [Deployer and CLI](#deployer-and-cli)
|
|
31
|
+
14. [Blue-green deployments](#blue-green-deployments)
|
|
32
|
+
15. [Backups and restore](#backups-and-restore)
|
|
33
|
+
16. [Deploy review](#deploy-review)
|
|
34
|
+
17. [Options reference](#options-reference)
|
|
35
|
+
18. [Security](#security)
|
|
35
36
|
|
|
36
37
|
---
|
|
37
38
|
|
|
@@ -57,7 +58,7 @@ Every response has the same envelope:
|
|
|
57
58
|
|
|
58
59
|
```jsonc
|
|
59
60
|
// success
|
|
60
|
-
{ "data": { … }, "responseTime": 4, "endpoint": "/api/v1/users/get", "version": "1.2.0" }
|
|
61
|
+
{ "data": { … }, "responseTime": 4, "endpoint": "/api/v1/users/get", "version": "1.2.0", "traceId": "…" }
|
|
61
62
|
// error
|
|
62
63
|
{ "error": { "code": 401, "message": "Unauthorized", "httpStatus": 401, "details": "…" } }
|
|
63
64
|
```
|
|
@@ -111,7 +112,8 @@ Per-endpoint flags:
|
|
|
111
112
|
|---|---|
|
|
112
113
|
| `ignoreInterceptor` | skip authentication for this endpoint |
|
|
113
114
|
| `allowInterceptorError` | run the handler even if the interceptor rejected the request |
|
|
114
|
-
| `validationModel`
|
|
115
|
+
| `validationModel` | validate the request |
|
|
116
|
+
| `resultModel` | describe the response in the API documentation (not checked at runtime) |
|
|
115
117
|
| `asStream` | stream the response |
|
|
116
118
|
| `ignoreInDocumentation` | hide from `doc/*` |
|
|
117
119
|
| `ignoreHttpLogging` | keep out of the request log (polling endpoints, secrets) |
|
|
@@ -233,12 +235,71 @@ if (!res.ok) {
|
|
|
233
235
|
}
|
|
234
236
|
```
|
|
235
237
|
|
|
236
|
-
`Http` never throws for HTTP or network errors: you always get `{ ok, status, data, error }`.
|
|
237
|
-
|
|
238
|
+
`Http` never throws for HTTP or network errors: you always get `{ ok, status, data, error }`.
|
|
239
|
+
|
|
240
|
+
Requests are **not retried** unless you ask for it: a `504` or a dropped connection doesn't mean the other side
|
|
241
|
+
did nothing, and a retried payment is a double charge. `retry: { enabled: true }` retries once on network
|
|
242
|
+
errors and on `429`, `502`, `503`, `504`; tune it with `maxAttempts` and `retryOnStatuses`. Multipart uploads
|
|
243
|
+
are never retried. The default timeout is 5 seconds.
|
|
244
|
+
|
|
245
|
+
It uses connection pooling (undici), and every call is recorded for the monitor: an outgoing request log (redacted),
|
|
238
246
|
active connections per host and latency percentiles (p50, p95, p99) per host.
|
|
239
247
|
|
|
240
248
|
---
|
|
241
249
|
|
|
250
|
+
## Microservice calls
|
|
251
|
+
|
|
252
|
+
One service (the host) exposes `Req` handlers; others (callers) call them by name. Every service has its own
|
|
253
|
+
Ed25519 key pair — `npx bmfk ms-key` prints one. There is no shared secret: the caller signs each request,
|
|
254
|
+
the host signs each answer, and each side holds only the other's public key.
|
|
255
|
+
|
|
256
|
+
```ts
|
|
257
|
+
// host
|
|
258
|
+
new MicroserviceHost({
|
|
259
|
+
id: "crm",
|
|
260
|
+
requests: [REQ_FEES_ACTUAL, REQ_MERCHANT_ACTUAL],
|
|
261
|
+
privateKey: secrets.CRM_MS_KEY, // the host's private key: signs its answers
|
|
262
|
+
clients: {
|
|
263
|
+
gate: { publicKey: "MCowBQYDK2VwAyEA…", allowedIps: ["127.0.0.1", "::1"] }, // everything in `requests`, from this server only
|
|
264
|
+
reports: { publicKey: "MCowBQYDK2VwAyEA…", requests: ["REQ_FEES_ACTUAL"], allowedIps: ["10.8.0.0/24"] },
|
|
265
|
+
},
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
// caller
|
|
269
|
+
new MicroserviceClient({
|
|
270
|
+
id: "crm",
|
|
271
|
+
host: "https://crm.example.com/api", // https; plain http only to localhost
|
|
272
|
+
kid: "gate", // this caller's name in the host's `clients`
|
|
273
|
+
privateKey: secrets.GATE_MS_KEY,
|
|
274
|
+
hostPublicKey: "MCowBQYDK2VwAyEA…", // every answer is checked against it
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
const fees = await REQ_MICROSERVICE_CALL.request({ id: "crm", requestName: "REQ_FEES_ACTUAL", requestData: { mid } });
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
- **Who may call what.** The host knows each caller by its key id and refuses requests outside that caller's
|
|
281
|
+
`requests` list. A request can't be replayed, changed on the way, or redirected to another host.
|
|
282
|
+
- **From where.** `allowedIps` (IPs and subnets, IPv4/IPv6) limits where a caller's key works, so a leaked key
|
|
283
|
+
is useless anywhere else. A call from another address gets `403` before its signature is even checked, and
|
|
284
|
+
the host logs the key id and address. The address is the real client's: behind nginx it is `X-Real-IP`
|
|
285
|
+
(`proxy_set_header X-Real-IP $remote_addr;`), believed only from `trustedProxies` (loopback by default);
|
|
286
|
+
otherwise the TCP peer. List both `127.0.0.1` and `::1` for a caller on the same server — `localhost` can
|
|
287
|
+
resolve to either. Without `allowedIps` any address is accepted; a malformed or empty list stops the host.
|
|
288
|
+
- **Operations run once.** Each call carries an operation id (`op`) that stays the same across retries: the
|
|
289
|
+
host runs it once and answers repeats from its job store. Pass your own `op` (a payment or transfer id) to
|
|
290
|
+
make it stable beyond this process. The default store is memory, so a restart forgets it: a handler that
|
|
291
|
+
moves money must also record `op` in its own database, in the same transaction as the effect —
|
|
292
|
+
`MicroserviceHost.currentCall()` gives the handler the caller and the `op`. An `op` reused for a different
|
|
293
|
+
request is refused (`CONFLICT`).
|
|
294
|
+
- **Errors.** A handler's `IError` goes back without its `stack`; an unexpected exception is logged on the host
|
|
295
|
+
and the caller gets a bare `INTERNAL_ERROR`.
|
|
296
|
+
- **Confidentiality is TLS.** Signatures prove who sent what; they don't hide it.
|
|
297
|
+
|
|
298
|
+
The old mode with a shared `securityKey` is still accepted, so callers can move one by one. `password`
|
|
299
|
+
was never used: remove it from configs.
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
242
303
|
## Logging and redaction
|
|
243
304
|
|
|
244
305
|
```ts
|
|
@@ -261,6 +322,20 @@ The incoming and outgoing request logs shown in the monitor go through the same
|
|
|
261
322
|
> Redaction is a safety net, not a policy. Don't log card data on purpose: masking patterns can't
|
|
262
323
|
> recognize every format.
|
|
263
324
|
|
|
325
|
+
### Request tracing
|
|
326
|
+
|
|
327
|
+
Every request gets a trace id. It is returned in the `X-Request-Id` response header and as `traceId` in the
|
|
328
|
+
response body, and it follows everything the request causes:
|
|
329
|
+
|
|
330
|
+
- `req.traceId` in the handler, and `Trace.current()` anywhere in code the request runs, across `await`s;
|
|
331
|
+
- `traceId` on every log item written while handling it (pass it on in your `output`);
|
|
332
|
+
- the incoming request log and the outgoing HTTP log in the monitor;
|
|
333
|
+
- signed microservice calls: the host takes over the caller's id, so one operation has one id across services.
|
|
334
|
+
|
|
335
|
+
Behind nginx, `proxy_set_header X-Request-Id $request_id;` makes the service use nginx's id, so the nginx access
|
|
336
|
+
log and the service logs share it. The header is accepted only from `trustedProxies`; from anyone else it is
|
|
337
|
+
ignored, so a client can't plant an id that collides with someone else's records.
|
|
338
|
+
|
|
264
339
|
---
|
|
265
340
|
|
|
266
341
|
## Monitor console (`sm/*`)
|
|
@@ -272,8 +347,8 @@ A web console for operations: `<baseEndPoint>sm/html`, plus a JSON API used by t
|
|
|
272
347
|
- Process: memory, event-loop delay, open file descriptors and sockets with history (to catch leaks),
|
|
273
348
|
and pm2 identity.
|
|
274
349
|
- System: CPU, RAM, disks, network and load.
|
|
275
|
-
- Metrics: request rate, errors and latency, by hour, day or week
|
|
276
|
-
|
|
350
|
+
- Metrics: request rate, errors and latency, by hour, day or week; 10 weeks of history kept on disk
|
|
351
|
+
(see [Data folder](#data-folder)).
|
|
277
352
|
- Outgoing HTTP: per-host p50/p95/p99 and active connections.
|
|
278
353
|
- Logs: the application log, incoming and outgoing request logs, and tails of pm2 and nginx log files.
|
|
279
354
|
- Threats: clients that look like they are probing (scanners, `/wp-login.php`, `../`, bursts of 404s).
|
|
@@ -294,7 +369,7 @@ access: {
|
|
|
294
369
|
monitorAuthDir: "/var/lib/my-service", // where 2FA enrollments are kept
|
|
295
370
|
```
|
|
296
371
|
|
|
297
|
-
- **Passwords must be stored as hashes.** Generate one with `npx
|
|
372
|
+
- **Passwords must be stored as hashes.** Generate one with `npx bmfk hash-password`. The command
|
|
298
373
|
asks for the password interactively and prints the config entry. A plain-text password in the config
|
|
299
374
|
is refused.
|
|
300
375
|
- **2FA (TOTP) is mandatory.** At first login the console shows a QR code to scan with any
|
|
@@ -311,7 +386,7 @@ monitorAuthDir: "/var/lib/my-service", // where 2FA enrollments are kept
|
|
|
311
386
|
- **Sessions** expire after 15 minutes idle and 8 hours at most. 10 failed logins lock the account
|
|
312
387
|
for 30 minutes.
|
|
313
388
|
- **Change access without a restart.** Instead of an inline object, `access` can be a path to a JSON
|
|
314
|
-
file with the same shape: `access: "/etc/my-service/access.json"`. `npx
|
|
389
|
+
file with the same shape: `access: "/etc/my-service/access.json"`. `npx bmfk access-config` creates
|
|
315
390
|
and edits this file from a menu. Run in the project folder, it finds the path the code assigns to
|
|
316
391
|
`access` (a string literal in `src/` or the compiled `bin/`/`dist/`), or takes it as an argument. Passwords are typed hidden and stored as hashes, and the result is
|
|
317
392
|
checked with the service's own validator. The file is watched, and changes apply
|
|
@@ -341,8 +416,8 @@ monitorAuthDir: "/var/lib/my-service", // where 2FA enrollments are kept
|
|
|
341
416
|
otherwise every request appears to come from `127.0.0.1`.
|
|
342
417
|
- **Block addresses.** Admins can block an address or a subnet from the threats page, permanently or
|
|
343
418
|
for a number of hours. See [IP blocking](#ip-blocking).
|
|
344
|
-
- **
|
|
345
|
-
everyone has to enroll again.
|
|
419
|
+
- **If you set `monitorAuthDir`, keep it outside the deploy folders.** Otherwise a deploy wipes the
|
|
420
|
+
enrollments and everyone has to enroll again. By default they are in `/var/bmfk/<project>/`.
|
|
346
421
|
|
|
347
422
|
---
|
|
348
423
|
|
|
@@ -356,13 +431,10 @@ documentation:
|
|
|
356
431
|
```
|
|
357
432
|
|
|
358
433
|
The check runs first, before body parsing, CORS and the interceptor, so a blocked client costs almost
|
|
359
|
-
nothing. The list is
|
|
360
|
-
never touch it. It is re-read
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|---|---|---|
|
|
364
|
-
| regular | `/var/node/app/…` | `/var/node/blocked-ips.app.json` (named after the project folder) |
|
|
365
|
-
| blue-green | `/var/node/app/blue/…` | `/var/node/app/blocked-ips.json` (shared by both slots) |
|
|
434
|
+
nothing. The list is `/var/bmfk/<project>/blocked-ips.json` (see [Data folder](#data-folder)), outside
|
|
435
|
+
the code, so deploys and restores never touch it, and shared by both blue-green slots. It is re-read
|
|
436
|
+
on change. A list already at the old place beside the code (`/var/node/blocked-ips.app.json`, or
|
|
437
|
+
`/var/node/app/blocked-ips.json` for blue-green) keeps being used until you move it.
|
|
366
438
|
|
|
367
439
|
The format:
|
|
368
440
|
|
|
@@ -410,7 +482,7 @@ Monitor and deployer configs store a salted scrypt hash, never the password itse
|
|
|
410
482
|
command on any machine with the package installed:
|
|
411
483
|
|
|
412
484
|
```text
|
|
413
|
-
$ npx
|
|
485
|
+
$ npx bmfk hash-password
|
|
414
486
|
|
|
415
487
|
Hash a monitor password (APIService access.monitor)
|
|
416
488
|
Login: ops
|
|
@@ -422,7 +494,7 @@ Repeat password:
|
|
|
422
494
|
{ "login": "ops", "password": "scrypt$16384$8$1$Rkps…$zrwU…" }
|
|
423
495
|
```
|
|
424
496
|
|
|
425
|
-
- **Deployer users.** For a user in the deployer's `setup.json`, use `npx
|
|
497
|
+
- **Deployer users.** For a user in the deployer's `setup.json`, use `npx bmfk hash-password --deployer`.
|
|
426
498
|
The hash differs from a monitor hash, so they can't be swapped.
|
|
427
499
|
- **Interactive only.** The password is never accepted as an argument, so it doesn't end up in shell
|
|
428
500
|
history or `ps`. Without a terminal (in CI, for example), the command refuses to run.
|
|
@@ -509,7 +581,8 @@ Authorization: Bearer <token>
|
|
|
509
581
|
Re-enrolling through the API is impossible on purpose. Otherwise anyone who learned the password
|
|
510
582
|
could attach their own authenticator. To reset:
|
|
511
583
|
|
|
512
|
-
1. Open
|
|
584
|
+
1. Open `/var/bmfk/<project>/monitor-2fa.json` on the server (with `monitorAuthDir` set:
|
|
585
|
+
`<monitorAuthDir>/monitor-2fa.<projectName>.json`).
|
|
513
586
|
2. Delete the user's entry under `projects.<projectName>.users.<login>`.
|
|
514
587
|
|
|
515
588
|
No restart is needed. The file is watched like `access.json`: within a second the user's sessions
|
|
@@ -544,9 +617,9 @@ documentation users their own passwords, never ones they use elsewhere.
|
|
|
544
617
|
signature is good for one request and five minutes, and covers the project, the fields and the
|
|
545
618
|
archive. With a password, `Authorization: Bearer sha256(login:password)` and `X-Deployer-Login`.
|
|
546
619
|
- **Project token.** Deploying, switching and restoring also require the project's own `token`. The
|
|
547
|
-
project config on the server holds only its hash. Run `npx
|
|
620
|
+
project config on the server holds only its hash. Run `npx bmfk project-token`: it prints a new
|
|
548
621
|
random token for `deploy.json` and its hash for the project config. To keep an existing token, run
|
|
549
|
-
`npx
|
|
622
|
+
`npx bmfk project-token --hash`. A token stored in plain text is refused like a wrong token. The
|
|
550
623
|
server log says why, and a startup error names the affected projects.
|
|
551
624
|
- **CLI version.** Users stored as a hash need a CLI from version 6 or later.
|
|
552
625
|
|
|
@@ -611,6 +684,9 @@ How connections are handled:
|
|
|
611
684
|
The deployer is an `APIService` running on the target server with the `deployer` option. It receives a
|
|
612
685
|
build, unpacks it, installs dependencies, writes the configuration and starts the process in pm2.
|
|
613
686
|
|
|
687
|
+
The CLI is `bmfk` (`npx bmfk <command>`). `badmfck`, its old name, still works, so existing scripts
|
|
688
|
+
such as `"deploy": "badmfck deploy"` need no change; switch them to `bmfk` when convenient.
|
|
689
|
+
|
|
614
690
|
**On the server:**
|
|
615
691
|
|
|
616
692
|
```ts
|
|
@@ -623,15 +699,15 @@ getDefaultOptions({
|
|
|
623
699
|
```
|
|
624
700
|
|
|
625
701
|
`setup.json` lists who may deploy. The recommended way is a **signing key** per user. Run
|
|
626
|
-
`npx
|
|
702
|
+
`npx bmfk deploy-key` in the project: it writes an Ed25519 private key into `deploy.json` and prints the
|
|
627
703
|
public key to add to the user in `setup.json` (`setup-config` → "set a deployer user's public key").
|
|
628
704
|
Every request is then signed. A captured request can't be replayed or changed, the signature covers the
|
|
629
705
|
archive's sha256, and the deployer stores no secret at all. `"require_signature": true` in `setup.json`
|
|
630
706
|
turns passwords off for everyone once all users have keys. The project token is still required on top,
|
|
631
707
|
so a deploy always proves which project it is meant for. Users without a key sign in with a password,
|
|
632
708
|
which is stored as a hash. The easiest way to manage users, reviewers and
|
|
633
|
-
allowed addresses is `npx
|
|
634
|
-
single hash use `npx
|
|
709
|
+
allowed addresses is `npx bmfk setup-config <folder>`, a menu that hashes passwords for you; for a
|
|
710
|
+
single hash use `npx bmfk hash-password --deployer`. When sign-in fails, the deployer logs why
|
|
635
711
|
(unknown login, wrong password, an old CLI without `X-Deployer-Login`), while the client only gets
|
|
636
712
|
`Unauthorized`.
|
|
637
713
|
|
|
@@ -655,7 +731,7 @@ rejects the whole change, and the previous setup stays in force.
|
|
|
655
731
|
> it, every request appears to come from `127.0.0.1`. Never add `127.0.0.1` to `allowed_ips` on a
|
|
656
732
|
> deployer behind a proxy on the same host: that would let every request through.
|
|
657
733
|
|
|
658
|
-
A project config (`projects_path/<name>.json`). The easiest way to make one is `npx
|
|
734
|
+
A project config (`projects_path/<name>.json`). The easiest way to make one is `npx bmfk project-config`:
|
|
659
735
|
it asks for everything below, generates the token, takes config values as hidden input, checks the
|
|
660
736
|
result against the deployer's schema, and saves the project config and a matching `deploy.json` with
|
|
661
737
|
permissions `600`.
|
|
@@ -664,14 +740,21 @@ permissions `600`.
|
|
|
664
740
|
{
|
|
665
741
|
"name": "my-service",
|
|
666
742
|
"destination": "/var/node/my-service",
|
|
667
|
-
"token": "scrypt$16384$8$1$…", // hash of the project token: npx
|
|
743
|
+
"token": "scrypt$16384$8$1$…", // hash of the project token: npx bmfk project-token
|
|
668
744
|
"unpack": true, "install": true, "pm2": true,
|
|
669
745
|
"backup": true, // copy the current version aside before each deploy (see Backups)
|
|
670
746
|
"migrate": false, // run `npm run migrate` before the process starts
|
|
747
|
+
"omitDev": false, // true: install without devDependencies (npm ci --omit=dev)
|
|
671
748
|
"config": { "DB_HOST": "…" } // substituted into the shipped config placeholders _{{DB_HOST}}_
|
|
672
749
|
}
|
|
673
750
|
```
|
|
674
751
|
|
|
752
|
+
The `name` becomes the deployed `package.json` name, the data folder `/var/bmfk/<name>` and part of the
|
|
753
|
+
state, backup and secrets file names. So it is restricted: lowercase letters, digits, `.`, `_` and `-`,
|
|
754
|
+
starting with a letter or digit, up to 100 characters — for example `api.gateway.example.com`. A
|
|
755
|
+
project config with any other name is ignored, with an error in the deployer's log;
|
|
756
|
+
`bmfk migrate-configs` lists such configs too.
|
|
757
|
+
|
|
675
758
|
#### Keeping secrets out of the deployed code
|
|
676
759
|
|
|
677
760
|
By default, `config` values are written into the shipped files in place of `_{{KEY}}_`. That puts
|
|
@@ -679,7 +762,7 @@ passwords into the code, into both blue-green slots and into every backup. Add `
|
|
|
679
762
|
config to avoid this:
|
|
680
763
|
|
|
681
764
|
```jsonc
|
|
682
|
-
"secrets": {} //
|
|
765
|
+
"secrets": {} // "secrets_dir" from setup.json, else /var/bmfk/<project>/secrets[-<slot>].json
|
|
683
766
|
"secrets": { "dir": "/etc/node-secrets" } // → /etc/node-secrets/<project>[-<slot>].json
|
|
684
767
|
"secrets": { "file": "/etc/node-secrets/my.json" }
|
|
685
768
|
```
|
|
@@ -716,39 +799,66 @@ git: it holds credentials.
|
|
|
716
799
|
{
|
|
717
800
|
"name": "my-service",
|
|
718
801
|
"host": "https://deployer.example.com/api/pckg/add",
|
|
719
|
-
"token": "<project token, printed by npx
|
|
802
|
+
"token": "<project token, printed by npx bmfk project-token>",
|
|
720
803
|
"username": "ci",
|
|
721
|
-
"privateKey": "<from npx
|
|
804
|
+
"privateKey": "<from npx bmfk deploy-key>", // or "password": "<your password>"
|
|
722
805
|
"includes": ["certs", { "src": "assets/logo.png", "dest": "bin/logo.png" }],
|
|
723
|
-
"excludes": ["*.map"]
|
|
806
|
+
"excludes": ["*.map"],
|
|
807
|
+
"bundle": true // optional, see below
|
|
724
808
|
}
|
|
725
809
|
```
|
|
726
810
|
|
|
811
|
+
**`"bundle": true`** ships the app's own code as one file instead of the tsc tree in `./bin`. It needs the
|
|
812
|
+
bundler in the project: `npm i -D esbuild @babel/parser` (they are optional, so servers don't install them). esbuild
|
|
813
|
+
bundles `src/` into the file package.json `"main"` points to (the one pm2 starts, e.g. `bin/Main.js`).
|
|
814
|
+
Every package stays a plain `require()`, and the server still runs `npm ci` as usual. Everything else in
|
|
815
|
+
`./bin` (html, json, workers) ships as it is, so the slot keeps the same layout and `__dirname` in the
|
|
816
|
+
entry file is still `bin/`. `./bin` itself is not changed.
|
|
817
|
+
|
|
818
|
+
- The entry is derived from `"main"`: `bin/Main.js` → `src/Main.ts`. Override with
|
|
819
|
+
`"bundle": { "entry": "src/Main.ts" }`.
|
|
820
|
+
- A `bin/Main.js.map` ships alongside (line mappings only, no source code). The deployer then starts the
|
|
821
|
+
process with `--enable-source-maps` automatically, so stack traces point at the original `src/` lines
|
|
822
|
+
even when the code is one minified file. (If the project ships its own `ecosystem.config.js`, the
|
|
823
|
+
deployer can't edit it and instead logs a reminder to add `node_args: "--enable-source-maps"` yourself.)
|
|
824
|
+
Turn the map off with `"sourcemap": false`; an `excludes` pattern like `*.map` drops it too, and then
|
|
825
|
+
the flag isn't added.
|
|
826
|
+
- `"bundle": { "minify": true }` strips comments, renames local variables and collapses whitespace. It
|
|
827
|
+
costs nothing at runtime and makes the shipped file hard to read, so a casual `cat` over `./bin` no
|
|
828
|
+
longer reveals the source. It is **not** a secret-hiding measure: string literals (so any value baked
|
|
829
|
+
into the code) stay in clear text, and anyone running as the process user can still read them from the
|
|
830
|
+
runtime. The real fix for credentials in code is a [secrets file](#keeping-secrets-out-of-the-deployed-code);
|
|
831
|
+
protect the files themselves with `"chmod": 700` and a dedicated OS user.
|
|
832
|
+
- The deploy warns, but doesn't stop, about code that behaves differently once it's in one file:
|
|
833
|
+
`__dirname` / `__filename` outside the entry (it becomes `bin/`), a value exported by the entry (such
|
|
834
|
+
as `export const __root = __dirname`) read while modules load rather than inside a function (it's not
|
|
835
|
+
set yet), and `.js` files left in `./bin` that are not part of the bundle.
|
|
836
|
+
|
|
727
837
|
```json
|
|
728
838
|
"scripts": {
|
|
729
|
-
"deploy": "
|
|
730
|
-
"activate": "
|
|
731
|
-
"status": "
|
|
732
|
-
"backups": "
|
|
733
|
-
"restore": "
|
|
839
|
+
"deploy": "bmfk deploy",
|
|
840
|
+
"activate": "bmfk activate",
|
|
841
|
+
"status": "bmfk status",
|
|
842
|
+
"backups": "bmfk backups",
|
|
843
|
+
"restore": "bmfk restore"
|
|
734
844
|
}
|
|
735
845
|
```
|
|
736
846
|
|
|
737
847
|
| Command | What it does |
|
|
738
848
|
|---|---|
|
|
739
|
-
| `
|
|
740
|
-
| `
|
|
741
|
-
| `
|
|
742
|
-
| `
|
|
743
|
-
| `
|
|
744
|
-
| `
|
|
745
|
-
| `
|
|
746
|
-
| `
|
|
747
|
-
| `
|
|
748
|
-
| `
|
|
749
|
-
| `
|
|
750
|
-
| `
|
|
751
|
-
| `
|
|
849
|
+
| `bmfk wizards` | list every interactive wizard below with what it does, and run one |
|
|
850
|
+
| `bmfk deploy [config]` | build and upload the project |
|
|
851
|
+
| `bmfk activate [config] [blue\|green]` | switch traffic to a slot (blue-green) |
|
|
852
|
+
| `bmfk status [config]` | active and last deployed slot, recent history |
|
|
853
|
+
| `bmfk backups [config]` | list backups |
|
|
854
|
+
| `bmfk restore [config] [backup] [--yes]` | restore a backup |
|
|
855
|
+
| `bmfk hash-password [--deployer]` | hash a password for the monitor or `setup.json` |
|
|
856
|
+
| `bmfk project-token [--hash]` | generate a project token and its hash, or hash an existing token |
|
|
857
|
+
| `bmfk project-config` | build a project config for the deployer step by step (plus a `deploy.json` skeleton) |
|
|
858
|
+
| `bmfk access-config [file]` | create or edit `access.json`: monitor and documentation users, roles, passwords, allowed addresses |
|
|
859
|
+
| `bmfk migrate-configs [folder] [--yes]` | hash the secrets of old `setup.json`, project configs and `access.json` files in place |
|
|
860
|
+
| `bmfk setup-config [file\|folder]` | edit the deployer's `setup.json`: add, rename or remove users, change passwords, reviewers, allowed IPs |
|
|
861
|
+
| `bmfk deploy-key [deploy.json]` | generate a signing key: private key into `deploy.json`, public key for `setup.json` |
|
|
752
862
|
|
|
753
863
|
To pass a config path through npm, use `--`: `npm run deploy -- deploy/prod.json`.
|
|
754
864
|
|
|
@@ -759,7 +869,9 @@ To pass a config path through npm, use `--`: `npm run deploy -- deploy/prod.json
|
|
|
759
869
|
- Unsafe destinations are refused: relative paths, the filesystem root, top-level system folders
|
|
760
870
|
(`/var`, `/etc`…), the deployer's own folders, and a folder whose wipe would delete another project.
|
|
761
871
|
- Dependencies are installed with `npm ci --ignore-scripts`. `migrate` is the only script the deployer
|
|
762
|
-
runs.
|
|
872
|
+
runs. With `"omitDev": true` in the project config, devDependencies (TypeScript, test tools, the
|
|
873
|
+
bundler) are not installed on the server at all. Check first that `npm start` and `npm run migrate`
|
|
874
|
+
need nothing from devDependencies — `ts-node` in a migrate script, for example.
|
|
763
875
|
- Every deploy, switch and restore needs a deployer user and the project token. Both are stored on
|
|
764
876
|
the server only as hashes.
|
|
765
877
|
- `allowed_ips` limits which addresses can reach the deployer at all.
|
|
@@ -832,7 +944,7 @@ The deployer manages two nginx files per project:
|
|
|
832
944
|
npm run deploy # new version → inactive slot (e.g. green), production unchanged
|
|
833
945
|
npm run status # "green is deployed but NOT switched"
|
|
834
946
|
npm run activate # traffic → green
|
|
835
|
-
npx
|
|
947
|
+
npx bmfk activate blue # rollback → blue
|
|
836
948
|
```
|
|
837
949
|
|
|
838
950
|
### Is my process live? (in the application)
|
|
@@ -894,7 +1006,7 @@ With `"backup": true`, the deployer copies the destination aside before every de
|
|
|
894
1006
|
```bash
|
|
895
1007
|
npm run backups # list: version, slot, who, when, size
|
|
896
1008
|
npm run restore # pick one interactively, confirm
|
|
897
|
-
npx
|
|
1009
|
+
npx bmfk restore 2026-10-13_10-00-00-my-service-blue --yes # non-interactive (CI)
|
|
898
1010
|
```
|
|
899
1011
|
|
|
900
1012
|
How a restore works:
|
|
@@ -918,7 +1030,7 @@ credentials alone can't change production.
|
|
|
918
1030
|
### Setup
|
|
919
1031
|
|
|
920
1032
|
Reviewers are defined in the deployer's `setup.json`. Their passwords are hashes made with
|
|
921
|
-
`npx
|
|
1033
|
+
`npx bmfk hash-password`, and they set up 2FA at the first sign-in. `review_url` is the address of
|
|
922
1034
|
the review page, as reviewers reach it:
|
|
923
1035
|
|
|
924
1036
|
```jsonc
|
|
@@ -948,7 +1060,7 @@ so at startup and refuses that project's uploads until it is fixed.
|
|
|
948
1060
|
|
|
949
1061
|
### How it works
|
|
950
1062
|
|
|
951
|
-
1. **`
|
|
1063
|
+
1. **`bmfk deploy`** uploads as usual. The archive goes through all the usual checks and is then
|
|
952
1064
|
held. The CLI prints `WAITING FOR REVIEW`, and production is untouched.
|
|
953
1065
|
2. **Each reviewer gets an email** with a personal link. The link alone is not enough: it opens a
|
|
954
1066
|
sign-in with login, password and a 2FA code.
|
|
@@ -957,7 +1069,7 @@ so at startup and refuses that project's uploads until it is fixed.
|
|
|
957
1069
|
line-by-line diff.
|
|
958
1070
|
4. **Accept** runs the normal deploy (backup, migrations, pm2, nginx) from the stored archive, after
|
|
959
1071
|
checking that its SHA-256 still matches what the reviewers saw. For blue-green, the new version
|
|
960
|
-
lands in the inactive slot, and `
|
|
1072
|
+
lands in the inactive slot, and `bmfk activate` still switches traffic. **Decline** deletes the
|
|
961
1073
|
archive.
|
|
962
1074
|
5. **A new upload** replaces the pending one. Every old link and every open review session stop
|
|
963
1075
|
working, and reviewers get new links.
|
|
@@ -1000,6 +1112,34 @@ so no restart is needed.
|
|
|
1000
1112
|
|
|
1001
1113
|
---
|
|
1002
1114
|
|
|
1115
|
+
|
|
1116
|
+
### Data folder
|
|
1117
|
+
|
|
1118
|
+
What has to survive restarts and deploys lives in one folder per project, outside the deployed code:
|
|
1119
|
+
|
|
1120
|
+
```
|
|
1121
|
+
/var/bmfk/<project>/
|
|
1122
|
+
metrics/ metrics history: the current week per minute, 10 weeks in all
|
|
1123
|
+
threats.json what the threat monitor has seen (addresses, user agents, URLs — never bodies)
|
|
1124
|
+
blocked-ips.json
|
|
1125
|
+
monitor-2fa.json monitor 2FA enrollments
|
|
1126
|
+
secrets[-<slot>].json config values the deployer keeps out of the code (`"secrets": {}`)
|
|
1127
|
+
```
|
|
1128
|
+
|
|
1129
|
+
- **The project name is the deployer's.** On every deploy the deployer writes its project name into
|
|
1130
|
+
the deployed `package.json` (and `package-lock.json`) `"name"`, and the app takes it from there. One
|
|
1131
|
+
source tree deployed as several projects gets a folder per project; the two blue-green slots of one
|
|
1132
|
+
project share theirs. Your repository's `package.json` is not changed. Off the deployer, the
|
|
1133
|
+
`package.json` name is used as is. (`projectName` stays what the authenticator app shows.)
|
|
1134
|
+
- **One writer.** Only the live process writes metrics and threats: a blue-green standby and pm2 cluster workers
|
|
1135
|
+
other than instance 0 count in memory only. A slot that becomes live loads what the other slot wrote,
|
|
1136
|
+
so charts continue across deploys.
|
|
1137
|
+
- **Rights.** The app creates its folder (`0700`). If it can't create `/var/bmfk` — say, the app runs as
|
|
1138
|
+
an unprivileged user — it says so at startup and falls back to a folder beside the code. Create the
|
|
1139
|
+
root once: `sudo mkdir /var/bmfk && sudo chown <app user> /var/bmfk`.
|
|
1140
|
+
- `BMFK_DATA_DIR` moves the root. Each file can still be set on its own: `metricsDir` (`false` keeps
|
|
1141
|
+
metrics in memory), `blockedIps.file`, `monitorAuthDir` / `monitorAuthFile`.
|
|
1142
|
+
|
|
1003
1143
|
## Options reference
|
|
1004
1144
|
|
|
1005
1145
|
| Option | Default | Description |
|
|
@@ -1013,8 +1153,8 @@ so no restart is needed.
|
|
|
1013
1153
|
| `interceptor` | — | authentication for your endpoints |
|
|
1014
1154
|
| `preproducer` / `postproducer` | — | hooks before the handler / before the response is sent |
|
|
1015
1155
|
| `access` | `{}` | `{ monitor, documentation, monitorAllowedIps }`, or a path to a JSON file reloaded on change |
|
|
1016
|
-
| `monitorAuthDir` / `monitorAuthFile` |
|
|
1017
|
-
| `metricsDir` |
|
|
1156
|
+
| `monitorAuthDir` / `monitorAuthFile` | `/var/bmfk/<project>/monitor-2fa.json` | where 2FA enrollments are stored |
|
|
1157
|
+
| `metricsDir` | `/var/bmfk/<project>/metrics` | metrics history, 10 weeks; `false` → in memory only |
|
|
1018
1158
|
| `logFiles` | pm2 auto-detected | log files the monitor may tail (for example nginx) |
|
|
1019
1159
|
| `threatMonitoring` | `true` | probe and scan detection; observation only |
|
|
1020
1160
|
| `trustedProxies` | loopback | proxies whose `X-Real-IP` / `X-Forwarded-For` are trusted |
|
|
@@ -1053,7 +1193,7 @@ so no restart is needed.
|
|
|
1053
1193
|
### What you must configure before going to production
|
|
1054
1194
|
|
|
1055
1195
|
1. Set `corsHostWhiteList` to your real front-end origins. Don't use `"*"` with cookies.
|
|
1056
|
-
2. Store all monitor and deployer passwords as hashes (`npx
|
|
1196
|
+
2. Store all monitor and deployer passwords as hashes (`npx bmfk hash-password`).
|
|
1057
1197
|
3. Point `monitorAuthDir` to a persistent directory outside the deploy folders, readable only by the
|
|
1058
1198
|
service user.
|
|
1059
1199
|
4. Run behind nginx (or another proxy) on loopback with TLS, and keep `trustedProxies` at its default
|
|
@@ -1080,7 +1220,7 @@ so no restart is needed.
|
|
|
1080
1220
|
each part and convert its files right after:
|
|
1081
1221
|
|
|
1082
1222
|
1. **CLI.** Update the CLI on the machines you deploy from. The new CLI also works with old deployers.
|
|
1083
|
-
2. **Deployer.** Upgrade the deployer, then run `npx
|
|
1223
|
+
2. **Deployer.** Upgrade the deployer, then run `npx bmfk migrate-configs <projects folder>`. It
|
|
1084
1224
|
picks up the folder's `setup.json` and every project config at once. Add `--yes` to skip the
|
|
1085
1225
|
confirmation, for example in a script. It hashes the
|
|
1086
1226
|
passwords in `setup.json` and the token of every project config, and renames the old `username`
|
|
@@ -1088,15 +1228,15 @@ each part and convert its files right after:
|
|
|
1088
1228
|
`deploy.json` unchanged.
|
|
1089
1229
|
3. **Apps.** Upgrade each app, then convert its `access.json` with the same command. Monitor users
|
|
1090
1230
|
keep their passwords; documentation passwords stay as they are. An app that sets `access` as an
|
|
1091
|
-
inline object needs the passwords in that object replaced with hashes (`npx
|
|
1092
|
-
or moved to a file with `npx
|
|
1231
|
+
inline object needs the passwords in that object replaced with hashes (`npx bmfk hash-password`),
|
|
1232
|
+
or moved to a file with `npx bmfk access-config`.
|
|
1093
1233
|
|
|
1094
1234
|
Before changing anything, `migrate-configs` shows what it will change and flags weak passwords (short,
|
|
1095
1235
|
or the same as the login). It copies the originals into a `.pre-hash-backup-*` folder (permissions
|
|
1096
1236
|
`700`) and verifies every new hash. Delete that folder once deploys and sign-ins work, because it holds
|
|
1097
1237
|
the plain secrets.
|
|
1098
1238
|
|
|
1099
|
-
Then move deploys to signing keys, one user at a time: `npx
|
|
1239
|
+
Then move deploys to signing keys, one user at a time: `npx bmfk deploy-key` in the project, and the
|
|
1100
1240
|
public key into `setup.json`. When every user has a key, set `"require_signature": true`.
|
|
1101
1241
|
|
|
1102
1242
|
Also removed in 6.x: the old `MysqlService` (use `DBService`).
|