import { Switch } from "@/components/ui/switch"; import { Textarea } from "@/components/ui/textarea"; import { Checkbox } from "@/components/ui/checkbox"; import { Badge } from "@/components/ui/badge"; import { cn } from "@/lib/utils"; import { useState } from "react"; import { Users, UserCheck } from "lucide-react"; import { ProxyHost } from "@/lib/models/proxy-hosts"; type UserEntry = { id: number; email: string; name: string | null; role: string; }; type GroupEntry = { id: number; name: string; description: string | null; member_count: number; }; type ForwardAuthAccessData = { userIds: number[]; groupIds: number[]; }; export function CpmForwardAuthFields({ cpmForwardAuth, users = [], groups = [], currentAccess, }: { cpmForwardAuth?: ProxyHost["cpmForwardAuth"] | null; users?: UserEntry[]; groups?: GroupEntry[]; currentAccess?: ForwardAuthAccessData | null; }) { const initial = cpmForwardAuth ?? null; const [enabled, setEnabled] = useState(initial?.enabled ?? false); const [selectedUserIds, setSelectedUserIds] = useState(currentAccess?.userIds ?? []); const [selectedGroupIds, setSelectedGroupIds] = useState(currentAccess?.groupIds ?? []); function toggleUser(id: number) { setSelectedUserIds((prev) => prev.includes(id) ? prev.filter((x) => x !== id) : [...prev, id] ); } function toggleGroup(id: number) { setSelectedGroupIds((prev) => prev.includes(id) ? prev.filter((x) => x !== id) : [...prev, id] ); } const allUsers = users; return (
{enabled && selectedUserIds.map((id) => ( ))} {enabled && selectedGroupIds.map((id) => ( ))}

CPM Forward Auth

Require users to authenticate via Caddy Proxy Manager before accessing this host