methods

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2026 License: GPL-3.0 Imports: 42 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTrustedLoginDisabled = errors.New("trusted login is not configured")

ErrTrustedLoginDisabled is returned when a password-less login is requested but its secret is not configured.

View Source
var ErrV1AuthFailed = errors.New("V1 authentication failed")

ErrV1AuthFailed is returned when the V1 server (nethcti-server) does not authenticate the user.

View Source
var ErrV1LoginRefused = fmt.Errorf("%w: login refused", ErrV1AuthFailed)

ErrV1LoginRefused is returned when the V1 server refuses the login without a challenge, as it does for an expired password. It wraps ErrV1AuthFailed.

Functions

func AdminCheckPersistentToken added in v0.8.0

func AdminCheckPersistentToken(c *gin.Context)

AdminCheckPersistentToken reports whether the user holds an integration token for the audience.

func AdminCreatePersistentToken added in v0.8.0

func AdminCreatePersistentToken(c *gin.Context)

AdminCreatePersistentToken issues an integration token for the user, without the user password. When the user has no session yet (e.g. never logged in), it is created with an internal login on the V1 server, authorized by the super admin token that the V1 server shares through the module environment.

func AdminDisable2FA added in v0.8.0

func AdminDisable2FA(c *gin.Context)

AdminDisable2FA disables 2FA for the user (e.g. lost device) and revokes all the user tokens, so every client has to log in again.

func AdminGet2FAStatus added in v0.8.0

func AdminGet2FAStatus(c *gin.Context)

AdminGet2FAStatus reports whether the user has 2FA enabled.

func AdminImportPhonebookCSV added in v0.4.5

func AdminImportPhonebookCSV(c *gin.Context)

AdminImportPhonebookCSV handles CSV phonebook imports for admin users. Admin can import contacts into any target user's phonebook by specifying the username form field. Requires super admin bearer token authentication.

func AdminReloadProfiles added in v0.4.5

func AdminReloadProfiles(c *gin.Context)

AdminReloadProfiles reloads profiles and users globally via super admin API endpoint

func AdminRemovePersistentToken added in v0.8.0

func AdminRemovePersistentToken(c *gin.Context)

AdminRemovePersistentToken revokes the user tokens of the audience; "all" revokes every token and the session. It succeeds also when there is nothing to revoke.

func BuildUserJWTClaims added in v0.5.0

func BuildUserJWTClaims(opts UserJWTOptions) jwtv5.MapClaims

BuildUserJWTClaims builds the canonical final JWT claims set for a user.

func ChangePassword added in v0.8.0

func ChangePassword(c *gin.Context)

ChangePassword changes the password of a user that cannot log in because the password is expired. The current password authenticates the request.

func ChangeUserPassword added in v0.8.0

func ChangeUserPassword(c *gin.Context)

ChangeUserPassword changes the password of the logged in user

func CheckPersistentToken added in v0.4.5

func CheckPersistentToken(c *gin.Context)

CheckPersistentToken checks if at least one valid integration token exists for the requested audience.

func CheckSummaryByUniqueID added in v0.5.0

func CheckSummaryByUniqueID(c *gin.Context)

CheckSummaryByUniqueID verifies whether a non-deleted summary exists for the given uniqueid. It is intended for HEAD endpoints and returns status only (no response body).

func CreateLegacyCTIPhonebookContact added in v0.5.8

func CreateLegacyCTIPhonebookContact(c *gin.Context)

CreateLegacyCTIPhonebookContact creates a legacy CTI phonebook contact from middleware.

func CreatePersistentToken added in v0.4.5

func CreatePersistentToken(c *gin.Context)

CreatePersistentToken creates a JWT integration token for the requested audience.

func DeleteExpiredTokens added in v0.0.3

func DeleteExpiredTokens()

func DeleteLegacyCTIPhonebookContact added in v0.5.8

func DeleteLegacyCTIPhonebookContact(c *gin.Context)

DeleteLegacyCTIPhonebookContact deletes a legacy CTI phonebook contact from middleware.

func Disable2FA added in v0.0.3

func Disable2FA(c *gin.Context)

Disable2FA disables two-factor authentication for the user

func Get2FARecoveryCodes added in v0.0.3

func Get2FARecoveryCodes(c *gin.Context)

Get2FARecoveryCodes retrieves the recovery codes for the user

func Get2FAStatus added in v0.0.3

