Documentation
¶
Index ¶
- Constants
- Variables
- func IsScopeAllowed(scope string, userRole string, isCustomer bool) bool
- func IsValidScope(scope string) bool
- func RegisterScope(def *ScopeDefinition)
- func UnregisterScope(scope string)
- type APIToken
- type APITokenCreateRequest
- type APITokenCreateResponse
- type APITokenListItem
- type APITokenUserType
- type ChangePasswordRequest
- type DBGroupRole
- type DBRole
- type DBRoleUser
- type Facet
- type Group
- type GroupMembership
- type IdentityProvider
- type IdentityProviderOrg
- type IndexStats
- type LDAPAuthenticationLog
- type LDAPConfiguration
- type LDAPConnectionTest
- type LDAPGroupMapping
- type LDAPSyncHistory
- type LDAPSyncStatistics
- type LDAPUserMapping
- type LoginRequest
- type LoginResponse
- type LookupItem
- type Permission
- type RefreshTokenRequest
- type Role
- type ScopeDefinition
- type ScopeRegistry
- type SearchHit
- type SearchRequest
- type SearchResult
- type Session
- type SessionData
- type SystemMaintenance
- func (m *SystemMaintenance) Duration() int
- func (m *SystemMaintenance) GetLoginMessage() string
- func (m *SystemMaintenance) GetNotifyMessage() string
- func (m *SystemMaintenance) IsCurrentlyActive() bool
- func (m *SystemMaintenance) IsPast() bool
- func (m *SystemMaintenance) IsUpcoming(withinMinutes int) bool
- func (m *SystemMaintenance) IsValid() bool
- func (m *SystemMaintenance) ShowsLoginMessage() bool
- func (m *SystemMaintenance) StartDateFormatted() string
- func (m *SystemMaintenance) StartDateInput() string
- func (m *SystemMaintenance) StopDateFormatted() string
- func (m *SystemMaintenance) StopDateInput() string
- type User
- func (u *User) CheckPassword(password string) bool
- func (u *User) IncrementFailedLogin()
- func (u *User) IsActive() bool
- func (u *User) IsLocked() bool
- func (u *User) LockAccount(duration time.Duration)
- func (u *User) ResetFailedLogin()
- func (u *User) SetPassword(password string) error
- func (u *User) UnlockAccount()
- type UserRole
Constants ¶
const ( GroupTypeLocal = "local" GroupTypeLDAP = "ldap" GroupTypeExternal = "external" )
Common group types.
const ( GroupRoleMember = "member" GroupRoleAdmin = "admin" GroupRoleOwner = "owner" )
Common group roles.
const ( LDAPSyncStatusPending = "pending" LDAPSyncStatusRunning = "running" LDAPSyncStatusCompleted = "completed" LDAPSyncStatusFailed = "failed" LDAPSyncStatusCancelled = "cancelled" )
Constants for LDAP sync status.
const ( LDAPSyncTriggerManual = "manual" LDAPSyncTriggerScheduled = "scheduled" LDAPSyncTriggerAPI = "api" LDAPSyncTriggerStartup = "startup" )
Constants for LDAP sync triggers.
const ( RoleUser = "user" RoleGuest = "guest" )
Additional role names (RoleAdmin and RoleAgent are defined in user.go).
const ( PermissionViewTickets = "view_tickets" PermissionCreateTickets = "create_tickets" PermissionEditTickets = "edit_tickets" PermissionDeleteTickets = "delete_tickets" PermissionAssignTickets = "assign_tickets" PermissionViewAllTickets = "view_all_tickets" PermissionManageUsers = "manage_users" PermissionManageQueues = "manage_queues" PermissionManageSettings = "manage_settings" PermissionViewReports = "view_reports" PermissionManageTemplates = "manage_templates" PermissionManageWorkflows = "manage_workflows" )
Common permissions.
const ( SessionKeyUserID = "UserID" SessionKeyUserLogin = "UserLogin" SessionKeyUserType = "UserType" SessionKeyUserTitle = "UserTitle" SessionKeyUserFullname = "UserFullname" // OTRS uses lowercase 'n' SessionKeyCreateTime = "CreateTime" SessionKeyLastRequest = "LastRequest" SessionKeyUserRemoteAddr = "UserRemoteAddr" SessionKeyUserRemoteAgent = "UserRemoteUserAgent" )
Session data keys (matching OTRS conventions).
const ( UserTypeAgent = "User" UserTypeCustomer = "Customer" )
User type constants.
const DefaultRateLimit = 1000
DefaultRateLimit is the default rate limit for new tokens (requests per hour)
const TokenPrefix = "gf_"
TokenPrefix is the prefix for all API tokens
const TokenPrefixLength = 8
TokenPrefixLength is the length of the identifier prefix (after gf_)
const TokenRandomLength = 32
TokenRandomLength is the length of the random part of the token
Variables ¶
var PermissionTypes = []string{
"ro",
"move_into",
"create",
"note",
"owner",
"priority",
"rw",
}
Permission types (OTRS-compatible).
var ValidScopes = map[string]string{
"*": "Full access (inherits all user permissions)",
"tickets:read": "View tickets",
"tickets:write": "Create and update tickets",
"tickets:delete": "Delete tickets",
"articles:read": "Read ticket articles",
"articles:write": "Add articles and replies",
"users:read": "View user information",
"queues:read": "View queue information",
"admin:*": "Admin operations (agents only)",
}
ValidScopes defines the allowed scope values
Functions ¶
func IsScopeAllowed ¶
IsScopeAllowed checks if a scope is allowed for a given user context
func IsValidScope ¶
IsValidScope checks if a scope is valid (exists in registry)
func RegisterScope ¶
func RegisterScope(def *ScopeDefinition)
RegisterScope adds a scope to the registry (used by plugins)
func UnregisterScope ¶
func UnregisterScope(scope string)
UnregisterScope removes a scope (used when plugins unload)
Types ¶
type APIToken ¶
type APIToken struct {
ID int64 `json:"id" db:"id"`
UserID int `json:"user_id" db:"user_id"`
UserType APITokenUserType `json:"user_type" db:"user_type"`
Name string `json:"name" db:"name"`
Prefix string `json:"prefix" db:"prefix"`
TokenHash string `json:"-" db:"token_hash"` // Never expose hash
Scopes []string `json:"scopes,omitempty"` // Parsed from JSON
ScopesJSON sql.NullString `json:"-" db:"scopes"` // Raw JSON from DB
ExpiresAt sql.NullTime `json:"expires_at,omitempty" db:"expires_at"`
LastUsedAt sql.NullTime `json:"last_used_at,omitempty" db:"last_used_at"`
LastUsedIP sql.NullString `json:"last_used_ip,omitempty" db:"last_used_ip"`
RateLimit int `json:"rate_limit" db:"rate_limit"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
CreatedBy sql.NullInt64 `json:"created_by,omitempty" db:"created_by"`
RevokedAt sql.NullTime `json:"revoked_at,omitempty" db:"revoked_at"`
RevokedBy sql.NullInt64 `json:"revoked_by,omitempty" db:"revoked_by"`
CustomerLogin string `json:"customer_login,omitempty"` // For customer tokens: login from customer_user
}
APIToken represents a personal access token for API authentication
func (*APIToken) HasScope ¶
HasScope returns true if the token has the specified scope If scopes is nil/empty, token has all permissions (inherits from user)
type APITokenCreateRequest ¶
type APITokenCreateRequest struct {
Name string `json:"name" binding:"required,min=1,max=100"`
Scopes []string `json:"scopes,omitempty"`
ExpiresIn string `json:"expires_in,omitempty"` // "30d", "90d", "1y", "never"
}
APITokenCreateRequest represents a request to create a new token
type APITokenCreateResponse ¶
type APITokenCreateResponse struct {
ID int64 `json:"id"`
Name string `json:"name"`
Prefix string `json:"prefix"`
Token string `json:"token"` // Full token - shown only at creation
Scopes []string `json:"scopes,omitempty"`
ExpiresAt *string `json:"expires_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
Warning string `json:"warning"`
}
APITokenCreateResponse includes the full token (shown only once)
type APITokenListItem ¶
type APITokenListItem struct {
ID int64 `json:"id"`
Name string `json:"name"`
Prefix string `json:"prefix"`
Scopes []string `json:"scopes,omitempty"`
ExpiresAt *string `json:"expires_at,omitempty"`
LastUsedAt *string `json:"last_used_at,omitempty"`
CreatedAt string `json:"created_at"`
IsActive bool `json:"is_active"`
}
APITokenListItem represents a token in list responses (no secret)
type APITokenUserType ¶
type APITokenUserType string
APITokenUserType represents the type of user for API tokens
const ( APITokenUserAgent APITokenUserType = "agent" APITokenUserCustomer APITokenUserType = "customer" )
type ChangePasswordRequest ¶
type DBGroupRole ¶
type DBGroupRole struct {
RoleID int `json:"role_id"`
GroupID int `json:"group_id"`
PermissionKey string `json:"permission_key"`
PermissionValue int `json:"permission_value"`
CreateTime time.Time `json:"create_time"`
CreateBy int `json:"create_by"`
ChangeTime time.Time `json:"change_time"`
ChangeBy int `json:"change_by"`
}
Maps to the `group_role` table.
type DBRole ¶
type DBRole struct {
ID int `json:"id"`
Name string `json:"name"`
Comments string `json:"comments"`
ValidID int `json:"valid_id"`
CreateTime time.Time `json:"create_time"`
CreateBy int `json:"create_by"`
ChangeTime time.Time `json:"change_time"`
ChangeBy int `json:"change_by"`
}
Maps to the `roles` table.
type DBRoleUser ¶
type DBRoleUser struct {
UserID int `json:"user_id"`
RoleID int `json:"role_id"`
CreateTime time.Time `json:"create_time"`
CreateBy int `json:"create_by"`
ChangeTime time.Time `json:"change_time"`
ChangeBy int `json:"change_by"`
}
Maps to the `role_user` table.
type Group ¶
type Group struct {
// OTRS-compatible fields (required for database operations)
ID interface{} `json:"id"` // Can be int or string depending on context
Name string `json:"name"`
Comments string `json:"comments,omitempty"`
ValidID int `json:"valid_id,omitempty"`
CreateTime time.Time `json:"create_time,omitempty"`
CreateBy int `json:"create_by,omitempty"`
ChangeTime time.Time `json:"change_time,omitempty"`
ChangeBy int `json:"change_by,omitempty"`
// Additional fields for LDAP/extended functionality
Description string `json:"description,omitempty"`
Type string `json:"type,omitempty"` // ldap, local, external
DN string `json:"dn,omitempty"` // LDAP Distinguished Name
Members []string `json:"members,omitempty"` // User IDs
Permissions []string `json:"permissions,omitempty"`
IsActive bool `json:"is_active,omitempty"`
IsSystem bool `json:"is_system,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
}
Group represents a user group in the system.
type GroupMembership ¶
type GroupMembership struct {
GroupID string `json:"group_id"`
UserID string `json:"user_id"`
Role string `json:"role,omitempty"` // member, admin, etc.
AddedBy string `json:"added_by,omitempty"`
AddedAt time.Time `json:"added_at"`
}
GroupMembership represents a user's membership in a group.
type IdentityProvider ¶
type IdentityProvider struct {
ID uint `json:"id"`
OrgID *uint `json:"org_id,omitempty"`
Name string `json:"name"`
ProviderType string `json:"provider_type"`
ClientID string `json:"client_id"`
ClientSecret string `json:"-"`
DiscoveryURL string `json:"discovery_url"`
SigningCert string `json:"signing_cert"`
PrivateKey string `json:"-"`
EntityID string `json:"entity_id"`
ACSURL string `json:"acs_url"`
IdPMetadataXML string `json:"idp_metadata_xml"`
Scopes string `json:"scopes"`
UserClaimEmail string `json:"user_claim_email"`
UserClaimName string `json:"user_claim_name"`
UserClaimGroups string `json:"user_claim_groups"`
Enabled bool `json:"enabled"`
AutoProvision bool `json:"auto_provision"`
UserTable string `json:"user_table"`
AutoAddToGroup string `json:"auto_add_to_group"`
CreateTime time.Time `json:"create_time"`
CreateBy uint `json:"create_by"`
ChangeTime time.Time `json:"change_time"`
ChangeBy uint `json:"change_by"`
}
func (*IdentityProvider) GetProviderType ¶
func (m *IdentityProvider) GetProviderType() string
func (*IdentityProvider) IsActive ¶
func (m *IdentityProvider) IsActive() bool
type IdentityProviderOrg ¶
type IndexStats ¶
type IndexStats struct {
Name string `json:"name"`
DocumentCount int64 `json:"document_count"`
StorageSize int64 `json:"storage_size"`
LastUpdated time.Time `json:"last_updated"`
Status string `json:"status"`
}
IndexStats represents search index statistics (Zinc-specific).
type LDAPAuthenticationLog ¶
type LDAPAuthenticationLog struct {
ID int `json:"id" db:"id"`
ConfigID int `json:"config_id" db:"config_id"`
Username string `json:"username" db:"username"`
UserID *int `json:"user_id" db:"user_id"`
Success bool `json:"success" db:"success"`
ErrorMessage string `json:"error_message" db:"error_message"`
IPAddress string `json:"ip_address" db:"ip_address"`
UserAgent string `json:"user_agent" db:"user_agent"`
AuthTime time.Time `json:"auth_time" db:"auth_time"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
}
LDAPAuthenticationLog represents LDAP authentication attempts.
type LDAPConfiguration ¶
type LDAPConfiguration struct {
ID int `json:"id" db:"id"`
Name string `json:"name" db:"name"`
Host string `json:"host" db:"host"`
Port int `json:"port" db:"port"`
BaseDN string `json:"base_dn" db:"base_dn"`
BindDN string `json:"bind_dn" db:"bind_dn"`
BindPassword string `json:"bind_password" db:"bind_password"`
UserFilter string `json:"user_filter" db:"user_filter"`
UserSearchBase string `json:"user_search_base" db:"user_search_base"`
GroupFilter string `json:"group_filter" db:"group_filter"`
GroupSearchBase string `json:"group_search_base" db:"group_search_base"`
UseTLS bool `json:"use_tls" db:"use_tls"`
StartTLS bool `json:"start_tls" db:"start_tls"`
InsecureSkipVerify bool `json:"insecure_skip_verify" db:"insecure_skip_verify"`
AttributeMapping string `json:"attribute_mapping" db:"attribute_mapping"` // JSON
GroupMemberAttribute string `json:"group_member_attribute" db:"group_member_attribute"`
AutoCreateUsers bool `json:"auto_create_users" db:"auto_create_users"`
AutoUpdateUsers bool `json:"auto_update_users" db:"auto_update_users"`
AutoCreateGroups bool `json:"auto_create_groups" db:"auto_create_groups"`
SyncIntervalMinutes int `json:"sync_interval_minutes" db:"sync_interval_minutes"`
DefaultRoleID int `json:"default_role_id" db:"default_role_id"`
AdminGroups string `json:"admin_groups" db:"admin_groups"` // JSON array
UserGroups string `json:"user_groups" db:"user_groups"` // JSON array
IsActive bool `json:"is_active" db:"is_active"`
TestMode bool `json:"test_mode" db:"test_mode"`
LastSyncAt *time.Time `json:"last_sync_at" db:"last_sync_at"`
SyncStatus string `json:"sync_status" db:"sync_status"`
SyncMessage string `json:"sync_message" db:"sync_message"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
CreatedBy int `json:"created_by" db:"created_by"`
UpdatedBy int `json:"updated_by" db:"updated_by"`
}
LDAPConfiguration represents LDAP configuration stored in database.
type LDAPConnectionTest ¶
type LDAPConnectionTest struct {
Success bool `json:"success"`
ErrorMessage string `json:"error_message,omitempty"`
ResponseTime int64 `json:"response_time"` // Milliseconds
ServerInfo string `json:"server_info,omitempty"`
UserCount int `json:"user_count,omitempty"`
GroupCount int `json:"group_count,omitempty"`
TestedAt time.Time `json:"tested_at"`
}
LDAPConnectionTest represents a test connection result.
type LDAPGroupMapping ¶
type LDAPGroupMapping struct {
ID int `json:"id" db:"id"`
GroupID int `json:"group_id" db:"group_id"`
ConfigID int `json:"config_id" db:"config_id"`
LDAPGroupDN string `json:"ldap_group_dn" db:"ldap_group_dn"`
LDAPGroupName string `json:"ldap_group_name" db:"ldap_group_name"`
LDAPObjectGUID string `json:"ldap_object_guid" db:"ldap_object_guid"`
LDAPObjectSID string `json:"ldap_object_sid" db:"ldap_object_sid"`
RoleMapping string `json:"role_mapping" db:"role_mapping"` // JSON
LastSyncAt time.Time `json:"last_sync_at" db:"last_sync_at"`
IsActive bool `json:"is_active" db:"is_active"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}
LDAPGroupMapping represents mapping between LDAP and GoatFlow groups.
type LDAPSyncHistory ¶
type LDAPSyncHistory struct {
ID int `json:"id" db:"id"`
ConfigID int `json:"config_id" db:"config_id"`
StartTime time.Time `json:"start_time" db:"start_time"`
EndTime *time.Time `json:"end_time" db:"end_time"`
Status string `json:"status" db:"status"` // running, completed, failed
UsersFound int `json:"users_found" db:"users_found"`
UsersCreated int `json:"users_created" db:"users_created"`
UsersUpdated int `json:"users_updated" db:"users_updated"`
UsersDisabled int `json:"users_disabled" db:"users_disabled"`
GroupsFound int `json:"groups_found" db:"groups_found"`
GroupsCreated int `json:"groups_created" db:"groups_created"`
GroupsUpdated int `json:"groups_updated" db:"groups_updated"`
ErrorCount int `json:"error_count" db:"error_count"`
ErrorLog string `json:"error_log" db:"error_log"` // JSON array of errors
Duration int64 `json:"duration" db:"duration"` // Milliseconds
TriggeredBy string `json:"triggered_by" db:"triggered_by"` // manual, scheduled, api
CreatedAt time.Time `json:"created_at" db:"created_at"`
}
LDAPSyncHistory represents LDAP sync history.
type LDAPSyncStatistics ¶
type LDAPSyncStatistics struct {
ConfigID int `json:"config_id"`
TotalSyncs int `json:"total_syncs"`
SuccessfulSyncs int `json:"successful_syncs"`
FailedSyncs int `json:"failed_syncs"`
LastSyncAt *time.Time `json:"last_sync_at"`
LastSuccessfulSync *time.Time `json:"last_successful_sync"`
AverageDuration int64 `json:"average_duration"` // Milliseconds
TotalUsersCreated int `json:"total_users_created"`
TotalUsersUpdated int `json:"total_users_updated"`
TotalGroupsCreated int `json:"total_groups_created"`
TotalGroupsUpdated int `json:"total_groups_updated"`
ErrorRate float64 `json:"error_rate"`
}
LDAPSyncStatistics represents aggregated sync statistics.
type LDAPUserMapping ¶
type LDAPUserMapping struct {
ID int `json:"id" db:"id"`
UserID int `json:"user_id" db:"user_id"`
ConfigID int `json:"config_id" db:"config_id"`
LDAPUserDN string `json:"ldap_user_dn" db:"ldap_user_dn"`
LDAPUsername string `json:"ldap_username" db:"ldap_username"`
LDAPObjectGUID string `json:"ldap_object_guid" db:"ldap_object_guid"`
LDAPObjectSID string `json:"ldap_object_sid" db:"ldap_object_sid"`
LDAPAttributes string `json:"ldap_attributes" db:"ldap_attributes"` // JSON
LastSyncAt time.Time `json:"last_sync_at" db:"last_sync_at"`
IsActive bool `json:"is_active" db:"is_active"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}
LDAPUserMapping represents mapping between LDAP and GoatFlow users.
type LoginRequest ¶
type LoginResponse ¶
type LookupItem ¶
type LookupItem struct {
ID int `json:"id"`
Value string `json:"value"`
Label string `json:"label"`
Order int `json:"order"`
Active bool `json:"active"`
}
LookupItem represents a generic lookup value (priority, type, status, etc.)
type Permission ¶
type Permission struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Category string `json:"category"`
IsSystem bool `json:"is_system"`
}
Permission represents a system permission.
type RefreshTokenRequest ¶
type RefreshTokenRequest struct {
RefreshToken string `json:"refresh_token" binding:"required"`
}
type Role ¶
type Role struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Permissions []string `json:"permissions"`
IsSystem bool `json:"is_system"`
IsActive bool `json:"is_active"`
Metadata map[string]string `json:"metadata,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Role represents a user role in the system.
type ScopeDefinition ¶
type ScopeDefinition struct {
Scope string `json:"scope"`
Description string `json:"description"`
Category string `json:"category"` // e.g., "core", "plugin:myplugin"
RequireRole string `json:"require_role"` // e.g., "Admin", "Agent", "" (any)
AgentOnly bool `json:"agent_only"` // If true, not available to customers
}
ScopeDefinition defines an API token scope
func GetAllScopes ¶
func GetAllScopes() []*ScopeDefinition
GetAllScopes returns all registered scopes (for admin/debugging)
func GetAvailableScopes ¶
func GetAvailableScopes(userRole string, isCustomer bool) []*ScopeDefinition
GetAvailableScopes returns scopes available for a given user context
type ScopeRegistry ¶
type ScopeRegistry struct {
// contains filtered or unexported fields
}
ScopeRegistry manages available API token scopes
type SearchHit ¶
type SearchHit struct {
ID string `json:"id"`
Type string `json:"type"`
Score float64 `json:"score"`
Source map[string]interface{} `json:"source"`
Highlights map[string][]string `json:"highlights,omitempty"`
Timestamp time.Time `json:"timestamp"`
}
SearchHit represents a single search result.
type SearchRequest ¶
type SearchRequest struct {
Query string `json:"query" binding:"required"`
Type string `json:"type,omitempty"` // tickets, notes, customers
Filters map[string]string `json:"filters,omitempty"`
DateFrom *time.Time `json:"date_from,omitempty"`
DateTo *time.Time `json:"date_to,omitempty"`
Page int `json:"page,omitempty"`
PageSize int `json:"page_size,omitempty"`
SortBy string `json:"sort_by,omitempty"`
SortOrder string `json:"sort_order,omitempty"`
Highlight bool `json:"highlight,omitempty"`
Facets []string `json:"facets,omitempty"`
}
SearchRequest represents a search query.
type SearchResult ¶
type SearchResult struct {
Query string `json:"query"`
TotalHits int64 `json:"total_hits"`
Page int `json:"page"`
PageSize int `json:"page_size"`
TotalPages int `json:"total_pages"`
Took int64 `json:"took_ms"`
Hits []SearchHit `json:"hits"`
Facets map[string][]Facet `json:"facets,omitempty"`
Suggestions []string `json:"suggestions,omitempty"`
}
SearchResult represents search results.
type Session ¶
type Session struct {
SessionID string `json:"session_id"`
UserID int `json:"user_id"`
UserLogin string `json:"user_login"`
UserType string `json:"user_type"` // "User" (agent) or "Customer"
UserTitle string `json:"user_title"`
UserFullName string `json:"user_full_name"`
CreateTime time.Time `json:"create_time"`
LastRequest time.Time `json:"last_request"`
RemoteAddr string `json:"remote_addr"`
UserAgent string `json:"user_agent"`
}
Session represents an active user session. The OTRS sessions table uses a key-value store format with columns: session_id, data_key, data_value, serialized
type SessionData ¶
type SessionData struct {
SessionID string `json:"session_id"`
DataKey string `json:"data_key"`
DataValue string `json:"data_value"`
Serialized int `json:"serialized"` // 0=plain text, 1=serialized
}
SessionData represents a key-value pair in the sessions table.
type SystemMaintenance ¶
type SystemMaintenance struct {
ID int `json:"id"`
StartDate int64 `json:"start_date"` // Unix epoch timestamp
StopDate int64 `json:"stop_date"` // Unix epoch timestamp
Comments string `json:"comments"` // Admin reference/description
LoginMessage *string `json:"login_message"` // Message shown on login page
ShowLoginMessage int `json:"show_login_message"` // 0 or 1
NotifyMessage *string `json:"notify_message"` // Notification banner message
ValidID int `json:"valid_id"` // 1=valid, 2=invalid
CreateTime time.Time `json:"create_time"`
CreateBy int `json:"create_by"`
ChangeTime time.Time `json:"change_time"`
ChangeBy int `json:"change_by"`
}
SystemMaintenance represents a scheduled system maintenance window. This maps directly to the OTRS system_maintenance table.
func (*SystemMaintenance) Duration ¶
func (m *SystemMaintenance) Duration() int
Duration returns the maintenance duration in minutes.
func (*SystemMaintenance) GetLoginMessage ¶
func (m *SystemMaintenance) GetLoginMessage() string
GetLoginMessage returns the login message or empty string if nil.
func (*SystemMaintenance) GetNotifyMessage ¶
func (m *SystemMaintenance) GetNotifyMessage() string
GetNotifyMessage returns the notify message or empty string if nil.
func (*SystemMaintenance) IsCurrentlyActive ¶
func (m *SystemMaintenance) IsCurrentlyActive() bool
IsCurrentlyActive returns true if the maintenance is currently active.
func (*SystemMaintenance) IsPast ¶
func (m *SystemMaintenance) IsPast() bool
IsPast returns true if the maintenance window has ended.
func (*SystemMaintenance) IsUpcoming ¶
func (m *SystemMaintenance) IsUpcoming(withinMinutes int) bool
IsUpcoming returns true if the maintenance starts within the given minutes.
func (*SystemMaintenance) IsValid ¶
func (m *SystemMaintenance) IsValid() bool
IsValid returns true if the maintenance record is valid.
func (*SystemMaintenance) ShowsLoginMessage ¶
func (m *SystemMaintenance) ShowsLoginMessage() bool
ShowsLoginMessage returns true if the login message should be displayed.
func (*SystemMaintenance) StartDateFormatted ¶
func (m *SystemMaintenance) StartDateFormatted() string
StartDateFormatted returns the start date as a formatted string for display.
func (*SystemMaintenance) StartDateInput ¶
func (m *SystemMaintenance) StartDateInput() string
StartDateInput returns the start date formatted for HTML datetime-local input.
func (*SystemMaintenance) StopDateFormatted ¶
func (m *SystemMaintenance) StopDateFormatted() string
StopDateFormatted returns the stop date as a formatted string for display.
func (*SystemMaintenance) StopDateInput ¶
func (m *SystemMaintenance) StopDateInput() string
StopDateInput returns the stop date formatted for HTML datetime-local input.
type User ¶
type User struct {
ID uint `json:"id" db:"id"`
Login string `json:"login" db:"login"`
Email string `json:"email"` // Not in users table, use login as email
Password string `json:"-" db:"pw"` // Never expose in JSON
Title string `json:"title" db:"title"`
FirstName string `json:"first_name" db:"first_name"`
LastName string `json:"last_name" db:"last_name"`
ValidID int `json:"valid_id" db:"valid_id"` // OTRS valid field (1=valid, 2=invalid, 3=invalid-temporarily)
CreateTime time.Time `json:"create_time" db:"create_time"`
CreateBy int `json:"create_by" db:"create_by"`
ChangeTime time.Time `json:"change_time" db:"change_time"`
ChangeBy int `json:"change_by" db:"change_by"`
Role string `json:"role"` // Admin, Agent, Customer
IsInAdminGroup bool `json:"is_in_admin_group,omitempty"` // User is in admin group (for nav display)
TenantID uint `json:"tenant_id,omitempty"`
LastLogin *time.Time `json:"last_login,omitempty"`
FailedLoginCount int `json:"-"`
LockedUntil *time.Time `json:"-"`
Groups []string `json:"groups,omitempty"` // Group names for the user
}
func (*User) CheckPassword ¶
func (*User) IncrementFailedLogin ¶
func (u *User) IncrementFailedLogin()
func (*User) LockAccount ¶
func (*User) ResetFailedLogin ¶
func (u *User) ResetFailedLogin()
func (*User) SetPassword ¶
func (*User) UnlockAccount ¶
func (u *User) UnlockAccount()