Guard server setup behind an initialized PKI
- Profiler: server_files_missing/require_* helpers; 409 for /server/configure, start/restart and POST /profiles when the PKI is not initialized or server files (honouring fqdn_server) are missing; stop stays allowed; DELETE /system/pki returns 409 while OpenVPN runs; GET /system/init/status adds pki_ready, server_ready, missing. - UI: shared usePkiStatus; VPN menu item locked until the PKI is ready, route guard for /config/vpn, Start/Restart and New Client disabled with hints, lock notice on the VPN page. - Test: one pytest (test_pki_guard.py). - Docs: plan and summary in DOCS/Changes, API reference, README, Index. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
dcc3d7f2d5
commit
56dae90ff5
19 files changed
+342
-22
No files matched your search
@@ -24,7 +24,7 @@ List all user profiles.
|
||||
Create a new user profile.
|
||||
- **Body**: `{"username": "jdoe"}`
|
||||
- **Action**: Generates keys, requests certificate, builds `.ovpn` file.
|
||||
- **Response `409`**: PKI initialization is running (the PKI is not complete yet).
|
||||
- **Response `409`**: PKI initialization is running, or the PKI is not initialized (`"PKI is not initialized. Initialize PKI first."`).
|
||||
|
||||
### `DELETE /profiles/{id}`
|
||||
Revoke a user profile.
|
||||
@@ -66,13 +66,15 @@ Start PKI initialization (init-pki, CA, server certificate, DH, TLS key, CRL) as
|
||||
|
||||
### `GET /system/init/status`
|
||||
Current state of the initialization job.
|
||||
- **Response**: `{ "state": "idle|running|done|error", "step": "init-pki|ca|server-cert|dh|ta-key|crl|null", "initialized": true, "started_at": "2026-10-04T10:00:00Z", "finished_at": null, "error": null }`
|
||||
- **Response**: `{ "state": "idle|running|done|error", "step": "init-pki|ca|server-cert|dh|ta-key|crl|null", "initialized": true, "started_at": "2026-10-04T10:00:00Z", "finished_at": null, "error": null, "pki_ready": true, "server_ready": true, "missing": [] }`
|
||||
- `initialized` reflects the files on disk (complete PKI), independent of `state`.
|
||||
- `pki_ready`: the PKI is initialized and no job is running (client certificates can be issued).
|
||||
- `server_ready`: `pki_ready` and every file `server.conf` references exists; `missing` lists the absent ones (relative to the PKI directory: `ca.crt`, `issued/<fqdn_server>.crt`, `private/<fqdn_server>.key`, `dh.pem`, `ta.key`, and `crl.pem` only when `crl_verify` is on). The check uses the current `fqdn_server`, so renaming the server after init makes it not ready.
|
||||
- `error` contains the EasyRSA message when `state` is `error`.
|
||||
|
||||
### `DELETE /system/pki`
|
||||
**DANGER**: Completely wipes the PKI directory and resets the job state.
|
||||
- **Response `409`**: an initialization job is running.
|
||||
- **Response `409`**: an initialization job is running, or OpenVPN is running (`"Stop OpenVPN first"`).
|
||||
|
||||
---
|
||||
|
||||
@@ -81,11 +83,13 @@ Current state of the initialization job.
|
||||
### `POST /server/configure`
|
||||
Generate the `server.conf` file based on current database settings.
|
||||
- **Response**: `{"message": "Server configuration generated", "path": "/etc/openvpn/server.conf"}`
|
||||
- **Response `409`**: the PKI is not initialized or an init job is running (`"PKI is not initialized. Initialize PKI first."`), or server files are missing (`"PKI server files are missing: ..."`).
|
||||
|
||||
### `POST /server/process/{action}`
|
||||
Control the OpenVPN system service.
|
||||
- **Path Param**: `action` (start, stop, restart)
|
||||
- **Response**: Status of the command execution.
|
||||
- **Response `409`**: for `start` and `restart` only, same conditions as `POST /server/configure`. `stop` is always allowed.
|
||||
|
||||
### `GET /server/process/stats`
|
||||
Get telemetry for the OpenVPN process.
|
||||
|
||||
Reference in new issue
Block a user