From bcb7554ffca23dac129df0ba03b04e1c5797dda6 Mon Sep 17 00:00:00 2001 From: Kaj Kowalski Date: Sun, 13 Jul 2025 23:27:36 +0200 Subject: [PATCH] fix: improve admin security and modal accessibility - Replace Card-based modal with proper Dialog component in SecurityAlertsTable for better accessibility - Add missing admin role check to threat-analysis endpoint for proper authorization - Implement ARIA attributes, focus management, and semantic structure - Ensure consistent admin security patterns across endpoints --- .../threat-analysis/route.ts | 2 +- components/security/SecurityAlertsTable.tsx | 98 ++++++++++--------- 2 files changed, 55 insertions(+), 45 deletions(-) diff --git a/app/api/admin/security-monitoring/threat-analysis/route.ts b/app/api/admin/security-monitoring/threat-analysis/route.ts index 2425817..6327de5 100644 --- a/app/api/admin/security-monitoring/threat-analysis/route.ts +++ b/app/api/admin/security-monitoring/threat-analysis/route.ts @@ -29,7 +29,7 @@ export async function POST(request: NextRequest) { try { const session = await getServerSession(authOptions); - if (!session?.user || !session.user.isPlatformUser) { + if (!session?.user || session.user.role !== "ADMIN") { return NextResponse.json({ error: "Unauthorized" }, { status: 401 }); } diff --git a/components/security/SecurityAlertsTable.tsx b/components/security/SecurityAlertsTable.tsx index 576d7da..e8b14b3 100644 --- a/components/security/SecurityAlertsTable.tsx +++ b/components/security/SecurityAlertsTable.tsx @@ -4,7 +4,15 @@ import { AlertTriangle, CheckCircle, Eye, EyeOff } from "lucide-react"; import { useState } from "react"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; -import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; +import { Card, CardContent } from "@/components/ui/card"; +import { + Dialog, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, +} from "@/components/ui/dialog"; import { Table, TableBody, @@ -196,32 +204,32 @@ export function SecurityAlertsTable({ )} {/* Alert Details Modal */} - {selectedAlert && ( - - - -
-
- {selectedAlert.title} -
- - {selectedAlert.severity} - - - {formatAlertType(selectedAlert.type)} - -
-
- + {selectedAlert?.severity} + + + {formatAlertType(selectedAlert?.type || "")} +
-
- + + + Security alert details and context information + + + + {selectedAlert && ( +

Description

@@ -249,26 +257,28 @@ export function SecurityAlertsTable({

)} + + )} -
- - {formatTimestamp(selectedAlert.timestamp)} - - {!selectedAlert.acknowledged && ( - - )} -
-
-
-
- )} + + + {selectedAlert && formatTimestamp(selectedAlert.timestamp)} + +
+ {selectedAlert && !selectedAlert.acknowledged && ( + + )} +
+
+ + ); }