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
@@ -56,7 +56,8 @@
|
||||
<!-- Start -->
|
||||
<button type="button" class="btn-action btn-action-primary"
|
||||
@click="handleControl('start')"
|
||||
:disabled="isLoading || stats.status === 'running'">
|
||||
:disabled="isLoading || stats.status === 'running' || !pkiStatus.server_ready"
|
||||
:title="startHint">
|
||||
<i v-if="isLoading && action==='start'" class="fas fa-spinner fa-spin"></i>
|
||||
<i v-else class="fas fa-play"></i>
|
||||
Start Service
|
||||
@@ -65,7 +66,8 @@
|
||||
<!-- Restart -->
|
||||
<button type="button" class="btn-action btn-action-save"
|
||||
@click="handleControl('restart')"
|
||||
:disabled="isLoading">
|
||||
:disabled="isLoading || !pkiStatus.server_ready"
|
||||
:title="startHint">
|
||||
<i v-if="isLoading && action==='restart'" class="fas fa-spinner fa-spin"></i>
|
||||
<i v-else class="fas fa-sync-alt"></i>
|
||||
Restart Service
|
||||
@@ -86,12 +88,22 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted, onUnmounted } from 'vue';
|
||||
import { ref, reactive, computed, onMounted, onUnmounted } from 'vue';
|
||||
import { useApi } from '../composables/useApi';
|
||||
import { useToast } from '../composables/useToast';
|
||||
import { usePkiStatus } from '../composables/usePkiStatus';
|
||||
|
||||
const { profilesApiClient } = useApi();
|
||||
const toast = useToast();
|
||||
const { status: pkiStatus, refresh: refreshPkiStatus } = usePkiStatus();
|
||||
|
||||
// Start/Restart need the PKI server files (Stop stays available)
|
||||
const startHint = computed(() => {
|
||||
if (pkiStatus.server_ready) return '';
|
||||
return pkiStatus.pki_ready && pkiStatus.missing.length
|
||||
? `Missing server files: ${pkiStatus.missing.join(', ')}`
|
||||
: 'Initialize PKI first';
|
||||
});
|
||||
|
||||
// State
|
||||
const stats = reactive({
|
||||
@@ -141,6 +153,7 @@ const handleControl = async (cmd) => {
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
refreshPkiStatus();
|
||||
fetchStats();
|
||||
// Poll every 5 seconds
|
||||
pollInterval = setInterval(fetchStats, 5000);
|
||||
|
||||
Reference in new issue
Block a user