How it works
How Rolebook decides who can do what
Rolebook answers one question across your entire product: may this person perform this action on this item? Here is how decisions work, what stays in your app, and every package that ships with it.
- Request
- Sam Lee → edit
project "Q3 report" - Editor of Acme
- yes
- Verdict
- Allowed
- Reason
- Sam is an Editor of Acme.
One decision, three steps
Every check follows the same path across routes, background jobs, APIs, and share dialogs.
Your app identifies the caller
Pass the signed-in user and the scoped roles they hold on workspaces, projects, or folders, loaded from your database or sign-in provider.
Your app loads the target item
Load the project or document through your own tenant-scoped query, along with its parent workspace and organization.
Rolebook decides and explains
The engine evaluates your policy in-process with zero network calls, returning allow or a coded denial with the deciding rule.
Four ways to ask. One engine that answers.
Every deployment pattern evaluates the same policy with the same rules. Start in-process and combine others as your architecture grows.
rolebookIn-process library
Import the engine and run checks directly inside your TypeScript or JavaScript server with no database or network dependency.
@rolebook/serverSharing HTTP API
Serve sharing operations to React components, browser clients, and Python, Go, or Rust SDKs using your own session for authentication.
@rolebook/decision-serviceDecision service
Answer single or batch checks over HTTP for services in other languages. Your authority provider loads the facts, and failures return a typed no-decision.
@rolebook/offlineSigned offline checks
Sign everything one check needs on your server. A device verifies the signature, expiry, and rollback state, then runs the same engine offline.
Clear separation of responsibilities
Rolebook owns the permission decision. Your app stays the source of truth for identity, tenancy, and data.
Your application
- Authenticates users and tracks which organizations they belong to.
- Loads each user's scoped role assignments for the request.
- Queries items through tenant-scoped paths along with their parent chain.
- Decides what UI or HTTP response to return when access is denied.
Rolebook
- Validates, compiles, and freezes your policy once at startup.
- Evaluates every request consistently and fails closed on malformed input.
- Explains each decision with a stable code, a plain reason, and the deciding rule.
- With @rolebook/sharing: stores memberships, invitations, folder inheritance, and audit history in your own database, and streams signed webhooks.
- With PostgreSQL, SQLite, and React: filters your tables to authorized items, checks access inside write transactions, and provides accessible sharing UI.
- With the decision service and offline bundles: delivers the same answers to other services and disconnected devices.
Everything Rolebook ships
Four areas, each explained in plain words, with code where it helps and a link to the docs.
Authorization
Rules that decide every request the same way
Policies, scoped roles, conditions, field rules, explained decisions and policy checks.
- Policies, resources and actions
- Scoped roles and inheritance
- Assignments across your hierarchy
- Conditions on facts
- Field-level permissions
- A no always wins
- Closed by default, with hard limits
- Decisions that explain themselves
- Catch policy mistakes before they ship
- Expected decisions as data
- Policy diff and versions
Sharing and teams
Sharing that works the way people expect
Members, invitations, expiring access, teams, history, inspection and filtered lists.
- Share an item with people and teams
- Member roles
- Invitations
- Access that ends by itself
- Ownership transfer
- Delegation limits
- Who has access, and what can I do here
- Why can or can't this person do that
- Your own lists, showing only what each person may open
- Custom roles per customer
- Inherited folder access
- Audit history and retention
- Teams
Integrations and tools
Fits the stack you already have
PostgreSQL, SQLite, sign-in providers, React UI, webhooks, HTTP API, CLI, offline checks, and migration.
- PostgreSQL and SQLite storage
- Writes decided in the same transaction
- Better Auth, Clerk and WorkOS
- React sharing components
- Signed access-change webhooks
- The HTTP API
- A decision service for your other services
- Signed checks for devices without a connection
- One strict parser at every boundary
- Route checks in Hono, Express and Fastify
- CLI and local MCP server
- Agent skills
- Move from Casbin or a role table
- Runnable recipes
Security model
What Rolebook guarantees, and where it stops
Trust boundary, guarantees, limits, write-time checks, remote and offline checks, inspection and the adapter contract.