Scopes & RBAC
The portal has two layers of access control: scopes (coarse-grained by HTTP method) and packages (fine-grained by specific endpoint).
Layer 1: Scopes
Scopes restrict which HTTP methods a subscription can use:
| Scope | Allowed |
|---|---|
read |
GET, HEAD, OPTIONS |
write |
GET, HEAD, OPTIONS, POST, PUT, PATCH |
admin |
All including DELETE |
Scope is set per subscription and defaults to the plan’s defaultScope:
| Plan | Default scope |
|---|---|
free |
read |
professional |
write |
enterprise |
admin |
Scope enforcement example
# write-scoped key trying DELETEPOST /api/gateway/validate{ "apiKey": "ltg_live_...", "method": "DELETE", "path": "/api/service/tickets/123"}
# Response:{ "valid": false, "error": "Scope 'write' does not allow DELETE requests"}Layer 2: Package permissions
Packages define a whitelist of METHOD:path pairs. When a subscription has packages assigned, the gateway checks each request against the union of all package permissions.
Without packages (unrestricted)
Subscription → no packagesGateway: scope check only → passes if method is allowedWith packages (endpoint-level control)
Subscription → [Package A: GET /tickets, GET /tickets/{id}] [Package B: POST /tickets]
Request: GET /tickets → allowed (Package A)Request: POST /tickets → allowed (Package B)Request: DELETE /tickets → blocked (not in any package)Permission evaluation
// Effective permissions = union of all assigned package permissionsconst pkgIds = subscription.packageIds ?? [];if (pkgIds.length > 0) { const allPkgs = await packages.list(); const assignedPkgs = allPkgs.filter(p => pkgIds.includes(p.id)); const allowed = new Set<string>(); for (const pkg of assignedPkgs) { for (const perm of pkg.permissions) { allowed.add(`${perm.method.toUpperCase()}:${perm.path}`); } } const key = `${method.toUpperCase()}:${path}`; if (!allowed.has(key)) return reject(403);}Designing your permission model
Simple: one package per role
| Package | Endpoints |
|---|---|
| Read-Only | GET endpoints only |
| Helpdesk | GET + POST tickets |
| Manager | GET + POST + PUT + DELETE tickets |
Assign the single matching package per subscription.
Modular: compose from small packages
| Package | Endpoints |
|---|---|
| Tickets Read | GET /tickets, GET /tickets/{id} |
| Tickets Write | POST /tickets, PUT /tickets/{id} |
| Companies Read | GET /companies, GET /companies/{id} |
| Contacts Read | GET /contacts |
Mix and match: a subscription gets “Tickets Write” + “Companies Read” for a combined permission set.
Checking a subscription’s effective permissions
GET /api/subscriptions/:id/packagesReturns the union of all assigned packages:
{ "packageIds": ["pkg_a", "pkg_b"], "permissions": [ { "method": "GET", "path": "/api/service/tickets" }, { "method": "POST", "path": "/api/service/tickets" }, { "method": "GET", "path": "/api/company/companies" } ]}