-
Notifications
You must be signed in to change notification settings - Fork 3
Access Controls
Maattt GoobyFRS edited this page Aug 15, 2026
·
1 revision
GoobyDesk uses a lightweight, session-based RBAC model. Roles are assigned to an employee's auth record and are copied into the Flask session at login. Access decisions are enforced per-route via the @role_required(...) decorator (local_handlers/auth_decorators.py).
| Role Constant | Value | Typical Purpose |
|---|---|---|
ROLE_ITSM_TECH |
itsm_technician |
Works tickets, changes, CRM, and service IDs |
ROLE_HR_TECH |
hr_technician |
Manages employee/HR records |
ROLE_MANAGER |
manager |
Elevated, cross-module access |
ROLE_ADMIN |
admin |
Full access, including sensitive HR actions |
A single employee may hold multiple roles; roles are stored as a list on the employee's auth record and are set during HR account provisioning (blueprints/hr_module.py, HR_ROLE_MAP).
- On login (
app.py,login()),_assign_roles_to_session()populatessession["roles"]from the authenticated employee record. - Protected routes are wrapped with
@role_required(*required_roles, require_all=False, redirect_to_login=True). -
role_requiredenforces, in order:-
Unauthenticated users are redirected to
/login(or given a 403 ifredirect_to_login=False). -
Admin or Manager bypass — if the session has
adminormanager, the request is always allowed, regardless of the route's declared roles. -
Wildcard role — a route declared with
@role_required("*")allows any authenticated user. -
Explicit role match — otherwise, the user must have at least one of the declared roles (or all of them, if
require_all=True).
-
Unauthenticated users are redirected to
- Unauthorized authenticated users receive a rendered
errors/403.htmlpage.
| Module | Routes | Required Role(s) |
|---|---|---|
ITSM (itsm_module.py) |
Dashboard, ticket detail, status update, add note | itsm_technician |
Changes (changes_module.py) |
Dashboard, submit new, CSV export | itsm_technician |
CRM (crm_module.py) |
Dashboard, new/edit customer, worknotes | itsm_technician |
Service IDs (serviceid_module.py) |
Dashboard, submit new | itsm_technician |
HR (hr_module.py) |
Dashboard, new/edit employee | hr_technician |
HR (hr_module.py) |
Reset employee password | admin |
Reports (reports_module.py) |
Dashboard, CSV export |
* (any authenticated user) |
Because Admins and Managers bypass explicit role checks, they can access every module above regardless of the table.
-
session["technician"]— logged-in username -
session["roles"]— list of role strings for the current session
- Always use the
ROLE_*constants fromlocal_handlers/auth_decorators.pyrather than hardcoded role strings, so role names stay consistent. - Use
require_all=Trueonly when a route genuinely needs every listed role; the default is "any of". - New sensitive actions (e.g., password resets, account unlocks) should default to
ROLE_ADMINrather than a broader role.