TimeTracker now includes a comprehensive, role-based permission system that allows administrators to control access to various features and functionality at a granular level. This system replaces the simple "admin" vs "user" model with a flexible role-based access control (RBAC) system.
RBAC applies within one organization. A single TimeTracker instance has one company profile (Settings → Company), one mail sender, and one shared data namespace. Roles can hide clients, projects, or tasks from specific users, but they cannot split company branding, invoice identity, or email configuration across separate companies.
If you need fully independent companies — each with its own company data, invoices, and email sender — run one TimeTracker instance per company. See Running Multiple TimeTracker Instances.
Permissions are individual capabilities or actions that a user can perform in the system. Examples include:
view_all_time_entries- View time entries from all userscreate_projects- Create new projectsedit_invoices- Edit invoice detailsmanage_settings- Access and modify system settings
Each permission has:
- Name: A unique identifier (e.g.,
edit_projects) - Description: Human-readable explanation of what the permission allows
- Category: Logical grouping (e.g.,
projects,invoices,system)
Roles are collections of permissions that can be assigned to users. Instead of granting individual permissions to each user, you assign roles that bundle related permissions together.
Examples of roles:
- Super Admin: Full system access with all permissions
- Admin: Most administrative capabilities except role management
- Manager: Can oversee projects, tasks, and team members
- User: Standard access for time tracking and personal data
- Viewer: Read-only access
Each role has:
- Name: Unique identifier
- Description: Explanation of the role's purpose
- System Role Flag: Indicates whether the role is built-in (cannot be deleted)
- Permissions: Collection of permissions assigned to the role
Users can be assigned one or more roles. A user's effective permissions are the union of all permissions from their assigned roles.
The following system roles are created by default:
- All permissions in the system
- Can manage roles and permissions themselves
- Intended for system administrators
- All permissions except role/permission management
- Can manage users, projects, invoices, settings
- Cannot modify the permission system itself
- Oversight capabilities for teams and projects
- Can view all time entries and reports
- Can create and edit projects, tasks, and clients
- Can create and send invoices
- Cannot delete users or modify system settings
- Standard time tracking capabilities
- Can create and edit own time entries
- Can create and manage own tasks
- View-only access to own projects and clients (
view_own_projects,view_own_clients) - Can view own reports and invoices
- Read-only access
- Can view own time entries, tasks, and reports
- Cannot create or modify anything
- Same capabilities as User but restricted to assigned clients and their projects only
- Admins assign one or more clients to the user in Admin → Users → Edit user (section "Assigned Clients (Subcontractor)")
- The user sees only those clients, their projects, and related time entries, invoices, and reports
- Direct access to other clients or projects returns 403 Forbidden
- See Subcontractor role and assigned clients for full details
Permissions are organized into the following categories:
view_own_time_entriesview_all_time_entriescreate_time_entriesedit_own_time_entriesedit_all_time_entriesdelete_own_time_entriesdelete_all_time_entries
view_own_projects/view_all_projects(legacyview_projects= view all)create_projectsedit_own_projects/edit_all_projects(legacyedit_projects= edit all)delete_own_projects/delete_all_projects(legacydelete_projects= delete all)archive_projectsmanage_project_costs
Projects and clients track created_by for workspace isolation. Rows with created_by NULL are legacy/shared and visible only to users with view-all (or admin).
view_own_tasksview_all_taskscreate_tasksedit_own_tasksedit_all_tasksdelete_own_tasksdelete_all_tasksassign_tasks
view_own_clients/view_all_clients(legacyview_clients= view all)create_clientsedit_own_clients/edit_all_clients(legacyedit_clients= edit all)delete_own_clients/delete_all_clients(legacydelete_clients= delete all)manage_client_notes
view_own_invoicesview_all_invoicescreate_invoicesedit_invoicesdelete_invoicessend_invoicesmanage_payments
view_own_reportsview_all_reportsexport_reportscreate_saved_reports
view_userscreate_usersedit_usersdelete_usersmanage_user_roles
manage_settingsview_system_infomanage_backupsmanage_telemetryview_audit_logs
manage_rolesmanage_permissionsview_permissions
- Navigate to Admin Dashboard → Roles & Permissions
- View all available roles with their permission counts
- Click on a role to see detailed information and assigned users
- Go to Admin Dashboard → Roles & Permissions
- Click Create Role
- Enter:
- Role name (e.g., "Project Manager")
- Description (optional)
- Select permissions by category
- Click Create Role
Note: Custom roles can be modified or deleted. System roles cannot be deleted but serve as templates for custom roles.
- Navigate to the role list
- Click Edit on a custom role (system roles cannot be edited)
- Modify name, description, or permissions
- Click Update Role
- Go to Admin Dashboard → Manage Users
- Click Edit on a user
- Click Manage Roles & Permissions
- Select the roles to assign
- Click Update Roles
Users can have multiple roles. Their effective permissions will be the combination of all assigned roles.
- Edit a user in the admin panel
- Click Manage Roles & Permissions
- Scroll to "Current Effective Permissions" to see all permissions the user has
Use the permission checking methods on the User model:
from flask_login import current_user
# Check single permission
if current_user.has_permission('edit_projects'):
# Allow editing
# Check if user has ANY of the permissions
if current_user.has_any_permission('edit_projects', 'delete_projects'):
# Allow action
# Check if user has ALL of the permissions
if current_user.has_all_permissions('create_invoices', 'send_invoices'):
# Allow actionFor quote listing/detail routes, users with quote-management permissions (for example edit_quotes) may need access beyond "own quotes only" in order to open the quote they just edited from redirects and list views. Keep list/detail scoping aligned with route-level permission intent to avoid "edit succeeds but view returns 404/redirect" behavior.
Current implementation uses a shared quote-access helper so quote list/detail scope matches edit capability: admins and users with edit_quotes can access quote list/detail across owners, while users without that permission remain scoped to their own quotes.
Validation reference: behavior is covered by quote web/API regression tests in tests/test_routes/test_quotes_web.py and tests/test_routes/test_api_v1_quotes_refactored.py.
Protect routes with permission decorators:
from app.utils.permissions import permission_required
@app.route('/projects/<id>/edit')
@login_required
@permission_required('edit_projects')
def edit_project(id):
# Only users with edit_projects permission can access
pass
# Require multiple permissions (user needs ANY of them)
@app.route('/reports/export')
@login_required
@permission_required('view_all_reports', 'export_reports')
def export_report():
pass
# Require ALL permissions
@app.route('/admin/critical')
@login_required
@permission_required('manage_settings', 'manage_backups', require_all=True)
def critical_admin_action():
passFor gradual migration, use the admin_or_permission_required decorator:
from app.utils.permissions import admin_or_permission_required
@app.route('/projects/delete')
@login_required
@admin_or_permission_required('delete_projects')
def delete_project():
# Admins OR users with delete_projects permission can access
passUse the template helpers to conditionally show UI elements:
{% if has_permission('edit_projects') %}
<a href="{{ url_for('projects.edit', id=project.id) }}">Edit Project</a>
{% endif %}
{% if has_any_permission('create_invoices', 'edit_invoices') %}
<button>Manage Invoices</button>
{% endif %}
{% if has_all_permissions('view_all_reports', 'export_reports') %}
<a href="{{ url_for('reports.export') }}">Export All Reports</a>
{% endif %}The new permission system is fully backward compatible with the existing "role" field:
- Users with
role='admin'are automatically recognized as administrators - Legacy admin users have all permissions (even without assigned roles)
- The
is_adminproperty checks both the legacy role field and new role assignments
To migrate users to the new system:
-
Run the migration command:
flask seed_permissions_cmd
-
This will:
- Create all default permissions
- Create all default roles
- Migrate existing users:
- Users with
role='admin'get the "admin" role - Users with
role='user'get the "user" role
- Users with
-
Optionally, review and adjust role assignments in the admin panel
If new permissions are added in a system update:
flask update_permissionsThis command updates permissions and roles without affecting user assignments.
id- Primary keyname- Unique permission identifierdescription- Human-readable descriptioncategory- Permission categorycreated_at- Timestamp
id- Primary keyname- Unique role identifierdescription- Role descriptionis_system_role- Boolean flagcreated_at- Creation timestampupdated_at- Last update timestamp
role_id- Foreign key to rolespermission_id- Foreign key to permissionscreated_at- Assignment timestamp
user_id- Foreign key to usersrole_id- Foreign key to rolesassigned_at- Assignment timestamp
GET /api/users/<user_id>/permissions
Access expectations: intended for administrator use (admin session / admin-equivalent role).
Returns:
{
"user_id": 1,
"username": "john",
"roles": [
{"id": 1, "name": "manager"}
],
"permissions": [
{"id": 1, "name": "view_all_time_entries", "description": "..."},
{"id": 2, "name": "create_projects", "description": "..."}
]
}GET /api/roles/<role_id>/permissions
Access expectations: intended for administrator use (admin session / admin-equivalent role).
Returns:
{
"role_id": 1,
"name": "manager",
"description": "Team Manager with oversight capabilities",
"is_system_role": true,
"permissions": [
{"id": 1, "name": "view_all_time_entries", "category": "time_entries", "description": "..."}
]
}- Start with a system role: Use system roles as templates
- Be specific: Create roles for specific job functions (e.g., "Invoice Manager", "Project Lead")
- Least privilege: Grant only the permissions needed for the role's purpose
- Document: Add clear descriptions to custom roles
- Use snake_case:
create_projects, notCreateProjects - Action first:
edit_invoices, notinvoices_edit - Be specific:
view_all_time_entriesvsview_own_time_entries
Always test permission changes:
- Create a test user
- Assign the role
- Log in as that user
- Verify they can/cannot access expected features
- Check user's assigned roles
- Verify the roles have the required permission
- Check if the feature requires multiple permissions
- Ensure user account is active
- System roles cannot be edited or deleted
- Roles assigned to users cannot be deleted (reassign users first)
If a legacy admin user (with role='admin') loses permissions:
- Verify their
rolefield is still 'admin' - If using new role system, assign them the "super_admin" or "admin" role
- The system checks both legacy role and new roles
- Log out and log back in
- Permissions are loaded on login
- Check browser cache/session
- Super Admin Role: Assign sparingly - it has full system access
- Regular Audits: Review user role assignments periodically
- Separation of Duties: Don't assign conflicting roles (e.g., invoice creation + approval)
- Testing: Always test in a non-production environment first
Planned features:
- Permission inheritance: Hierarchical permissions
- Time-based roles: Temporary role assignments
- Audit logging: Track permission changes
- Role templates: Exportable role configurations
- API keys with permissions: Scoped API access
For issues or questions about the permission system:
- Check this documentation
- Review the test files:
tests/test_permissions.pyandtests/test_permissions_routes.py - Check the implementation:
app/models/permission.pyandapp/utils/permissions.py