func Get2FAStatus(c *gin.Context)

Test2FAStatus checks if 2FA is enabled for the user

func GetCentralizedPhonebookContact added in v0.5.8

func GetCentralizedPhonebookContact(c *gin.Context)

GetCentralizedPhonebookContact returns a single contact from the centralized (company-wide) phonebook by id. These contacts are published for all users and carry no owner/group scoping, so any caller with the phonebook capability can read them. The frontend calls this route for contacts whose source is not "cti".

func GetFilteredHistory added in v0.5.0

func GetFilteredHistory(c *gin.Context)

GetFilteredHistory returns history rows filtered server-side by voicemail, summary or transcription and keeps count/pagination consistent.

func GetLegacyCTIPhonebookContact added in v0.5.8

func GetLegacyCTIPhonebookContact(c *gin.Context)

GetLegacyCTIPhonebookContact serves the legacy CTI phonebook detail route from middleware.

func GetPasswordInfo added in v0.8.0

func GetPasswordInfo(c *gin.Context)

GetPasswordInfo returns the cached password expiration info of the user

func GetSummaryByUniqueID added in v0.5.0

func GetSummaryByUniqueID(c *gin.Context)

GetSummaryByUniqueID returns the summary for the given uniqueid.

func GetTranscriptionByUniqueID added in v0.5.0

func GetTranscriptionByUniqueID(c *gin.Context)

GetTranscriptionByUniqueID returns the transcription for the given uniqueid.

func GetUserStatus added in v0.0.3

func GetUserStatus(username string) (string, error)

GetUserStatus retrieves the 2FA status for the user

func ImportPhonebookCSV added in v0.4.5

func ImportPhonebookCSV(c *gin.Context)

ImportPhonebookCSV handles CSV phonebook imports for the authenticated user. Requires JWT bearer token authentication.

func IsPasswordExpired added in v0.8.0

func IsPasswordExpired(ctx context.Context, username, password string) (bool, *userportal.Policy)

IsPasswordExpired asks the user portal whether the credentials rejected by the V1 server belong to a user that must change the password. When so, it returns also the password policy (nil if not available) for the new password.

func IsSupportUser added in v0.8.0

func IsSupportUser(c *gin.Context) bool

IsSupportUser returns true if the User header starts with "support-" and Secretkey is present.

func IssueUserJWT added in v0.5.0

func IssueUserJWT(opts UserJWTOptions) (jwtv5.MapClaims, string, error)

IssueUserJWT builds and signs a canonical user JWT in one place.

func ListLegacyPhonebook added in v0.5.8

func ListLegacyPhonebook(c *gin.Context)

ListLegacyPhonebook serves the legacy alphabetical list route from middleware.

func ListSummaryStatus added in v0.5.0

func ListSummaryStatus(c *gin.Context)

ListSummaryStatus returns the list of summary/transcription status for user's calls.

func ListVoicemailByID added in v0.5.0

func ListVoicemailByID(c *gin.Context)

ListVoicemailByID returns a single voicemail by DB id when :id is numeric. For legacy list types such as "all", "old" or "inbox", it transparently falls back to the V1 voicemail endpoint to preserve existing behavior.

func LoginV1 added in v0.8.0

func LoginV1(username, password string, mode LoginMode) (string, string, error)

LoginV1 authenticates the user on the V1 server and returns the username of the account, as the V1 server names it, with the persistent NethCTIToken ("username:token") the middleware uses to call it.

The V1 server also accepts other names for the same account (the main extension number, a different case): the session must always be keyed by the account username, so the login is repeated once with that username.

With LoginPassword, password is the user password and it is also the key of the legacy token. The other modes need no user password: the request carries the username and a shared secret in dedicated headers, and the legacy token key is derived from that secret.

func NethlinkHeartbeat added in v0.5.22

func NethlinkHeartbeat(c *gin.Context)

NethlinkHeartbeat records a NethLink last-seen for the authenticated user. It supersedes the legacy nethcti-server POST /user/nethlink (previously reached via the V1 proxy) and additionally persists the client version and OS details sent in the body. The username comes from the JWT; the extension is taken from the body since the JWT does not carry it.

func OTPPending added in v0.8.0

func OTPPending(claims map[string]interface{}) bool

OTPPending reports whether the claims belong to a token of a user with 2FA enabled whose OTP has not been verified yet.

