import { redirect } from "next/navigation"; import { ForbiddenError } from "@raredays/core"; import { getServerSession } from "@raredays/identity/server"; import { app } from "@/lib/runtime"; export default async function ProtectedPage(): Promise { const session = await getServerSession(app); if (!session) { redirect("/"); } // Framework-owned authz: gate on a permission, not a role string, through // the permission port (framework ADR-0025) in the user's organization. const { user } = session; const allowed = await app .require("permissionProvider") .hasPermission(user, "content", "read", user.organizationId); if (!allowed) throw new ForbiddenError({ permission: "content.read" }); return (

Protected

Signed in as {session.user.email}

User id: {session.user.id}

); }