Certificates: profile modal with notes, note tooltip; async PKI init

- Profiler: UserProfile.note (nullable, startup migration), PUT
  /profiles/{id}/note (max 1000 chars); add missing `requests`
  dependency (client creation failed without Public IP set).
- UI: clickable rows on Certificates open a compact profile details
  modal with an editable note; tooltip with the note on the client
  name (v-note-tooltip) and a note icon.
- PKI init runs in a background thread: POST /system/init returns 202,
  GET /system/init/status, 409 for a second start, Clear PKI and client
  creation are blocked while it runs. A marker file identifies an
  interrupted run (only such a PKI is wiped on the next Init).
- PKI Configuration page: state from the server, progress spinner and
  step text, polling, Init/Clear/Save locked while running, Init locked
  once initialized.
- Tests: one pytest each for notes and async init (requirements-dev.txt).
- Docs: plans and summaries in DOCS/Changes, API reference, README, Index.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ayurishchevandClaude Sonnet 5.5 committed 2026-10-04 20:56:36 +03:00
1 parent 3836049230
commit d251ec73d0
24 files changed
+722 -39

No files matched your search

+19 -4
View File
@@ -18,17 +18,23 @@ Manage OpenVPN Client profiles (`.ovpn` configs and certificates).
### `GET /profiles`
List all user profiles.
- **Response**: Array of profile objects (id, username, status, expiration_date, etc.).
- **Response**: Array of profile objects (id, username, status, expiration_date, note, etc.).
### `POST /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).
### `DELETE /profiles/{id}`
Revoke a user profile.
- **Action**: Revokes certificate in CRL and marks profile as revoked in DB.
### `PUT /profiles/{id}/note`
Set or clear the free-text note of a profile.
- **Body**: `{"note": "text"}` (max 1000 characters; empty or `null` clears the note)
- **Response**: Updated profile object (including `note`). `404` if the profile does not exist.
### `GET /profiles/{id}/download`
Download the `.ovpn` configuration file for a user.
- **Response**: File stream (application/x-openvpn-profile).
@@ -53,11 +59,20 @@ Update PKI settings (e.g., Key Size, Certificate Expiry).
- **Body**: JSON object matching `PKISetting` schema.
### `POST /system/init`
Initialize the PKI infrastructure (InitCA, GenDH, BuildServerCert).
- **Note**: Only runs if PKI is empty.
Start PKI initialization (init-pki, CA, server certificate, DH, TLS key, CRL) as a background job. Returns immediately.
- **Response `202`**: `{"state": "running"}`
- **Response `409`**: a job is already running, or the PKI is already complete (`ca.crt`, `dh.pem`, `ta.key`, `crl.pem` and the server certificate). An incomplete PKI left by an interrupted run is removed and initialization starts again.
- **Note**: Job state is kept in memory; the Profiler must run as a single process (one uvicorn worker). After a restart the state is `idle`.
### `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 }`
- `initialized` reflects the files on disk (complete PKI), independent of `state`.
- `error` contains the EasyRSA message when `state` is `error`.
### `DELETE /system/pki`
**DANGER**: Completely wipes the PKI directory.
**DANGER**: Completely wipes the PKI directory and resets the job state.
- **Response `409`**: an initialization job is running.
---