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
+23
-3
@@ -38,9 +38,13 @@
|
||||
<router-link to="/config/pki" class="nav-link" active-class="active" title="PKI">
|
||||
<i class="fas fa-fingerprint"></i> <span>PKI</span>
|
||||
</router-link>
|
||||
<router-link to="/config/vpn" class="nav-link" active-class="active" title="VPN">
|
||||
<router-link v-if="pkiStatus.pki_ready" to="/config/vpn" class="nav-link" active-class="active" title="VPN">
|
||||
<i class="fas fa-server"></i> <span>VPN</span>
|
||||
</router-link>
|
||||
<!-- Locked until the PKI is initialized: stays visible so the reason is clear -->
|
||||
<a v-else href="/config/pki" class="nav-link nav-link-locked" title="Initialize PKI first" @click.prevent="onLockedVpnClick">
|
||||
<i class="fas fa-lock"></i> <span>VPN</span>
|
||||
</a>
|
||||
|
||||
<!-- SECTION: MANAGEMENT -->
|
||||
<div class="nav-section-header mt-3">MANAGEMENT</div>
|
||||
@@ -129,6 +133,8 @@ import { useAppConfig } from './composables/useAppConfig';
|
||||
import { useApi } from './composables/useApi';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import ToastContainer from './components/ToastContainer.vue';
|
||||
import { usePkiStatus } from './composables/usePkiStatus';
|
||||
import { useToast } from './composables/useToast';
|
||||
|
||||
const { loadConfig, isLoaded } = useAppConfig();
|
||||
const { apiClient } = useApi();
|
||||
@@ -139,6 +145,8 @@ const isSidebarOpen = ref(false);
|
||||
const isCompact = ref(false);
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const { status: pkiStatus, refresh: refreshPkiStatus } = usePkiStatus();
|
||||
const toast = useToast();
|
||||
|
||||
const isAuthenticated = computed(() => route.name !== 'Login');
|
||||
const username = ref(localStorage.getItem('ovpmon_user') || '');
|
||||
@@ -160,6 +168,12 @@ const syncUsername = async () => {
|
||||
};
|
||||
const onUserChanged = () => { username.value = localStorage.getItem('ovpmon_user') || ''; };
|
||||
|
||||
// The locked VPN item points to the PKI page instead of the VPN page
|
||||
const onLockedVpnClick = () => {
|
||||
toast.show('Initialize PKI first', 'info');
|
||||
if (route.name !== 'PKIConfig') router.push('/config/pki');
|
||||
};
|
||||
|
||||
const handleLogout = () => {
|
||||
localStorage.removeItem('ovpmon_token');
|
||||
localStorage.removeItem('ovpmon_user');
|
||||
@@ -185,13 +199,19 @@ const refreshPage = () => {
|
||||
// Close sidebar on route change
|
||||
watch(() => route.path, () => {
|
||||
isSidebarOpen.value = false;
|
||||
if (route.name !== 'Login') syncUsername();
|
||||
if (route.name !== 'Login') {
|
||||
syncUsername();
|
||||
refreshPkiStatus();
|
||||
}
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
await loadConfig();
|
||||
window.addEventListener('ovpmon-user-changed', onUserChanged);
|
||||
if (route.name !== 'Login') syncUsername();
|
||||
if (route.name !== 'Login') {
|
||||
syncUsername();
|
||||
refreshPkiStatus();
|
||||
}
|
||||
|
||||
// Init Theme
|
||||
const savedTheme = localStorage.getItem('theme') || 'light';
|
||||
|
||||
Reference in new issue
Block a user