skip to content

Compare role-based, attribute-based and relationship-based access control as ways to express permissions, and describe how you would choose between them for a multi-tenant product that supports sharing and delegation.

level: principalimportance: should knowfreq 42%

answer

  1. roles: finite, auditable, explode on data
  2. attributes: expressive, open-world reverse query
  3. relationships: sharing and listing, consistency cost
  4. tenant isolation is structural, not policy
  5. one enforcement point, one vocabulary

basics

~20 s

Roles are a closed, auditable set but explode when decisions depend on data. Attribute policies are expressive but make 'who can see this' hard to answer. Relationship models express sharing and inheritance naturally at the cost of consistency. Real systems combine: roles for coarse operations, relationships for object-level, attributes as conditions.

solid answer

~60 s

Role-based control maps principals to a finite set of roles and roles to permissions. Its strength is enumerability - you can answer 'who can do this' by listing - and its weakness is that any decision depending on the data itself becomes another role, giving role explosion. Attribute or policy-based control decides from attributes of subject, resource and environment. It expresses context - time, data classification, device posture - that roles cannot, but the reverse query becomes open-world: answering 'who can reach this record' may require evaluating the policy over every subject, and every attribute must be trustworthy and fresh. Relationship-based control stores a graph - owner, group member, parent folder - and answers both directions by traversal, which is exactly what sharing and delegation need. Its hard problem is consistency: a revoked share must not still be visible through a stale cache or replica. For that product I would use roles for coarse operation-level rules, a relationship model for object-level access including inheritance and delegation, and attribute conditions layered on top. The decisive constraint is one enforcement point and one vocabulary.

go deeper

for a junior

Define roles versus attribute conditions and give one example of each.

for a middle

Explain role explosion and why sharing and inheritance suit a relationship model.

for a senior

Reason about reverse queries, consistency of revocation, and the decision-point availability trade-off.

for a principal

Choose a layered model, keep tenant isolation structural, and standardise one enforcement point and one resource-action vocabulary across services.

## What each model actually is **Role-based.** Permissions attach to named roles; principals hold roles. The model is finite and closed, which is its whole value: access reviews, audits and 'who has this permission' are enumerations over data you own. It works well for operation-level rules that do not depend on which record is involved. **Attribute or policy-based.** A policy evaluates attributes of the subject, resource, action and environment. It expresses conditions no role can - clearance versus classification, business hours, device posture, whether the requester is in the same region as the data. The cost is that the policy is a program: reasoning about the whole system means reasoning about a program's behaviour over all inputs rather than reading a table. **Relationship-based.** Access derives from a graph of tuples: this user owns that document, this group contains that user, this folder is the parent of that file. It answers 'can this principal do this' by traversal and, importantly, also answers 'list everything this principal can see', which listing endpoints need and which policy engines are notoriously bad at. ## How the differences bite - **Role explosion.** As soon as permission depends on the record - project, tenant, region, lifecycle state - roles multiply combinatorially, and the enumerability that justified the model disappears into thousands of near-identical roles nobody can audit. - **Reverse queries.** Roles answer them by lookup, graphs by traversal, attribute policies often not at all without brute-force evaluation. If your product must show 'who has access to this file', that requirement alone constrains the model. - **Consistency.** A relationship store has a genuine ordering problem: if a share is revoked and a check reads a stale replica, access persists after the user was told it was removed. Systems that take this seriously return a consistency token from the write and require it on subsequent checks, so a decision is never made from state older than the revocation. - **Attribute trust and freshness.** An attribute policy is only as good as its inputs. If attributes arrive in a credential minted earlier, the policy is deciding on stale facts; if any attribute is client-supplied, it is not an input, it is an attack. ## The architectural split, and its cost Separating the decision point from the enforcement point lets policy be authored, versioned and tested centrally while every service enforces it. The costs are real and must be decided rather than discovered: latency on every request; an availability dependency where you must choose in advance whether enforcement fails closed and takes an outage or fails open and takes a breach; and cache staleness if you soften either. Sidecar or in-process evaluation with a distributed policy bundle trades freshness for availability; a central service trades the reverse. ## Choosing for the product described Multi-tenancy first: tenant isolation should not be a policy decision at all but a structural one, enforced by scoping data access so a cross-tenant read cannot be expressed. Layering it as one more rule in a policy engine puts your strongest boundary at the mercy of a policy bug. Above that: roles for coarse operation-level authority (billing administrator, auditor, member), because it is auditable and users understand it. A relationship model for object-level access, because sharing, folder inheritance and delegation are relationships, and modelling them as roles produces exactly the explosion described. Attribute conditions as a thin overlay for context - require a recent strong authentication for exports, deny outside permitted regions - because those are conditions on a permission rather than a source of one. ## The failure mode that actually kills systems Two half-models. Some checks in a policy engine, others hand-written in handlers, a third set implied by data scoping, and no single vocabulary for resources and actions. Then nobody can answer what a principal can do, migrations stall, and each new service invents its own dialect. Pick one enforcement architecture, name resources and actions once, and require every service to go through it - the coherence is worth more than the expressiveness of any individual model.

  • What should an enforcement point do when a central policy decision point is unreachable?
    It must be decided in advance and documented: failing closed protects data but turns a policy-service outage into a full product outage, while failing open turns it into an access-control breach. Most systems fail closed for mutations and sensitive reads, and reduce blast radius by distributing policy bundles or caching decisions for a bounded time so short outages are survivable. The point is that it is a deliberate choice with a bounded staleness window.
  • Why should tenant isolation not be expressed as one more rule in the policy model?
    Because it is the strongest boundary in a multi-tenant system, and a policy is a program that can have bugs, gaps and deployment lag. Enforcing tenancy structurally - scoping every query by tenant in the data-access layer, or in the database itself - makes a cross-tenant read unrepresentable rather than merely disallowed. Policy then handles the finer decisions inside a tenant, where a bug is contained.

saying these in an interview costs you the question

  • Presenting the models as an evolutionary ladder where the newest is simply better.
  • Ignoring the reverse query - listing what a principal can access, or who can access an object.
  • Trusting attributes that arrive from the client or from a stale credential.
  • Running two or three enforcement mechanisms in parallel with no shared vocabulary for resources and actions.

context