Lion Cipher Lab

Enforce multi-tenant RBAC with Casbin (RBAC with domains) -- and test it like code

Why it matters

Broken access control is the top risk in both the OWASP Top 10 and the OWASP API Security Top 10, and multi-tenant software (one app serving many customer companies) turns a small authorization slip into one customer reading another customer's data. Libraries like Casbin make the rules short and readable, but a single missing clause in the rules, or a single route that never asks the library, quietly reopens the hole. This lab teaches the habit that actually prevents that: a table of expected decisions you run like any other test, so a leak shows up as a red test before it ships.

What you'll learn

Steps in this lab

  1. What you are building, and the words you need
  2. Set up: open a terminal, check Python, install pycasbin
  3. Write the model: model.conf, one section at a time
  4. Write the policy: two tenants that deliberately differ
  5. Write the test table and run it: 39 decisions, green
  6. Bug 1: a matcher that forgets r.dom == p.dom
  7. Bug 2: role definition g = _, _ (the domain silently vanishes)
  8. Bug 3: path matching surprises (keyMatch vs keyMatch2 vs regexMatch)
  9. The bug Casbin cannot see: a route that never asks
  10. The policy store is part of the attack surface
  11. When Casbin fits, and when OPA, Cedar or OpenFGA fit better
  12. Honest negatives, and the habit to keep

Open the full interactive lab →