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:
ayurishchevandClaude Sonnet 5.5 committed 2026-10-04 21:52:40 +03:00
1 parent dcc3d7f2d5
commit 56dae90ff5
19 files changed
+342 -22

No files matched your search

+6 -2
View File
@@ -173,9 +173,11 @@ import { ref, computed, onMounted, onUnmounted, reactive } from 'vue';
import { useApi } from '../composables/useApi';
import { useToast } from '../composables/useToast';
import { usePkiStatus } from '../composables/usePkiStatus';
const { profilesApiClient } = useApi();
const toast = useToast();
const { refresh: refreshPkiStatus } = usePkiStatus();
// State
const form = reactive({
@@ -265,6 +267,7 @@ const loadStatus = async (initial = false) => {
return;
}
stopPolling();
if (wasRunning) refreshPkiStatus(); // unlock the sidebar without a reload
// Report the result once: a job seen running on this page, or a failure found on page load
if (wasRunning && initStatus.state === 'done') {
showMessage('PKI initialized successfully!', 'success');
@@ -301,7 +304,7 @@ const handleInit = async () => {
// Already running (second tab) or already initialized: attach to the server state
await loadStatus();
} else {
showMessage(`Error initializing: ${err.message}`, 'error');
showMessage(`Error initializing: ${err.response?.data?.detail || err.message}`, 'error');
}
} finally {
isLoading.value = false;
@@ -319,8 +322,9 @@ const handleClear = async () => {
const data = res.data;
showMessage(data.message || 'PKI cleared successfully!', 'warning');
await loadStatus();
refreshPkiStatus();
} catch (err) {
showMessage(`Error clearing PKI: ${err.message}`, 'error');
showMessage(`Error clearing PKI: ${err.response?.data?.detail || err.message}`, 'error');
} finally {
isLoading.value = false;
action.value = '';