KatInterview

Unified Permission Service for Roles and Per-Item Sharing

System DesignModel answer
MediumModel answerSystem Designauthorizationrbacacl

Last updated

Design a multi-tenant authorization service that combines scoped role assignments with per-resource grants, covering the data model, evaluation rules, APIs, caching, auditing, and tricky edge cases.

You are building the permission layer for a multi-tenant collaboration product. Content is organized as a tree of resources, for example site → space → page and site → project → issue. The layer must answer one question quickly and safely: may this user perform this action on this resource?

It must support two ways of granting access at the same time:

  • Role-based access: a user or group is assigned a named role (Admin, Editor, Viewer) that bundles a set of permissions, optionally limited to one part of the tree (for example, "Editor on Space X").
  • Resource-level grants: a specific resource can give permissions straight to a user or group (for example, one page shared with one person).

Requirements

  • Actions: read, write, delete, share, admin.
  • Works across several resource types (spaces, pages, projects, issues).
  • Principals are users and groups.
  • Provide APIs to grant access, revoke access, and check access.
  • Cover policy evaluation, the data model, caching, and audit logging.

What to deliver

  1. Core entities and a storage schema.
  2. The evaluation algorithm that turns grants into an allow/deny decision.
  3. A REST API surface.
  4. How you handle edge cases: whether deny beats allow, how inheritance down the tree works (and how it can be cut), and what happens when group membership changes.

State your assumptions about scale and latency up front and justify your design choices against them.

Hints

Hint 1

Try to treat a role assignment and a direct share as the same thing: a set of actions attached to a node in the resource tree for some principal. That makes evaluation a single walk.

Hint 2

Decide the conflict rule early (default deny, does explicit deny win, can inheritance be stopped at a node) and make sure the lockout case for administrators is handled.

Hint 3

Checks vastly outnumber changes, so think about caching the user's expanded group set and the resource's ancestor chain, and how a revocation can be made visible quickly while a grant is allowed to lag.

Hint 4

Consider the stale-read problem: someone is removed from a page, then sensitive content is added, and a cached decision still lets the removed person read it. What version or token could prevent that?