API Route RBAC Enforcement protects workspace-scoped resources by requiring valid membership before allowing access to any workspace endpoints.Documentation Index
Fetch the complete documentation index at: https://docs.praison.ai/llms.txt
Use this file to discover all available pages before exploring further.
Quick Start
How It Works
| Component | Responsibility |
|---|---|
| require_workspace_member | FastAPI dependency that enforces workspace membership |
| MemberService.has_role() | Database query to verify user’s workspace membership and role |
| AuthIdentity | Enhanced with workspace_id for downstream route handlers |
| 403 Forbidden | Returned to non-members attempting workspace access |
Implementation Details
RBAC Dependency
Therequire_workspace_member dependency replaces get_current_user in all workspace-scoped routes:
Dependency Configuration
Role Hierarchy
Protected Routes
All workspace-scoped API routes now enforce membership:Core Resources
| Route Pattern | Enforcement | Minimum Role | Notes |
|---|---|---|---|
GET /workspaces/{id} | ✅ | member | |
PATCH /workspaces/{id} | ✅ | admin | |
DELETE /workspaces/{id} | ✅ | owner | |
GET /workspaces/{id}/members | ✅ | member | |
POST /workspaces/{id}/members | ✅ | admin | Extra check: owner required for admin/owner roles |
PATCH /workspaces/{id}/members/{user_id} | ✅ | admin | |
DELETE /workspaces/{id}/members/{user_id} | ✅ | admin |
Project Management
| Route Pattern | Enforcement | Minimum Role |
|---|---|---|
GET /workspaces/{id}/projects/ | ✅ | member |
POST /workspaces/{id}/projects/ | ✅ | member |
PATCH /workspaces/{id}/projects/{pid} | ✅ | member |
DELETE /workspaces/{id}/projects/{pid} | ✅ | admin |
Issue Tracking
| Route Pattern | Enforcement | Minimum Role |
|---|---|---|
GET /workspaces/{id}/issues/ | ✅ | member |
POST /workspaces/{id}/issues/ | ✅ | member |
GET /workspaces/{id}/issues/{iid} | ✅ | member |
PATCH /workspaces/{id}/issues/{iid} | ✅ | member |
DELETE /workspaces/{id}/issues/{iid} | ✅ | admin |
Agent Management
| Route Pattern | Enforcement | Minimum Role |
|---|---|---|
GET /workspaces/{id}/agents/ | ✅ | member |
POST /workspaces/{id}/agents/ | ✅ | member |
PATCH /workspaces/{id}/agents/{aid} | ✅ | member |
DELETE /workspaces/{id}/agents/{aid} | ✅ | admin |
Owner-only Sub-checks
Beyond the base role requirements, certain operations require additional owner privileges:Member Management with Owner Role
| Operation | Requirement | Error Message |
|---|---|---|
Add member with role=owner | Caller must be owner | Only owners can add another owner |
Change role to owner | Caller must be owner | Only owners can assign the owner role |
Change existing owner role | Caller must be owner | Only owners can change an owner's role |
Remove existing owner | Caller must be owner | Only owners can remove an owner |
| Change your own role | Always forbidden | Cannot change your own role |
| Remove yourself | Always forbidden | Cannot remove yourself from the workspace |
Example Owner-only Operations
Cross-workspace Access (IDOR)
Theensure_resource_in_workspace function prevents cross-workspace resource access by returning 404 (not 403) when a resource exists but belongs to a different workspace.
Protected Resources
| Resource | Routes | 404 Message |
|---|---|---|
| Agents | GET/PATCH/DELETE /agents/{id} | Agent not found |
| Issues | GET/PATCH/DELETE /issues/{id} | Issue not found |
| Issue Comments | POST/GET /issues/{id}/comments | Issue not found |
Error Responses
403 Forbidden - Non-Member
When a valid user attempts to access a workspace they’re not a member of:403 Forbidden - Insufficient Role
When a member lacks the required role level:403 Forbidden - Owner Role Required
When an admin attempts to assign admin or owner roles:401 Unauthorized
When authentication fails (invalid/missing token):API Testing
Valid Member Access
Non-Member Access
Role-based Access
Migration Impact
Behavior Changes
| Scenario | Before batch 3 | After batch 3 |
|---|---|---|
| Valid user, non-member | ✅ Access granted | ❌ 403 Forbidden |
| Valid user, workspace member | ✅ Access granted | ✅ Access granted |
| Invalid token | ❌ 401 Unauthorized | ❌ 401 Unauthorized |
| Admin promotes member → admin | ✅ allowed | ❌ 403 Forbidden |
| Admin promotes member → owner | ❌ already blocked | ❌ still blocked |
| Owner promotes member → admin | ✅ allowed | ✅ allowed |
| Cross-workspace resource access via service layer | Surface IDOR risk | ❌ returns None/404 |
Client Impact
Best Practices
Handle Authorization Errors Gracefully
Handle Authorization Errors Gracefully
Use Appropriate Role Requirements
Use Appropriate Role Requirements
Configure route dependencies with the minimum required role. Don’t require
admin for operations that member can safely perform.Validate Membership Before UI Actions
Validate Membership Before UI Actions
Check user workspace membership before displaying UI elements like “Create Project” buttons to prevent unsuccessful API calls.
Monitor Failed Authorization Attempts
Monitor Failed Authorization Attempts
Testing
Verify RBAC enforcement with the integration test suite:- Non-member 403 responses on all workspace routes
- Member access granted for basic operations
- Admin role enforcement for management operations
- Owner role enforcement for destructive operations
Related
Team Members & RBAC
Learn about workspace member management
Authentication
Understand JWT token authentication

