Files
OpenVPN-Monitoring-Simple/DOCS/Profiler_Management/API_Reference.md
T
ayurishchevandClaude Sonnet 5.5 d251ec73d0 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>
2026-10-04 20:56:36 +03:00

3.5 KiB

OpenVPN Profiler API Reference

This module (APP_PROFILER) is built with FastAPI and provides management capabilities.

Base URL: http://<your-server>:8000/api

Authentication

All endpoints (except initial setup) require a Bearer Token. Header: Authorization: Bearer <JWT_TOKEN>

Note: The token is shared with the Core Monitoring API.


1. User Profiles

Manage OpenVPN Client profiles (.ovpn configs and certificates).

GET /profiles

List all user profiles.

  • 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).

2. System Configuration

Manage global settings for the server and PKI.

GET /config

Get current configuration.

  • Query Params: section (optional: 'server' or 'pki')
  • Response: { "server": {...}, "pki": {...} }

PUT /config/server

Update OpenVPN Server settings (e.g., protocol, port, DNS).

  • Body: JSON object matching SystemSettings schema.

PUT /config/pki

Update PKI settings (e.g., Key Size, Certificate Expiry).

  • Body: JSON object matching PKISetting schema.

POST /system/init

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 and resets the job state.

  • Response 409: an initialization job is running.

3. Server Management

POST /server/configure

Generate the server.conf file based on current database settings.

  • Response: {"message": "Server configuration generated", "path": "/etc/openvpn/server.conf"}

POST /server/process/{action}

Control the OpenVPN system service.

  • Path Param: action (start, stop, restart)
  • Response: Status of the command execution.

GET /server/process/stats

Get telemetry for the OpenVPN process.

  • Response: { "status": "running", "cpu_percent": 1.2, "memory_mb": 45.0 }