KatInterview

Access Control System With Caching and Revocation Guarantees

System DesignModel answer
MediumModel answerSystem Designrbacauthorizationcaching

Last updated

Design an RBAC authorization service handling fast permission checks, role inheritance, scoped assignments, and bounded revocation delay.

You're designing an authorization service that many applications will query to enforce access control. The service manages roles, permissions, and assignments, then answers whether a given principal can perform an action on a resource.

Your design should address:

Core Model

  • Permissions represent actions on resource types (e.g., "documents:read", "projects:delete")
  • Roles bundle permissions and can inherit from other roles
  • Principals (users, service accounts) receive role assignments
  • Assignments may be scoped to tenants, projects, or specific resources
  • The system denies access by default

Operations

  • Administrative: create/modify roles, assign/revoke roles, manage role hierarchies
  • Runtime: checkPermission(principal, action, resource) returns allow/deny

Requirements

  • Permission checks must be fast (single-digit milliseconds) since they're on every protected request
  • Revocations must take effect within a bounded time window
  • The system should remain available even when the central authority is unreachable
  • All administrative changes and access denials need audit trails

Discussion Points

  1. How do you model the entities and relationships? What data structures support efficient evaluation?
  2. How do you achieve low-latency checks while ensuring revocations propagate within your time bound?
  3. What happens when the authorization service is down or slow?
  4. How do you prevent administrator mistakes from causing widespread outages?
  5. What observability and debugging tools does the system need?

Consider role inheritance cycles, the cost of scope matching, cache invalidation strategies, and the tension between availability and security.

Hints

Hint 1

Model inheritance as a directed acyclic graph and pre-compute the transitive closure of permissions when roles change, not during every check

Hint 2

Cache compiled permission sets per principal at the application layer with TTL-based expiration; your TTL becomes your revocation bound

Hint 3

Design for explicit fail-open or fail-closed behavior per resource type, and log every failure mode separately for alerting