Skip to content

Nethcti-middleware: single user with unresolved profile_id blacks out phonebook (and all capability-gated routes) for the whole instance #8091

Description

@tonyco97

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    nethvoiceBug or features releted to the NethVoice projectnethvoice-ctiThe issue is related to NethLink (NethVoice Web client)

    Type

    Fields

    No fields configured for Bug.

    Projects

    Status
    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions