You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(web): Zanzibar RBAC with SpiceDB schema, Postgres tuples, and roles API (Closes#180)
Replace the legacy hardcoded role checks in lib/rbac.ts with a
relationship-based Zanzibar model:
- lib/zanzibar/schema.ts + schema.zed: SpiceDB model (merchant owner/editor/
viewer relations; group#member aggregation; view_payments, edit_merchant,
manage_team, manage_billing, delete_merchant permissions).
- lib/zanzibar/store.ts: delegating client — checks SpiceDB over HTTP
(edge-safe, fetch-based) or falls back to a Postgres-backed store on the
new role_tuples table (FORCE RLS like payments, so tuples can't leak across
tenants).
- migrations/007_role_tuples.sql + ensureSchema: the role_tuples table.
- lib/zanzibar/permissions.ts: authorize()/can() helpers for App Router
routes (401/403).
- app/api/roles: GET lists a merchant's roles (view_dashboard); POST grants/
revokes owner/editor/viewer + group#member (manage_team).
- middleware.ts: forward the verified session's Stellar address as
x-accensa-merchant and x-accensa-sub so routes and authz checks share one
trusted identity.
- payments/route.ts: wire view_payments enforcement behind ACCENSA_ENFORCE_RBAC=1.
- DEPLOYMENT.md: RBAC/SpiceDB provisioning, cut-over, and env vars.
- Tests for the DB store + schema helpers + roles route.
0 commit comments