← Back to Next.js SaaS foundation team
See how it helps
1. Evaluate
4. Honest Error Semantics (
Workspace roles and authorization
Defines workspace permissions as a combination of identity, membership, resource ownership and subscription capability checked on the server.
workspace-roles-authorization
Team members using this skill
When is it useful?
Use it when roles alone cannot explain who may access private projects, billing or plan-restricted features.
What does it help you do?
- Separates platform roles, membership, resource scope and plan entitlements.
- Checks actor, action and the full resource ownership chain.
- Uses explicit server-side capabilities rather than scattered role names.
Try asking this
Allow a workspace billing member to view invoices without editing private projects. Open billing invoices and a guessed private-project URL with the same role. Invoice access should succeed while project reads and mutations are denied server-side.
Detailed documentation
Read the skill’s original instructions, examples and checks in their authored language.
Show less
Workspace Roles & Authorization
When to Use
Use when designing or auditing role-based (RBAC) or attribute/resource-based (ABAC) access control inside multi-tenant workspaces.
Four Orthogonal Authorization Planes
Never conflate these four distinct concepts into a single role check:
- Platform / Global Identity Role: Whether the actor is a normal SaaS user or an internal platform operator (e.g.,
platform_supportvia explicit audited break-glass flow). A global admin flag should never silently bypass normal workspace UI boundaries without explicit elevation. - Workspace Membership Role: The user's role within the active workspace (
owner,admin,member,billing,viewer,guest), stored onworkspace_memberships(workspace_id, user_id, role). - Resource-Level Scope / Ownership: Fine-grained access within a workspace (e.g., private project membership, creator of a comment, guest restricted to a single channel/folder, or scoped API key permissions).
- Workspace Plan Entitlement: Whether the workspace's subscription includes a capability (
sso_enabled,custom_roles,max_projects). Even a workspaceownercannot use a feature the workspace's plan does not entitle, and aviewercannot mutate settings even on anEnterpriseplan!
Server-Side Policy Enforcement Rules
1. Evaluate (Actor, Membership, Action, TargetResource) Together
Every protected operation must evaluate:
authorize({
actor, // Authenticated user or API key principal
membership, // Verified active membership in target workspace
action: 'project.delete',
resource: project, // Loaded from DB with resource.workspaceId === membership.workspaceId
});
- Never check only
membership.role === 'admin'while loadingProject.findById(req.params.id)without verifyingproject.workspaceId === membership.workspaceId! - For child resources (
task$\rightarrow$project$\rightarrow$workspace), verify that the entire parent chain belongs to the same workspace.
2. Explicit Permission Capabilities Over Scattered Role Strings
- Map roles (
owner,admin,member,viewer) to explicit capability permissions (workspace:delete,members:invite,members:remove,billing:manage,project:create,project:write,project:read). - Enforce role hierarchy invariants on member management:
- An
admincannot remove anowner, promote themselves or anyone else toowner, or modify anowner's role. - A member cannot grant a role or API-key scope higher than the permissions they currently hold (privilege escalation prevention).
- An
3. Scoped Workspace API Keys & Service Accounts
- Bind workspace API keys and incoming webhooks explicitly to a single
workspace_idwith an explicit permission scope (read:projects,write:tasks) and expiration/revocation support. - Never issue a user-global API key that implicitly grants access to every workspace the user joins in the future unless explicitly scoped and consented per workspace.
4. Honest Error Semantics (403 vs. 404 vs. Empty List)
- For resources belonging to another workspace, return
404 Not Foundso cross-tenant resource IDs cannot be enumerated. - Within the same workspace, when an authenticated
viewerattempts an unauthorized mutation (POST/DELETE), return an explicit403 Forbiddenwith a clear domain error—never silently return200 OKor an empty array that misleads the UI into thinking the action succeeded or data was deleted.
Included files 1
SKILL.md
