feat(auth): enhance security and audit logging
- Integrate webhook alerts for admin login lockouts. - Implement detailed audit logging for login, logout, and setup actions. - Improve client revocation event tracking. - Standardize error handling in profile updates. - Enforce 'operator' role for event API access.
This commit is contained in:
1 parent
5c977d6977
commit
8132087085
52 files changed
+4434
-407
No files matched your search
+55
-29
@@ -1,6 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import { PageShell } from '@/components/layout/PageShell';
|
||||
import { useVconRole } from '@/components/layout/VconShell';
|
||||
import { Button } from '@/components/ui/Button';
|
||||
import { Panel } from '@/components/ui/Panel';
|
||||
import { StatStrip } from '@/components/ui/StatStrip';
|
||||
@@ -16,6 +17,7 @@ import {
|
||||
} from '@/components/ui/Table';
|
||||
import { useToast } from '@/components/ui/Toast';
|
||||
import { getCached, setCached } from '@/lib/vconCache';
|
||||
import { getVconRoleCapabilities } from '@/lib/vconUiHelpers';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
|
||||
interface StorageStatsSummary {
|
||||
@@ -32,10 +34,13 @@ interface StoragePartitionFile {
|
||||
sizeBytes: number;
|
||||
linesCount: number;
|
||||
modifiedAt: string;
|
||||
compressed?: boolean;
|
||||
}
|
||||
|
||||
export default function StoragePage() {
|
||||
const { success, warning, error } = useToast();
|
||||
const currentRole = useVconRole();
|
||||
const { canOperate } = getVconRoleCapabilities(currentRole);
|
||||
const [stats, setStats] = useState<StorageStatsSummary | null>(() =>
|
||||
getCached<StorageStatsSummary | null>('vcon:storage-stats', null)
|
||||
);
|
||||
@@ -76,6 +81,10 @@ export default function StoragePage() {
|
||||
}, [fetchStorageData]);
|
||||
|
||||
const handleManualFlush = async () => {
|
||||
if (!canOperate) {
|
||||
error('Read-only role', 'Buffer flush requires operator or owner permissions.');
|
||||
return;
|
||||
}
|
||||
setFlushing(true);
|
||||
try {
|
||||
const res = await fetch('/api/storage', {
|
||||
@@ -134,16 +143,22 @@ export default function StoragePage() {
|
||||
>
|
||||
Refresh
|
||||
</Button>
|
||||
<Button
|
||||
size="xs"
|
||||
variant="primary"
|
||||
icon="HardDrive"
|
||||
loading={flushing}
|
||||
disabled={flushing}
|
||||
onClick={() => void handleManualFlush()}
|
||||
>
|
||||
Flush Buffer
|
||||
</Button>
|
||||
{canOperate ? (
|
||||
<Button
|
||||
size="xs"
|
||||
variant="primary"
|
||||
icon="HardDrive"
|
||||
loading={flushing}
|
||||
disabled={flushing}
|
||||
onClick={() => void handleManualFlush()}
|
||||
>
|
||||
Flush Buffer
|
||||
</Button>
|
||||
) : (
|
||||
<span className="border border-[var(--border)] bg-[var(--surface-2)] px-2 py-1 font-mono text-[10.5px] uppercase tracking-wider text-[var(--text-muted)]">
|
||||
Read-only ({currentRole})
|
||||
</span>
|
||||
)}
|
||||
</>
|
||||
}
|
||||
>
|
||||
@@ -178,25 +193,36 @@ export default function StoragePage() {
|
||||
{files.length === 0 ? (
|
||||
<TableEmpty colSpan={5} message="No CSV files" />
|
||||
) : (
|
||||
files.map((file) => (
|
||||
<TableRow key={`${file.clientId}/${file.filename}`}>
|
||||
<TableCell className="font-mono text-[var(--accent)]">
|
||||
{file.clientId}
|
||||
</TableCell>
|
||||
<TableCell className="font-mono font-medium text-[var(--text)]">
|
||||
{file.filename}
|
||||
</TableCell>
|
||||
<TableCell className="font-mono tabular-nums">
|
||||
{(file.sizeBytes / 1024).toFixed(1)} KB
|
||||
</TableCell>
|
||||
<TableCell className="font-mono tabular-nums">
|
||||
{file.linesCount.toLocaleString()}
|
||||
</TableCell>
|
||||
<TableCell className="font-mono tabular-nums text-[var(--text-dim)]">
|
||||
{new Date(file.modifiedAt).toLocaleString()}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))
|
||||
files.map((file) => {
|
||||
const isCompressed = Boolean(
|
||||
file.compressed ||
|
||||
file.filename.toLowerCase().endsWith('.csv.gz')
|
||||
);
|
||||
return (
|
||||
<TableRow key={`${file.clientId}/${file.filename}`}>
|
||||
<TableCell className="font-mono text-[var(--accent)]">
|
||||
{file.clientId}
|
||||
</TableCell>
|
||||
<TableCell className="font-mono font-medium text-[var(--text)]">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="shrink-0 border border-[var(--border-strong)] px-1 py-0.5 font-mono text-[9px] uppercase tracking-wider text-[var(--text-muted)]">
|
||||
{isCompressed ? 'CSV.GZ' : 'CSV'}
|
||||
</span>
|
||||
<span>{file.filename}</span>
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell className="font-mono tabular-nums">
|
||||
{(file.sizeBytes / 1024).toFixed(1)} KB
|
||||
</TableCell>
|
||||
<TableCell className="font-mono tabular-nums">
|
||||
{file.linesCount.toLocaleString()}
|
||||
</TableCell>
|
||||
<TableCell className="font-mono tabular-nums text-[var(--text-dim)]">
|
||||
{new Date(file.modifiedAt).toLocaleString()}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
);
|
||||
})
|
||||
)}
|
||||
</TableBody>
|
||||
</Table>
|
||||
|
||||
Reference in new issue
Block a user