This document defines the Role-Based Access Control (RBAC) model for the Synapse system, specifying permissions, resources, and endpoints for each user type. The system implements a layered security architecture with JWT authentication and granular authorization by functionality.
| Role Name | Description | Permissions | Assigned Users/Groups | Resource Access | Creation Date | Active |
|---|---|---|---|---|---|---|
| Admin | Manages users, permissions and accesses reports | Users: CRUD on User Profiles, Update User, Create User, Deactivate User Reports: Grant/Remove Report Email Permissions, R on Report History, R on Report Details, Send Reports Manually AI: CRUD on AI Agent Interaction System: Access to System Logs, Advanced Settings |
Administrators | User Profiles, Report History, Report Details, AI Agent, Administrative Panel, System Logs | 2025/09/29 | β |
| Regular User | Accesses reports and manages own account | Reports: R on Report History, R on Report Details AI: CRUD on AI Agent Interaction Account: Deactivate Own Account, Reset Own Password, Edit Own Data, Register in System Chat: Send/Receive Messages, View Conversation History |
Registered Users | Report History, Report Details, AI Agent, User Profile, Account Settings, Chat Interface | 2025/09/29 | β |
| Inactive User | Deactivated account with no system access | None | Deactivated Users | None | 2025/09/29 | β |
The Synapse RBAC system implements multi-layered security with the following components:
- Authentication Layer: JWT-based token validation
- Authorization Layer: Role-based permission checking
- Resource Layer: Endpoint-specific access control
- Data Layer: User isolation and admin privileges
| Endpoint Category | Public Access | User Access | Admin Access | Notes |
|---|---|---|---|---|
| Authentication | β | β | β | Login/logout available to all |
| User Registration | β | β | β | Public registration enabled |
| User Profile | β | β | β | Own profile + admin override |
| Reports (View) | β | β | β | All authenticated users |
| Reports (Manage) | β | β | β | Admin-only operations |
| Chat/NLP | β | β | β | Authenticated user feature |
| Admin Panel | β | β | β | Strict admin-only access |
| System Endpoints | β | β | β | Health checks public |
π For detailed endpoint documentation, see API Endpoints
- JWT (JSON Web Tokens) with access token and refresh token
- HTTPOnly Cookies for secure token storage
- Configurable expiration (access: 30min, refresh: 7 days)
- Automatic token rotation via
/auth/refreshendpoint
- Role-Based Access Control (RBAC) with Admin/User roles
- Validation middleware (
PermissionValidator) for administrative endpoints - Real-time verification of user status (is_active)
- Resource segregation based on user role
- Bcrypt hash for passwords with automatic salt
- Input validation for injection prevention
- Configured CORS for secure cross-origin requests
- Rate limiting (to implement) for attack prevention
| Action | Admin | Regular User | Inactive User |
|---|---|---|---|
| Create user | β | β | β |
| View all users | β | β | β |
| View own profile | β | β | β |
| Edit any user | β | β | β |
| Edit own profile | β | β | β |
| Deactivate any user | β | β | β |
| Deactivate own account | β | β | β |
| Reset any user password | β | β | β |
| Reset own password | β | β | β |
| Action | Admin | Regular User | Inactive User |
|---|---|---|---|
| View report history | β | β | β |
| View report details | β | β | β |
| Send reports manually | β | β | β |
| Generate new reports | β | β | β |
| Configure subscribers | β | β | β |
| Manage email permissions | β | β | β |
| Schedule reports | β | β | β |
| Action | Admin | Regular User | Inactive User |
|---|---|---|---|
| Access chat interface | β | β | β |
| Send messages to AI | β | β | β |
| Receive AI responses | β | β | β |
| View conversation history | β | β | β |
| Create new conversations | β | β | β |
| Delete own conversations | β | β | β |
| Delete other users' conversations | β | β | β |
| Action | Admin | Regular User | Inactive User |
|---|---|---|---|
| Access administrative panel | β | β | β |
| View system logs | β | β | β |
| Configure system | β | β | β |
| Manage permissions | β | β | β |
| Monitor performance | β | β | β |
| Backup and restore | β | β | β |
graph TD
A[User logs in] --> B[Credential validation]
B --> C{Valid credentials?}
C -->|No| D[Return 401 error]
C -->|Yes| E[Check user status]
E --> F{User active?}
F -->|No| G[Return 403 error]
F -->|Yes| H[Generate access token and refresh token]
H --> I[Set HTTPOnly cookies]
I --> J[Update last_access]
J --> K[Return success]
graph TD
A[Request with token] --> B[Extract token from cookie]
B --> C{Token present?}
C -->|No| D[Return 401 error]
C -->|Yes| E[Validate JWT signature]
E --> F{Valid token?}
F -->|No| G[Return 401 error]
F -->|Yes| H[Extract user_id from token]
H --> I[Fetch user from database]
I --> J{User exists and active?}
J -->|No| K[Return 401 error]
J -->|Yes| L[Check required permissions]
L --> M{Permission granted?}
M -->|No| N[Return 403 error]
M -->|Yes| O[Allow resource access]
# Auth Class - Authentication management
class Auth:
@staticmethod
def get_current_user() -> CurrentUser
# Validates token and returns current user
@staticmethod
def create_access_token() -> str
# Generates JWT access token
@staticmethod
def create_refresh_token() -> str
# Generates JWT refresh token
# PermissionValidator Class - Permission validation
class PermissionValidator:
def __init__(self, user: CurrentUser)
def execute(self) -> None
# Validates if user has admin permissionThe RBAC system relies on key user attributes for access control:
# Core security attributes from User model
class SecurityContext:
user_id: int # Unique user identifier
is_admin: bool # Administrative privileges flag
is_active: bool # Account status (active/inactive)
email: str # User identification
receive_email: bool # Email permission flagπ For complete database schema, see Database Model
- Rate Limiting: System does not implement login attempt limitation
- Session Management: Lacks active token invalidation on logout
- Password Policy: Minimal password policy (only 8 characters)
- Audit Log: Absence of audit logs for sensitive actions
- HTTPS: Cookies not marked as secure (development)
- Implement rate limiting for authentication endpoints
- Add token blacklist for effective logout
- Strengthen password policy (complexity, expiration)
- Implement audit logs for administrative actions
- Configure HTTPS in production with secure cookies
- Add 2FA for administrative accounts
- Implement CSRF protection for sensitive forms
- JWT Authentication
- Basic Admin/User Authorization
- User endpoints
- Reports endpoints
- WebSocket endpoints for chat
- Conversation system
- AI integration
- Message history
- Complete administrative panel
- Granular user management
- Audit logs
- System configurations
- Rate limiting
- Robust password policy
- Two-factor authentication
- Advanced session management
- OWASP Top 10 - Web application security
- RFC 7519 - JSON Web Token (JWT)
- NIST 800-63B - Digital Identity Guidelines
- ISO 27001 - Information Security Management
π Last Updated: 29/09/2025
π€ Responsible: Synapse Development Team
π Next Review: Sprint 3 Start
π Status: Partial Implementation (40% complete)