Authorization with RBAC and ReBAC
Pathrule4 Rules • 2 Memories • 1 Skill
Application authorization decides whether an authenticated principal may perform one action on one resource in one context. This bundle defines a deny-by-default decision boundary, object-level checks, role and relationship modeling, policy evolution, and adversarial tests. Unlike Auth Sessions, JWT, and OAuth, it starts after identity is known; unlike IAM and Least Privilege, it governs application resources rather than cloud administration.
Suggested path map
Pathrule places each piece on the matching path, so your assistant only sees it where it belongs. This is the scoping you get on import; you can adjust it in your workspace.
Rules
4Every protected operation asks one deny-first decision API/src/authorizationhighstrictHandlers call a central decision boundary with principal, action, resource, tenant, and trusted context before side effects begin.
| 1 | Authorization is a server-side precondition for every protected read and write, not a UI feature or a role-name convention. Route handlers, jobs, GraphQL resolvers, batch actions, and internal tools call one decision interface with the authenticated principal, canonical action, loaded resource, trusted tenant, and current policy context. Any missing input, evaluation error, or unknown action denies. |
| 2 | |
| 3 | - Resolve principal and tenant from authenticated server state, never from an unverified request field. |
| 4 | - Name actions from business capabilities such as invoice.approve rather than HTTP verbs or screen names. |
| 5 | - Return a stable allow or deny result with policy version and reason code, without leaking sensitive relationship data. |
| 6 | - Complete authorization before writes, external calls, queues, or protected response bytes. |
| 7 | |
| 8 | Verification: Remove each input, use an unknown action, inject an evaluator failure, and call the same operation through every transport; confirm all paths deny consistently. |
Memories
2Roles, attributes, and relationships solve different dimensions/src/authorizationRBAC groups stable job capabilities, ABAC adds trusted context, and ReBAC expresses resource relationships such as owner, member, parent, or viewer.
| 1 | Use roles for stable bundles of capabilities, not for every team, customer, document, or exception. Use trusted attributes for contextual conditions such as account status, region, data classification, or approved time window. Use relationships when access depends on how a principal connects to a resource through ownership, membership, hierarchy, delegation, or sharing. Complex applications usually combine these dimensions behind one decision API. |
| 2 | |
| 3 | Do not copy relationship facts into ever-growing role names or accept authorization attributes from the client. Define tuple or relation ownership, cardinality, inheritance, cycle behavior, and deletion semantics. Keep policy readable enough that product and security owners can review the intended matrix. See /src/domain for canonical resource loading and /tests/authorization for edge coverage. |
Skills
1Why this pattern
Agents scatter role-name checks through handlers, trust tenant or owner ids from requests, and authorize list pages while missing the individual object mutation path.
Built for Teams building multi-user or multi-tenant applications with role, attribute, ownership, group, hierarchy, or sharing permissions.
Keeps your assistant from:
- Authenticated users accessing another tenant's object by changing an id
- Role strings becoming an unreviewable substitute for resource policy
- Stale authorization caches preserving access after a relationship changes
- License
- Apache-2.0
- Version
- 1.0.0
- Updated
- 2026-08-25