ABAC (attribute-based access control)
ABAC, attribute-based access control, decides whether a person may perform an action by checking attributes of the person, the record, the action and sometimes the environment against rules. In a business app those attributes are things like whose record it is and which status it is in, and Meadowstack 2.1 writes them as conditions on the record in the same `domain/permissions.ts` that holds the roles.
By Bohuslav PoláčekChecked
export function canFor(person: Person): CanFn {
return (action, subject) => {
if (!roleActions[person.role].includes(action as Action)) return false;
const request = subject as PurchaseRequest | undefined;
// Without a record the question is "may this person ever do it" (show the "New request" button?).
if (!request) return true;
const mine = request.requesterId === person.id;
switch (action) {
case "request.read":
case "request.comment":
return request.status !== "draft" || mine || person.role === "admin";
case "request.edit":
case "request.submit":
return (request.status === "draft" || request.status === "rejected") && (mine || person.role === "admin");
case "request.withdraw":
return request.status === "submitted" && mine;
case "request.delete":
return request.status === "draft" && (mine || person.role === "admin");
case "request.approve":
case "request.reject":
return request.status === "submitted" && !mine;
case "request.reopen":
return (request.status === "approved" || request.status === "rejected") && request.decidedById === person.id;Why it matters in a business app
Roles answer "may approvers approve?". They cannot answer "may Dana approve this request?", because the answer depends on the request: Dana wrote it, it is still a draft, someone else already decided it. Those are attributes of the record, and the rules that read them are where most real permission bugs live: a person editing a request after it was approved, or reading a colleague's draft.
NIST's guide to ABAC (SP 800-162) describes the same idea in general terms: subject, object, operation and environment attributes checked against policy.
How Meadowstack handles it
In 2.1 the record rules sit right after the role check in one function, canFor(person), which returns the can(action, record) every screen asks:
| Action | Attribute it reads |
|---|---|
request.read | the status (a draft is private) and the requester |
request.edit, request.submit | the status is draft or rejected, and the person wrote it or is an admin |
request.withdraw | the status is submitted, and the person wrote it |
request.approve, request.reject | the status is submitted, and the person did not write it (four-eyes) |
request.reopen | the person is the one who decided |
Asked without a record, can("request.create") answers "may this person ever do it", which decides whether the button shows. The same conditions appear again in the Supabase example's policies and trigger (row-level security); in 2.1 keeping the server side in step is your job, and Meadowstack 3.0, coming as an update to every licence, generates the database policies from one policy file.
Common mistakes
- A new role for every exception. "Approver who may not approve their own" is not a role; it is a condition on the record.
- Checking the attribute the browser sent. The requester and the status come from the stored record, never from the request body.
- Forgetting the status. An edit rule without a status check lets people change a request after it was approved.
- Rules spread across components. One function per module, tested (
test/permissions.test.tsin the starter), is what keeps them readable.
Questions
Is ABAC better than RBAC?
Neither replaces the other in a typical business app. Roles give the broad lines that people understand, and attributes of the record handle ownership, status and four-eyes. The starter does exactly that: roles first, then the record.
Do I need a policy engine for ABAC?
Not for most business apps. A plain function per module that reads the person and the record covers ownership and status rules, and the same conditions can be written as database policies.
What counts as an environment attribute?
Conditions outside the person and the record, such as the time of day or the network a request comes from. The starter's rules use none; a rule like that belongs on the server, where the time and the network can be trusted.
Two ways
Build it yourself, or have it built
Build it yourself
Build your app on the framework
Get the codebase these apps stand on and build yours with Claude Code, Cursor or Codex.
One payment, lifetime updates
Get the frameworkHave it built
Have us build your app
Tell us how your team works. We plan the app with you and build it on the same framework at a fixed price.
After launch, Care keeps it improving, from €99 a month.
from €1,990
Describe your app