"use client"; import { InfoBanner, SectionDivider, Toggle, } from "@/modules/settings/components/panel/controls"; import { SETTINGS_PANEL_INSET } from "@/modules/settings/components/panel/surface"; import type { SecuritySettingsDraft, SettingsBackend, } from "@/modules/settings/components/panel/types"; import type { SystemSecurityPolicy } from "@/lib/shared/contracts/system"; import { Lock } from "@/components/icons/platform-icons"; import { cn } from "@/lib/utils"; type SecuritySectionProps = { data: SettingsBackend["security"]; draft: SecuritySettingsDraft; isDemoMode?: boolean; onChange: (patch: Partial) => void; }; const selectCls = "h-8 w-36 cursor-pointer appearance-none rounded-lg border border-glass-border bg-background/55 px-3 text-xs text-foreground focus:border-primary/40 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50"; function PreferenceRow({ label, description, children, }: { label: string; description?: string; children: React.ReactNode; }) { return (
{label}
{description && (
{description}
)}
{children}
); } export function SecuritySection({ data, draft, isDemoMode = false, onChange, }: SecuritySectionProps) { const isDisabled = isDemoMode || data.isLoading || data.isSaving; if (isDemoMode) { return (

Security settings are locked

Firewall and intrusion prevention controls are disabled in demo mode.

); } return (
{data.error && ( )} {/* ── Firewall ── */}
onChange({ firewallEnabled: !draft.firewallEnabled })} disabled={isDisabled} />
{/* ── Intrusion Prevention ── */}
onChange({ fail2banEnabled: !draft.fail2banEnabled })} disabled={isDisabled} />
onChange({ fail2banMaxRetries: e.target.value })} type="number" min={1} disabled={isDisabled} className="h-8 w-36 rounded-lg border border-glass-border bg-background/55 px-3 text-xs text-foreground focus:border-primary/40 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50" /> onChange({ fail2banBanDurationSeconds: e.target.value })} type="number" min={60} disabled={isDisabled} className="h-8 w-36 rounded-lg border border-glass-border bg-background/55 px-3 text-xs text-foreground focus:border-primary/40 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50" />
); }