diff --git a/frontend/src/components/settings/SettingsPage.tsx b/frontend/src/components/settings/SettingsPage.tsx index dbe9713..83a5c0f 100644 --- a/frontend/src/components/settings/SettingsPage.tsx +++ b/frontend/src/components/settings/SettingsPage.tsx @@ -5,7 +5,7 @@ import { useAuth, isSuperAdmin, isTenantAdmin } from '@/lib/auth' import { authApi } from '@/lib/api' import { getSMTPSettings, updateSMTPSettings, testSMTPSettings, clearWinboxSessions } from '@/lib/settingsApi' import { SMTP_PRESETS } from '@/lib/smtpPresets' -import { User, Shield, Info, Key, Lock, ChevronRight, Download, Trash2, AlertTriangle, Mail, Monitor } from 'lucide-react' +import { User, Shield, Info, Key, KeyRound, Lock, ChevronRight, Download, Trash2, AlertTriangle, Mail, Monitor } from 'lucide-react' import { Button } from '@/components/ui/button' import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog' import { Input } from '@/components/ui/input' @@ -150,6 +150,23 @@ export function SettingsPage() { )} + {/* Credential Profiles */} + {isTenantAdmin(user) && ( +
+ + +
+ Credential Profiles +

Manage shared credentials for RouterOS and SNMP devices

+
+ + +
+ )} + {/* Maintenance — super_admin only */} {isSuperAdmin(user) && (
diff --git a/frontend/src/routes/_authenticated/settings.credentials.tsx b/frontend/src/routes/_authenticated/settings.credentials.tsx new file mode 100644 index 0000000..9a7f809 --- /dev/null +++ b/frontend/src/routes/_authenticated/settings.credentials.tsx @@ -0,0 +1,46 @@ +import { createFileRoute } from '@tanstack/react-router' +import { ShieldAlert, Building2 } from 'lucide-react' +import { useAuth, isSuperAdmin, isTenantAdmin } from '@/lib/auth' +import { useUIStore } from '@/lib/store' +import { CredentialProfilesPage } from '@/components/settings/CredentialProfilesPage' + +export const Route = createFileRoute('/_authenticated/settings/credentials')({ + component: CredentialProfilesRoute, +}) + +function CredentialProfilesRoute() { + const { user } = useAuth() + const { selectedTenantId } = useUIStore() + + const tenantId = isSuperAdmin(user) ? (selectedTenantId ?? '') : (user?.tenant_id ?? '') + + // RBAC: only tenant_admin+ can manage credential profiles + if (!isTenantAdmin(user)) { + return ( +
+
+ +

Access Denied

+

+ You need tenant admin or higher permissions to manage credential profiles. +

+
+
+ ) + } + + return ( +
+ {!tenantId ? ( +
+ +

+ Select an organization from the sidebar to manage credential profiles. +

+
+ ) : ( + + )} +
+ ) +}