/be:access-controlfrom Backend Skills
Access control for a Next.js API on Firebase — roles, relationships and attributes (RBAC, ReBAC, ABAC) behind permission verbs and one pure can(); guards as the only gate, 404 before 403; tenant scoping; invitations; escalation limits; two-person approval and access reviews; stale claims; API-key scopes; share links and passcodes; where plan and flag checks sit; UI gates that only hide; and tests. Use when adding a permission, role, guarded route, API key, share link, or a control only some people see.
Ships in Backend Skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Who may do what is decided by permission verbs, never role names. Roles, relationships, API keys and share links all resolve to verbs; one pure function answers every question; the API's guards are the only place the answer protects anything. Moving a capability between roles is then one line in the map, and every guard and button follows it.
Before applying this skill, read the project's root AGENTS.md, the AGENTS.md closest to the files in question, and any doc they link for this skill's topic. Names, values and choices — budgets, tiers, tokens, voice, paths — come from those files, never from this skill.
OWASP prefers relationship- and attribute-based checks to bare roles for applications, because a role alone can't say whose resource. The house model is all three, in their places:
An operator holds no resource verbs. They act on customers' resources through the operator routes, with operator verbs, audited as operator actions — never by borrowing a member's role.
Shape scope.resource.action — admin.user.suspend, project.member.invite; multi-word resources hyphenated (feature-flag).
A fixed action vocabulary, kept at the top of the permissions file:
| Group | Actions |
|---|---|
| Read | view · list · search · report · export |
| Change | create · update · delete · duplicate |
| Relationships | invite · add · remove (remove detaches; delete destroys) |
| Lifecycle | publish/unpublish · archive/unarchive · suspend/unsuspend · cancel |
| Approval | approve · reject · request |
| Escape hatch | perform — only when nothing above fits |
Every reverse action is its own verb, so grants and audit entries can tell the directions apart.
One registry — every verb in one constants file, typed as a union, in the shared contracts. An inline string is a bug.
Set of verbs, in the shared contracts beside the verbs.can(actor, permission) is pure — no reads, no side effects — so the API, the UI and the tests run the same predicate. canAll and canAny wrap it. The actor is { platformRoles?, resourceRole?, scopes? }, built by the guard; a key's or link's scopes are verbs it was granted directly.The guard is the only real gate; nothing upstream checks again, and the UI only hides.
| The route acts on | Guard |
|---|---|
| A platform resource (operator routes) | requirePermission(request, verb) — session, claims, can(); audits a denial |
| One resource or anything under it | load<Resource>WithPermission(request, id, verb) — session, load, resolve the role, can() |
| A resource whose role is already loaded | require<Resource>Permission(request, verb, role) |
| A second verb in the same handler | requireActor(actor, verb) — against the actor in hand, without verifying the token again |
| The caller's own record | requireSession(request) — no permission; there's no one else's to protect (auth) |
.pick() allowlist, so a role can't be set through a profile update); a response returns only what that caller may see (schemas-and-contracts).ForbiddenError, NotFoundError) that errorResponse maps; a guard never returns a boolean a route might ignore (api-architecture).A key lets a customer's own scripts and integrations call the API. Issuing, storing and revoking it is auth's; what it may do is here:
can(), so every route that takes keys reuses its existing guard. Operator routes never accept a key.rate-limiting), and their actions are audited with the key's id as the actor.A link or code grants access to whoever holds it. Following the W3C's capability-URL guidance, except where Google's noindex rule overrides it:
GET never triggers an action.rate-limiting); a correct code sets a short-lived cookie for that resource only, so the code isn't sent again.Referrer-Policy: no-referrer, loads no third-party scripts, and is noindex (a meta tag and X-Robots-Tag) — never disallowed in robots.txt. The W3C note suggests listing the links' path there, but Google never reads a noindex on a page it's blocked from crawling, so a blocked link can still be indexed from links elsewhere (seo-aeo-geo).Access control answers "may this caller do this?". Two other checks answer different questions and come after it, each with its own error code so the UI can tell "you can't" from "your plan doesn't include this":
plan-entitlements).A feature that's switched off answers as if the route didn't exist, before any of these (feature-flags).
audit-log).How a person gains a resource role:
Claims are a cache of the stored roles, never the record:
setCustomUserClaims, awaited in the request; keep claims small (Firebase caps them at 1,000 bytes).auth); a role taken away revokes the person's sessions, because waiting for expiry leaves the old powers live.can() on an actor built from the session (and the resource role the page resolved), through a usePermission hook and a small gate component that renders its children only when the verb holds.Where clients read the store directly, the security rules mirror the same model — default-deny, ownership and membership checked in the rule, role fields immutable to clients (firestore). Where every read and write goes through the API, the rules deny clients entirely.
testing).can() pure; resolve resource roles per request; load before checking so a hidden id is a 404; take ownership from the record and identity from the token; scope queries by tenant; revoke sessions when a role is removed; make links unguessable, expiring and revocable; test every verb both ways.Sessions, claims and key issuing auth · plan checks plan-entitlements · flags feature-flags · attempt limits rate-limiting · the route the guard sits in api-architecture · field allowlists and projections schemas-and-contracts · security rules firestore · server threats backend-security · tests testing · the audit access-control-audit.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub timonwa/engineering-skills --plugin be22 skills in this plugin
/access-control-auditManually invoked. Access-control audit — guards on every route and Server Action (BFLA), 404 before 403 and tenant scoping (BOLA), allowlisted writes and projected reads (BOPLA), verbs never role names, roles that add up, escalation and invitations, claims and revocation, sessions and sign-in, API keys and share links, the plan and flag order, UI gates, data rules and the tests. Verifies each finding and writes a prioritised report./api-architectureHow an API route is built in a Next.js API — the fixed order of rate limit, authorise, validate, delegate, audit, respond; thin routes over services; the response envelope and typed errors; caching headers; concurrent edits; long-running work; cursor pagination and allowlisted sorts; resource paths, versions, deprecation and state-transition sub-routes; and what every new route ships with. Cron, webhooks and audit logs are references. Use when adding, changing or reviewing a route handler or the API layer's structure./api-auditManually invoked. API-layer audit — the six-step route, thin routes over services, validation at every boundary, the envelope, typed errors and no-store, concurrent edits and long-running work, a named rate limit on every route, cursor lists, versions and transitions, the audit log, each route's reference entry and test, cron, webhook and proxy rules, and where present maintenance mode, flags, plan entitlements, outgoing webhooks and email sending. Verifies each finding and writes a prioritised report.Other plugins' skills for the same job