Backend Authorization
Purpose
Design how the backend decides who may do what — as distinct, layered checks, each enforced server-side on every protected operation. This is the umbrella skill; role-permission-design and ownership-authorization detail the models.
When to Use
- When any endpoint or operation must be restricted.
- Not for identity itself (
backend-authentication) or abuse throttling (rate-limiting) — a rate limit is not an access decision.
Inputs
- Auth session/claims design (
backend-authentication).
- Endpoint inventory with sensitivity (
rest-api-design / graphql-api-design).
- Domain model: owners, organizations/tenants, shared resources.
Discovery Questions
- Which of these does the system actually need — and which does each endpoint need?
- Authentication — is the caller identified at all?
- Role authorization — does the caller's role permit this action class (admin vs user)?
- Permission authorization — does the caller hold the specific permission (finer than role)?
- Ownership authorization — does the caller own this resource?
- Organization/tenant scope — is the resource inside the caller's org/tenant?
- Object-level authorization — per-object rules beyond ownership (shared-with, state-dependent access)?
- Where is each check enforced (guard/middleware vs service vs query)?
- What happens on failure — 403, or 404 to hide existence?
Responsibilities
- Classify every protected endpoint by which of the six levels apply — most non-trivial endpoints need authentication + one of role/permission + one of ownership/tenant/object.
- Place enforcement: coarse checks (authenticated, role/permission) at the edge (guard/middleware); resource-bound checks (ownership, tenant, object) in the service/query where the resource is loaded (
ownership-authorization).
- Centralize decision logic (policy functions/guards) — no scattered
if (user.role === 'admin') in handlers.
- Define failure behavior per resource class (403 vs existence-hiding 404) with
backend-error-handling.
- Require negative tests for every protected operation:
- User A cannot read/update/delete User B's resource.
- Non-admin cannot invoke an admin action.
- Client-supplied ownership/tenant IDs are ignored — scope derives from the session.
- Cross-tenant access is rejected even with a valid, guessed ID.
Required Workflow
- Build the endpoint × authorization-level matrix.
- Design the role/permission model (
role-permission-design).
- Design ownership/tenant/object checks (
ownership-authorization).
- Fix enforcement placement + failure responses.
- Specify the negative-test suite; wire into
backend-integration-testing.
Decision Rules
- Every protected operation names its levels explicitly; "it's behind login" is level 1 only and usually insufficient.
- Role/permission checks never substitute for ownership/tenant checks — an authenticated user with the right role can still only touch their data unless the model says otherwise.
- Deny by default: an endpoint without a recorded authorization decision is a defect.
- UI hiding (client packs) is convenience; the server check is the boundary.
Rules
- Authorization derives from server-side session/claims — never from client-supplied role, user ID, or org ID fields.
- One policy home per rule; duplicated checks drift.
- Every new endpoint lands with its negative tests, not after.
Anti-Patterns
- Treating "authenticated" as "authorized."
- Role checks only, no ownership/tenant check on resource access (IDOR/BOLA).
- Authorization logic copy-pasted across handlers.
- Trusting
body.userId / body.orgId for scoping.
- Confusing rate limiting or CAPTCHA with authorization.
Validation Checklist
Definition of Done
A recorded authorization design: per-endpoint level matrix, centralized enforcement with placement, failure behavior, and a negative-test suite covering cross-user, role-escalation, untrusted-ID, and cross-tenant cases.
Related Skills
backend-authentication, role-permission-design, ownership-authorization, backend-integration-testing, backend-error-handling, ../../security-review, graphql-api-design (resolver-level enforcement).
Related Knowledge
../../../knowledge/ (roles, tenancy model, sharing rules).
Related References
../../../references/backend/auth/ (authorization matrix, when populated).
Context Loading Guidance
- Requires: session/claims design, endpoint inventory, tenancy/ownership model.
- Does not require: login flow internals, UI gating.
- May load:
role-permission-design, ownership-authorization.
- Stop when: matrix, placement, and negative tests are recorded.
Token Efficiency Guidance
The endpoint × level matrix is the deliverable — build it and let the two specialist skills carry model detail.
1---2name: backend-authorization3description: Use to plan backend authorization — who may do what. Distinguishes authentication, role authorization, permission authorization, ownership authorization, organization/tenant scope, and object-level authorization; enforces centrally per endpoint and requires negative tests.4---56# Backend Authorization78## Purpose910Design how the backend decides **who may do what** — as distinct, layered checks, each enforced server-side on every protected operation. This is the umbrella skill; `role-permission-design` and `ownership-authorization` detail the models.1112## When to Use1314- When any endpoint or operation must be restricted.15- **Not** for identity itself (`backend-authentication`) or abuse throttling (`rate-limiting`) — a rate limit is not an access decision.1617## Inputs1819- Auth session/claims design (`backend-authentication`).20- Endpoint inventory with sensitivity (`rest-api-design` / `graphql-api-design`).21- Domain model: owners, organizations/tenants, shared resources.2223## Discovery Questions2425- Which of these does the system actually need — and which does each endpoint need?26 1. **Authentication** — is the caller identified at all?27 2. **Role authorization** — does the caller's role permit this action class (admin vs user)?28 3. **Permission authorization** — does the caller hold the specific permission (finer than role)?29 4. **Ownership authorization** — does the caller own *this* resource?30 5. **Organization/tenant scope** — is the resource inside the caller's org/tenant?31 6. **Object-level authorization** — per-object rules beyond ownership (shared-with, state-dependent access)?32- Where is each check enforced (guard/middleware vs service vs query)?33- What happens on failure — 403, or 404 to hide existence?3435## Responsibilities3637- Classify every protected endpoint by which of the six levels apply — most non-trivial endpoints need authentication + one of role/permission + one of ownership/tenant/object.38- Place enforcement: coarse checks (authenticated, role/permission) at the edge (guard/middleware); resource-bound checks (ownership, tenant, object) in the service/query where the resource is loaded (`ownership-authorization`).39- Centralize decision logic (policy functions/guards) — no scattered `if (user.role === 'admin')` in handlers.40- Define failure behavior per resource class (403 vs existence-hiding 404) with `backend-error-handling`.41- Require **negative tests** for every protected operation:42 - User A cannot read/update/delete User B's resource.43 - Non-admin cannot invoke an admin action.44 - Client-supplied ownership/tenant IDs are ignored — scope derives from the session.45 - Cross-tenant access is rejected even with a valid, guessed ID.4647## Required Workflow48491. Build the endpoint × authorization-level matrix.502. Design the role/permission model (`role-permission-design`).513. Design ownership/tenant/object checks (`ownership-authorization`).524. Fix enforcement placement + failure responses.535. Specify the negative-test suite; wire into `backend-integration-testing`.5455## Decision Rules5657- Every protected operation names its levels explicitly; "it's behind login" is level 1 only and usually insufficient.58- Role/permission checks never substitute for ownership/tenant checks — an authenticated user with the right role can still only touch *their* data unless the model says otherwise.59- Deny by default: an endpoint without a recorded authorization decision is a defect.60- UI hiding (client packs) is convenience; the server check is the boundary.6162## Rules6364- Authorization derives from server-side session/claims — never from client-supplied role, user ID, or org ID fields.65- One policy home per rule; duplicated checks drift.66- Every new endpoint lands with its negative tests, not after.6768## Anti-Patterns6970- Treating "authenticated" as "authorized."71- Role checks only, no ownership/tenant check on resource access (IDOR/BOLA).72- Authorization logic copy-pasted across handlers.73- Trusting `body.userId` / `body.orgId` for scoping.74- Confusing rate limiting or CAPTCHA with authorization.7576## Validation Checklist7778- [ ] Endpoint × level matrix recorded (all six levels considered).79- [ ] Enforcement placement fixed (edge vs service/query).80- [ ] Failure behavior (403 vs 404) decided per resource class.81- [ ] Policy logic centralized.82- [ ] Negative tests specified: cross-user, non-admin→admin, client-supplied IDs untrusted, cross-tenant rejected.8384## Definition of Done8586A recorded authorization design: per-endpoint level matrix, centralized enforcement with placement, failure behavior, and a negative-test suite covering cross-user, role-escalation, untrusted-ID, and cross-tenant cases.8788## Related Skills8990`backend-authentication`, `role-permission-design`, `ownership-authorization`, `backend-integration-testing`, `backend-error-handling`, `../../security-review`, `graphql-api-design` (resolver-level enforcement).9192## Related Knowledge9394`../../../knowledge/` (roles, tenancy model, sharing rules).9596## Related References9798`../../../references/backend/auth/` (authorization matrix, when populated).99100## Context Loading Guidance101102- **Requires:** session/claims design, endpoint inventory, tenancy/ownership model.103- **Does not require:** login flow internals, UI gating.104- **May load:** `role-permission-design`, `ownership-authorization`.105- **Stop when:** matrix, placement, and negative tests are recorded.106107## Token Efficiency Guidance108109The endpoint × level matrix is the deliverable — build it and let the two specialist skills carry model detail.