Steps to reproduce
- Have a NethVoice CTI instance with users.json containing at least one user whose
profile_id does not exist in profiles.json (e.g. a service extension with no CTI profile assigned, profile_id "-1")
- Restart or start nethcti-middleware
- Log in to the CTI web UI as any other, correctly configured user
- Open the Rubrica (Phonebook) section
Expected behavior
The phonebook loads normally for users whose account is correctly configured, regardless of unrelated malformed/unassigned user records elsewhere in users.json.
Actual behavior
The phonebook request fails with 403 Forbidden ("forbidden: missing capability") for every user on the instance, not just the one with the bad profile reference.
Root cause: loadUsers() in store/profiles.go returns a hard error as soon as it finds one user referencing an unknown profile_id, and InitProfiles() propagates that error before assigning the global profiles/users maps. main.go ignores the error return of InitProfiles, so the middleware starts with profiles and users both nil. Every subsequent call to GetUserCapabilities() then fails with "user X not found", which the RequireCapabilities middleware turns into a 403 for all capability-gated routes (phonebook search/getall/contact, and nethvoice_cti.satellite_stt), for every user, with no error surfaced anywhere except a generic 403 in the browser console.
This is easy to hit in practice: a service/extension-only user with no CTI profile assigned (profile_id "-1") is a legitimate, common configuration, tolerated by nethcti-server (Node.js), but not by nethcti-middleware.
Components
- nethcti-middleware (Go), affected on the version introducing the
RequireCapabilities("phonebook") gate together with the current loadUsers/loadProfiles implementation in store/profiles.go
- Reproduced on a NethVoice 1.7-based NS8 instance
Steps to reproduce
profile_iddoes not exist in profiles.json (e.g. a service extension with no CTI profile assigned, profile_id "-1")Expected behavior
The phonebook loads normally for users whose account is correctly configured, regardless of unrelated malformed/unassigned user records elsewhere in users.json.
Actual behavior
The phonebook request fails with
403 Forbidden("forbidden: missing capability") for every user on the instance, not just the one with the bad profile reference.Root cause:
loadUsers()instore/profiles.goreturns a hard error as soon as it finds one user referencing an unknownprofile_id, andInitProfiles()propagates that error before assigning the globalprofiles/usersmaps.main.goignores the error return ofInitProfiles, so the middleware starts withprofilesandusersbothnil. Every subsequent call toGetUserCapabilities()then fails with "user X not found", which theRequireCapabilitiesmiddleware turns into a 403 for all capability-gated routes (phonebook search/getall/contact, andnethvoice_cti.satellite_stt), for every user, with no error surfaced anywhere except a generic 403 in the browser console.This is easy to hit in practice: a service/extension-only user with no CTI profile assigned (profile_id "-1") is a legitimate, common configuration, tolerated by nethcti-server (Node.js), but not by nethcti-middleware.
Components
RequireCapabilities("phonebook")gate together with the currentloadUsers/loadProfilesimplementation instore/profiles.go