Rendering
Tenant-scoped DAL policy
Application pattern, not a framework API. Authenticate independently; constrain tenant, role and ownership in every protected operation. Conceal missing and foreign rows under an explicit policy. Source: https://nextjs.org/docs/app/guides/authentication
Formal Syntax & Structure
nextjs syntaxnextjs
decide(principal, resource)Working Example
Example Snippetnextjs
type Principal = {id:string; tenant:string; role:'reader'|'editor'|'admin'};type Draft = {owner:string; tenant:string};function decide(p:Principal|null,d:Draft|null) { if (!p) return 'UNAUTHENTICATED'; if (!d || d.tenant !== p.tenant) return 'NOT_FOUND'; return p.role==='admin' || (p.role==='editor' && p.id===d.owner) ? 'ALLOW' : 'FORBIDDEN';}const a:Principal={id:'a',tenant:'north',role:'editor'};console.log(decide(a,{owner:'a',tenant:'north'}));console.log(decide(a,{owner:'a',tenant:'south'}));