func ParseUserJWT added in v0.8.0

func ParseUserJWT(tokenString string) (jwtv5.MapClaims, error)

ParseUserJWT validates a user JWT (signature and expiration) and returns its claims.

func PhoneIslandTokenCheck added in v0.0.3

func PhoneIslandTokenCheck(c *gin.Context)

PhoneIslandTokenCheck is a legacy compatibility endpoint. Historically this endpoint checked the phone-island integration token existence.

func PhoneIslandTokenLogin added in v0.0.3

func PhoneIslandTokenLogin(c *gin.Context)

PhoneIslandTokenLogin is a legacy compatibility endpoint. It maps legacy subtype values to the new persistent token audiences.

func PhoneIslandTokenRemove added in v0.0.3

func PhoneIslandTokenRemove(c *gin.Context)

PhoneIslandTokenRemove is a legacy compatibility endpoint. It maps legacy subtype values to the new persistent token audiences.

func ProxyV1Request

func ProxyV1Request(c *gin.Context, path string, allowAnonymous bool)

ProxyV1Request forwards requests to the legacy V1 API

func QRCode added in v0.0.3

func QRCode(c *gin.Context)

QRCode generates a QR code for the user to set up 2FA

func RefreshPasswordInfo added in v0.8.0

func RefreshPasswordInfo(username, password string)

RefreshPasswordInfo reads in background the password expiration info of the user from the user portal and caches it. It runs at every login, as the password can be changed elsewhere too (e.g. the NS8 user portal). Errors are logged only: the info is optional.

func RemovePersistentToken added in v0.4.5

func RemovePersistentToken(c *gin.Context)

RemovePersistentToken revokes all integration JWTs for the requested audience.

func RewriteSupportToAdmin added in v0.8.0

func RewriteSupportToAdmin(c *gin.Context) bool

RewriteSupportToAdmin validates a support user's Secretkey against MariaDB and rewrites the request headers to use admin credentials. Returns true if the rewrite succeeded, false otherwise (caller should return 401).

func SearchLegacyPhonebook added in v0.5.8

func SearchLegacyPhonebook(c *gin.Context)

SearchLegacyPhonebook serves the legacy union search route from middleware.

func SupportAuthThrottled added in v0.8.0

func SupportAuthThrottled(ip, username string) bool

SupportAuthThrottled reports whether ip exceeded the failed login budget for username.

func UpdateLegacyCTIPhonebookContact added in v0.5.8

func UpdateLegacyCTIPhonebookContact(c *gin.Context)

UpdateLegacyCTIPhonebookContact updates a legacy CTI phonebook contact from middleware.

func UpdateSummaryByUniqueID added in v0.5.0

func UpdateSummaryByUniqueID(c *gin.Context)

UpdateSummaryByUniqueID updates the summary for the given uniqueid.

func UpsertUserSession added in v0.8.0

func UpsertUserSession(username, NethCTIToken string) *models.UserSession

UpsertUserSession stores the NethCTIToken of a successful login, reusing the existing session (and its tokens) when the user already has one. It returns a copy of the session.

func VerifyOTP added in v0.1.3

func VerifyOTP(c *gin.Context)

VerifyOTP verifies the OTP provided by the user

func VerifyUserPassword added in v0.2.0

func VerifyUserPassword(username, password string) bool

VerifyUserPassword verifies a user's password against NetCTI server

func WatchCallSummary added in v0.5.0

func WatchCallSummary(c *gin.Context)

WatchCallSummary starts watching for a summary in the satellite transcripts table.

Types

type CallMetadata added in v0.5.0

type CallMetadata struct {
	Src           string
	Dst           string
	CNam          string
	Company       string
	DstCompany    string
	DstCNam       string
	CallTimestamp *time.Time
}

type LoginMode added in v0.8.0

type LoginMode int

LoginMode selects how LoginV1 authenticates the user on the V1 server.

const (
	// LoginPassword uses the user password.
	LoginPassword LoginMode = iota
	// LoginSSO uses the trusted SSO secret (the user has been authenticated
	// by the SSO front-end).
	LoginSSO
	// LoginInternal uses the super admin token, shared with the V1 server
	// through the module environment (admin endpoints).
	LoginInternal
)

type PhonebookImportResponse added in v0.4.5

