Documentation
¶
Overview ¶
Package sysconfig provides system configuration management.
Index ¶
- func SaveCustomerPortalConfig(db *sql.DB, cfg CustomerPortalConfig, userID int) error
- func SaveCustomerPortalConfigForCompany(db *sql.DB, customerID string, cfg CustomerPortalConfig, userID int) error
- type CustomerPortalConfig
- type DeployedConfig
- type Manager
- func (m *Manager) Deploy(outputPath string) error
- func (m *Manager) Get(name string) (interface{}, error)
- func (m *Manager) GetArray(name string) []string
- func (m *Manager) GetBool(name string) bool
- func (m *Manager) GetInt(name string) int
- func (m *Manager) GetSettings() map[string]*Setting
- func (m *Manager) GetString(name string) string
- func (m *Manager) Load() error
- func (m *Manager) Reset(name string, userID int) error
- func (m *Manager) Set(name, value string, userID int) error
- type Option
- type PasswordPolicy
- type PasswordValidationError
- type Setting
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SaveCustomerPortalConfig ¶
func SaveCustomerPortalConfig(db *sql.DB, cfg CustomerPortalConfig, userID int) error
SaveCustomerPortalConfig persists portal settings as sysconfig overrides.
func SaveCustomerPortalConfigForCompany ¶
func SaveCustomerPortalConfigForCompany(db *sql.DB, customerID string, cfg CustomerPortalConfig, userID int) error
SaveCustomerPortalConfigForCompany writes overrides scoped to a specific customer, creating defaults on demand.
Types ¶
type CustomerPortalConfig ¶
type CustomerPortalConfig struct {
Enabled bool
LoginRequired bool
Title string
LandingPage string
}
CustomerPortalConfig holds global portal settings stored in sysconfig tables.
func DefaultCustomerPortalConfig ¶
func DefaultCustomerPortalConfig() CustomerPortalConfig
DefaultCustomerPortalConfig returns the built-in defaults when no sysconfig rows exist.
func LoadCustomerPortalConfig ¶
func LoadCustomerPortalConfig(db *sql.DB) (CustomerPortalConfig, error)
LoadCustomerPortalConfig reads portal settings from sysconfig tables.
func LoadCustomerPortalConfigForCompany ¶
func LoadCustomerPortalConfigForCompany(db *sql.DB, customerID string) (CustomerPortalConfig, error)
LoadCustomerPortalConfigForCompany returns overrides for a specific customer when present, falling back to global values.
type DeployedConfig ¶
type DeployedConfig struct {
Version string `yaml:"version"`
Timestamp time.Time `yaml:"timestamp"`
Settings map[string]interface{} `yaml:"settings"`
Metadata map[string]interface{} `yaml:"metadata"`
}
DeployedConfig represents the deployed configuration file structure.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles system configuration loading and deployment.
func NewManager ¶
NewManager creates a new configuration manager.
func (*Manager) GetSettings ¶
GetSettings returns all settings for UI display.
type PasswordPolicy ¶
type PasswordPolicy struct {
// PasswordRegExp is a custom regex pattern that passwords must match.
// Example: "[a-z]|[A-Z]|[0-9]" requires at least one letter or digit.
PasswordRegExp string `json:"password_reg_exp"`
// PasswordMinSize is the minimum password length. 0 = disabled.
PasswordMinSize int `json:"password_min_size"`
// PasswordMin2Lower2UpperCharacters requires at least 2 lowercase AND 2 uppercase letters.
PasswordMin2Lower2UpperCharacters bool `json:"password_min_2_lower_2_upper_characters"`
// PasswordMin2Characters requires at least 2 letter characters (alphabetic).
PasswordMin2Characters bool `json:"password_min_2_characters"`
// PasswordNeedDigit requires at least 1 digit (0-9).
PasswordNeedDigit bool `json:"password_need_digit"`
// PasswordMaxLoginFailed is the max failed login attempts before account locked (0 = disabled).
// Note: This is only used for agents, not customers in OTRS.
PasswordMaxLoginFailed int `json:"password_max_login_failed"`
}
PasswordPolicy holds OTRS-compatible password policy settings. These settings are stored in sysconfig_default with names like: - CustomerPreferencesGroups###Password (for customers) - PreferencesGroups###Password (for agents)
func DefaultAgentPasswordPolicy ¶
func DefaultAgentPasswordPolicy() PasswordPolicy
DefaultAgentPasswordPolicy returns default policy for agents (all disabled, matching OTRS defaults).
func DefaultCustomerPasswordPolicy ¶
func DefaultCustomerPasswordPolicy() PasswordPolicy
DefaultCustomerPasswordPolicy returns default policy (all disabled, matching OTRS defaults).
func LoadAgentPasswordPolicy ¶
func LoadAgentPasswordPolicy(db *sql.DB) (PasswordPolicy, error)
LoadAgentPasswordPolicy loads agent password policy from sysconfig.
func LoadCustomerPasswordPolicy ¶
func LoadCustomerPasswordPolicy(db *sql.DB) (PasswordPolicy, error)
LoadCustomerPasswordPolicy loads customer password policy from sysconfig.
func (*PasswordPolicy) GetRequirements ¶
func (p *PasswordPolicy) GetRequirements() []string
GetRequirements returns a list of active password requirements for display.
func (*PasswordPolicy) HasRequirements ¶
func (p *PasswordPolicy) HasRequirements() bool
HasRequirements returns true if any password policy rules are enabled.
func (*PasswordPolicy) ValidatePassword ¶
func (p *PasswordPolicy) ValidatePassword(password string) *PasswordValidationError
ValidatePassword validates a password against the policy. Returns nil if valid, or a PasswordValidationError if invalid. Validation order matches OTRS: RegExp -> MinSize -> 2Lower2Upper -> NeedDigit -> 2Characters
type PasswordValidationError ¶
PasswordValidationError holds details about why password validation failed.
type Setting ¶
type Setting struct {
ID int `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
IsInvisible bool `json:"is_invisible"`
IsReadonly bool `json:"is_readonly"`
IsRequired bool `json:"is_required"`
IsValid bool `json:"is_valid"`
HasConfigLevel int `json:"has_configlevel"`
UserModificationPossible bool `json:"user_modification_possible"`
UserModificationActive bool `json:"user_modification_active"`
XMLContentRaw string `json:"xml_content_raw"`
XMLContentParsed string `json:"xml_content_parsed"`
XMLFilename string `json:"xml_filename"`
EffectiveValue string `json:"effective_value"`
CreateTime time.Time `json:"create_time"`
ChangeTime time.Time `json:"change_time"`
CreateBy int `json:"create_by"`
ChangeBy int `json:"change_by"`
// Parsed configuration data
Type string `json:"type"`
Default interface{} `json:"default"`
Options []Option `json:"options,omitempty"`
Min *int `json:"min,omitempty"`
Max *int `json:"max,omitempty"`
Validation string `json:"validation,omitempty"`
DependsOn string `json:"depends_on,omitempty"`
DependsValue string `json:"depends_value,omitempty"`
}
Setting represents a configuration setting.