264e80ed73
- Move WAF config (enable, CRS, custom directives, templates) from Settings page into a new Settings tab on the WAF page - WAF page now has three tabs: Events | Suppressed Rules | Settings - Rename nav item from "WAF Events" to "WAF", route /waf-events → /waf - Fix excluded_rule_ids preservation: no longer wiped when form field is absent (Settings tab omits the hidden field intentionally) - Allow pre-adding suppressed rules even when WAF is disabled - Reorder sidebar: Overview, Proxy Hosts, Access Lists, Certificates, WAF, Analytics, Audit Log, Settings Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
53 lines
1.7 KiB
TypeScript
53 lines
1.7 KiB
TypeScript
export const dynamic = 'force-dynamic';
|
|
|
|
import WafEventsClient from "./WafEventsClient";
|
|
import { listWafEvents, countWafEvents, getWafRuleMessages } from "@/src/lib/models/waf-events";
|
|
import { getWafSettings } from "@/src/lib/settings";
|
|
import { listProxyHosts } from "@/src/lib/models/proxy-hosts";
|
|
import { requireAdmin } from "@/src/lib/auth";
|
|
|
|
const PER_PAGE = 50;
|
|
|
|
interface PageProps {
|
|
searchParams: Promise<{ page?: string; search?: string }>;
|
|
}
|
|
|
|
export default async function WafPage({ searchParams }: PageProps) {
|
|
await requireAdmin();
|
|
const { page: pageParam, search: searchParam } = await searchParams;
|
|
const page = Math.max(1, parseInt(pageParam ?? "1", 10) || 1);
|
|
const search = searchParam?.trim() || undefined;
|
|
const offset = (page - 1) * PER_PAGE;
|
|
|
|
const [events, total, globalWaf, hosts] = await Promise.all([
|
|
listWafEvents(PER_PAGE, offset, search),
|
|
countWafEvents(search),
|
|
getWafSettings(),
|
|
listProxyHosts(),
|
|
]);
|
|
|
|
const globalExcludedIds = globalWaf?.excluded_rule_ids ?? [];
|
|
const globalExcludedMessages = await getWafRuleMessages(globalExcludedIds);
|
|
|
|
const hostWafMap: Record<string, number[]> = {};
|
|
for (const host of hosts) {
|
|
const ids = host.waf?.excluded_rule_ids ?? [];
|
|
for (const domain of host.domains) {
|
|
hostWafMap[domain] = ids;
|
|
}
|
|
}
|
|
|
|
return (
|
|
<WafEventsClient
|
|
events={events}
|
|
pagination={{ total, page, perPage: PER_PAGE }}
|
|
initialSearch={search ?? ""}
|
|
globalExcluded={globalExcludedIds}
|
|
globalExcludedMessages={globalExcludedMessages}
|
|
globalWafEnabled={globalWaf?.enabled ?? false}
|
|
hostWafMap={hostWafMap}
|
|
globalWaf={globalWaf ?? null}
|
|
/>
|
|
);
|
|
}
|