type PhonebookImportResponse struct {
	Message       string   `json:"message"`
	TotalRows     int      `json:"total_rows"`
	ImportedRows  int      `json:"imported_rows"`
	FailedRows    int      `json:"failed_rows"`
	SkippedRows   int      `json:"skipped_rows"`
	ErrorMessages []string `json:"error_messages,omitempty"`
}

PhonebookImportResponse represents the response from a CSV import

type SummaryDrawer added in v0.5.0

type SummaryDrawer struct {
	UniqueID      string     `json:"uniqueid"`
	Summary       string     `json:"summary"`
	Sentiment     *int       `json:"sentiment,omitempty"`
	State         string     `json:"state"`
	Src           string     `json:"src,omitempty"`
	Dst           string     `json:"dst,omitempty"`
	CNam          string     `json:"cnam,omitempty"`
	Company       string     `json:"company,omitempty"`
	DstCompany    string     `json:"dst_company,omitempty"`
	DstCNam       string     `json:"dst_cnam,omitempty"`
	CallTimestamp *time.Time `json:"call_timestamp,omitempty"`
	CreatedAt     time.Time  `json:"created_at"`
	UpdatedAt     time.Time  `json:"updated_at"`
	DeletedAt     *time.Time `json:"deleted_at,omitempty"`
}

type SummaryListItem added in v0.5.0

type SummaryListItem struct {
	ID               int64  `json:"id,omitempty"`
	LinkedID         string `json:"linkedid,omitempty"`
	UniqueID         string `json:"uniqueid"`
	State            string `json:"state"`
	HasTranscription bool   `json:"has_transcription"`
	HasSummary       bool   `json:"has_summary"`
	SrcNumber        string `json:"src_number,omitempty"`
	DstNumber        string `json:"dst_number,omitempty"`
	// DurationSeconds is the wall-clock length of this conversation segment, set by
	// the satellite for transfer sub-legs (consultation / post-transfer) that have
	// no CDR row of their own for every participant. Lets the UI render a real
	// duration instead of 00:00:00. Nil when unknown.
	DurationSeconds *int `json:"duration_seconds,omitempty"`
	// Extra marks a conversation surfaced in addition to the requested history
	// row (e.g. the consultation leg of a transfer). The frontend renders these
	// as their own conversation rows, keyed by id (not uniqueid, which they may
	// share with the main leg).
	Extra     bool       `json:"extra,omitempty"`
	UpdatedAt *time.Time `json:"updated_at"`
}

type SummaryStatusLookup added in v0.5.3

type SummaryStatusLookup struct {
	UniqueID string `json:"uniqueid,omitempty"`
	LinkedID string `json:"linkedid,omitempty"`
}

type SummaryUpdateRequest added in v0.5.0

type SummaryUpdateRequest struct {
	Summary string `json:"summary"`
}

type SummaryWatchRequest added in v0.5.0

type SummaryWatchRequest struct {
	UniqueID string `json:"uniqueid"`
	LinkedID string `json:"linkedid,omitempty"`
}

type TranscriptionDrawer added in v0.5.0

type TranscriptionDrawer struct {
	UniqueID      string     `json:"uniqueid"`
	Transcription string     `json:"transcription"`
	Src           string     `json:"src,omitempty"`
	CNum          string     `json:"cnum,omitempty"`
	CNam          string     `json:"cnam,omitempty"`
	Company       string     `json:"company,omitempty"`
	CCompany      string     `json:"ccompany,omitempty"`
	DstCompany    string     `json:"dst_company,omitempty"`
	DstCNam       string     `json:"dst_cnam,omitempty"`
	Dst           string     `json:"dst,omitempty"`
	CallTimestamp *time.Time `json:"call_timestamp,omitempty"`
	CreatedAt     *time.Time `json:"created_at"`
}

type UserInfo added in v0.3.0

type UserInfo struct {
	DisplayName  string   `json:"-"`
	PhoneNumbers []string `json:"-"`
}

UserInfo contains the user data needed by transcript authorization checks.

func GetUserInfo added in v0.3.0

func GetUserInfo(nethCTIToken string) (*UserInfo, error)

GetUserInfo keeps compatibility with existing transcript checks by resolving the in-memory session token back to the local user/profile store.

type UserJWTOptions added in v0.5.0

type UserJWTOptions struct {
	Username    string
	OTPVerified bool
	IssuedAt    time.Time
	ExpiresAt   *time.Time
	Audience    string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL