Skip to content

PRD: Per-merchant scoped authorization

ModulePermissionsPRD IDPRD-EFF-001
StatusReady to devFEATEFF · BANA-1436
EpicPlaneBANA-1548
Date2026-06-04Versionv1.0
Packages@nx/identityURDEFF
SurfaceBackend
OwnerPhát Nguyễn

What per-merchant scoped authorization is

Centralizes authorization on a per-merchant policy engine so every verifier service enforces grants within the active merchant chosen per request, and resolves a user's reachable merchants/organizers from the authorization policy store instead of scattered request-context filtering. The result: "what can this user see and do here" becomes one consistent, policy-backed answer across commerce, finance, and inventory - with per-merchant isolation and soft-delete honoured.

Why centralize it

Authorization in BANA is originally driven by request-context filtering: each service derives a user's reachable organizers and merchants from the request and hand-filters its queries. This makes "what can this user see" implicit, duplicated across services, and impossible to reason about in one place - and it has no single home to resolve a grant within the active merchant a request operates in.

A central scoped-RBAC engine across the verifier services closes this gap: route-level authorization is enforced the same way everywhere through the policy engine, and HQ merchant reach is expanded from organizer/merchant membership rather than per-request guesswork. Because BANA needs soft-delete-aware, per-merchant policy loading, the platform core supplies the entity contract, the soft-delete flag, and the per-merchant domain resolver to the framework's scoped Casbin adapter - no framework change required. Inventory was the first pilot surface; coarse role grants are now seeded across every module/verifier service.

The easiest place to get it wrong

The active merchant decides scope, not the user's permissions

A user's permissions (what they can do) and the request's active merchant (where they're acting) are two different questions. A grant on a merchant only takes effect while the user is acting on that exact active merchant of the request - switching to another merchant, the grant no longer applies, even though the user is still the same person.

This is also why an Owner who owns several merchants still has to switch the active merchant on screen to act on a different one, instead of seeing every merchant's data merged together.

Proprietary and Confidential. Unauthorized copying, distribution, or use of this software is strictly prohibited.