VoxBridge authenticates dashboard and admin API access with JWTs and authorizes by role. Users live in the users MongoDB collection. Code: routes/auth.py, routes/users.py, auth/jwt.py, auth/deps.py, models/user.py.

JWT

auth/jwt.py signs an HS-family JWT with settings.jwt_secret/jwt_algorithm:
ClaimValue
subuser email
rolerole string
namedisplay name
expnow + jwt_expire_minutes
get_current_user (auth/deps.py) decodes the bearer token, then re-reads the user from MongoDB on every request — so a deactivated or deleted user is rejected immediately even with a still-valid token. The role used for authorization comes from the database record, not the token claim.

Login & self-service

Under /api/v1/auth:
MethodPathAuthPurpose
POST/loginnoneEmail + password → access_token. 401 on bad credentials or is_active=false.
POST/registeradmin+Create a user (rank-gated, see below)
GET/meanyCurrent profile
PUT/meanyUpdate own name
PUT/me/passwordanyChange own password (verifies current)
Passwords are hashed via auth/password.py (hash_password/verify_password); raw passwords are never stored.

Role hierarchy

ROLE_RANK (routes/users.py):
RoleRankTypical use
agent0Agent Desk operator
supervisor1Monitors/barge, Agent Assist manager
admin2Manage bots, campaigns, users
super_admin3Carriers, integrations, delete users
Role dependencies in auth/deps.py: require_admin (admin or super_admin), require_super_admin (exact), require_agent_or_supervisor, require_supervisor, require_agent_assist_manager (admin/super_admin/supervisor), require_any_role.

The same-rank rule

The guard differs between creating/assigning a role and modifying an existing user:
  • Create / assign role (register, role change in update_user): blocked only when actor_rank < new_rank. A user may create or promote up to their own rank — e.g. a super_admin can mint another super_admin.
  • Modify another user (_check_hierarchy, used by update/deactivate/reset-password): requires actor_rank > target_rank (actor_rank <= target_rank is rejected). You cannot modify a peer or someone above you.
  • Self-modification is always allowed past _check_hierarchy (the email-equality short-circuit), but you cannot delete or deactivate yourself.

User CRUD

Under /api/v1/users:
MethodPathRoleNotes
GETadminList users
GET/{user_id}adminGet user
PUT/{user_id}adminUpdate (hierarchy + role-rank guards; email uniqueness enforced)
DELETE/{user_id}super_adminDelete (cannot delete self)
POST/{user_id}/deactivateadminToggle is_active (cannot deactivate self)
POST/{user_id}/reset-passwordadminSet new password (hierarchy-gated)
Agent-specific fields (departments, max_concurrent_calls, agent_languages, agent_primary_language) are normalised on write via normalise_agent_languages/normalise_agent_primary_language. Invalid user_id400; missing → 404.

API keys

Non-JWT auth for CRM-triggered dialout.

Agent Desk

Where agent/supervisor roles are used at runtime.

Agent Assist

Assist-moment management (manager roles).

VoxBridge overview

Control-plane responsibilities.