Rolebook

Roles and permissions

Consistent roles across every workspace

Define what an Admin, Editor, or Viewer can do once in TypeScript. Enforce the same policy across routes, APIs, background jobs, and UI.

Sort:
Which permissions each role has
ViewEditShareDelete

3 of 4 permissions

Pick a square to see why.

01 · Roles and permissions

Scoped to workspaces and items

Assign roles where they belong. Someone can be a Viewer in one workspace and an Editor on a single project inside it.

  • Sam in workspace Acme · Viewer

    Sam in workspace Acme · Viewer: View allowed, Edit not allowed, Share not allowed, Delete not allowed.

  • Sam in project Q3 report · Editor

    Sam in project Q3 report · Editor: View allowed, Edit allowed, Share allowed, Delete not allowed.

02 · Roles and permissions

Customer-defined custom roles

Let enterprise tenants create custom roles bounded by a template you control, so custom roles can never exceed their baseline.

  • Admin

    Admin: View allowed, Edit allowed, Share allowed, Delete allowed.

  • Editor

    Editor: View allowed, Edit allowed, Share allowed, Delete not allowed.

  • Reviewer (custom, from Editor)

    Reviewer (custom, from Editor): View allowed, Edit not allowed, Share allowed, Delete not allowed.

03 · Roles and permissions

Explicit denies always win

Deny rules evaluate before allow rules across direct roles, inherited roles, and teams. One block overrides every allow.

Sam Lee has both roles

  • Admin

    Admin: View allowed, Edit allowed, Share allowed, Delete allowed.

  • Contractor

    Contractor: View allowed, Edit allowed, Share not allowed, Delete blocked.

Sam Lee → delete: Denied

For developers

Type-safe roles that live in your repository

Define resources, actions, and roles in TypeScript. Rolebook validates and freezes the policy once at startup.

Read the docs
policy.ts
import { definePolicy } from "rolebook";

export const policy = definePolicy({
  resources: {
    organization: { actions: ["read"] },
    workspace: { parent: "organization", actions: ["read", "update"] },
    project: { parent: "workspace", actions: ["read", "update", "delete"] },
  },
  roles: {
    workspace_viewer: {
      scope: "workspace",
      rules: [{ effect: "allow", permission: "project:read" }],
    },
    workspace_editor: {
      scope: "workspace",
      inherits: ["workspace_viewer"],
      rules: [
        {
          effect: "allow",
          permission: "project:update",
          where: { fact: "resource.ownerId", operator: "equals", value: { fact: "subject.id" } },
        },
      ],
    },
    contractor: {
      scope: "workspace",
      rules: [{ effect: "deny", permission: "project:delete" }],
    },
  },
});

Ship enterprise-ready access control from day one.

Allow wisely.