config

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2025 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Matcher             language.Matcher
	DefaultLanguageTags []language.Tag
)

Functions

func ReloadConfigFile

func ReloadConfigFile() (err error)

ReloadConfigFile is a thread safe function to reload a ConfigFile object.

func SetTestFile added in v1.4.10

func SetTestFile(testFile File)

SetTestFile sets the global `file` variable to the provided `testFile` implementing the `File` interface.

Types

type Backend

type Backend struct {
	// contains filtered or unexported fields
}

Backend is a password Database container.

func (*Backend) Get

func (b *Backend) Get() definitions.Backend

Get gets the name of a password Database.

func (*Backend) GetName added in v1.5.0

func (b *Backend) GetName() string

GetName returns the name of the Backend instance or an empty string if the instance is nil.

func (*Backend) Set

func (b *Backend) Set(value string) error

Set updates the backend of the Backend based on the provided value. It returns an error if the value is not valid. Valid values for the backend are "cache", "ldap" and "lua". If the value is valid, the backend field of Backend is updated accordingly. An error of type ErrWrongPassDB is returned if the value is not valid.

func (*Backend) String

func (b *Backend) String() string

func (*Backend) Type

func (b *Backend) Type() string

Type returns the name of the type.

type BackendServer

type BackendServer struct {
	Protocol      string `mapstructure:"protocol" validate:"required,oneof=imap pop3 lmtp smtp sieve http"`
	Host          string `mapstructure:"host" validate:"required,hostname|ip"`
	DeepCheck     bool   `mapstructure:"deep_check"`
	RequestURI    string `mapstructure:"request_uri" validate:"omitempty,url_encoded"`
	TestUsername  string `mapstructure:"test_username" validate:"omitempty,excludesall= "`
	TestPassword  string `mapstructure:"test_password" validate:"omitempty,excludesall= "`
	Port          int    `mapstructure:"port" validate:"omitempty,min=1,max=65535"`
	TLS           bool   `mapstructure:"tls"`
	TLSSkipVerify bool   `mapstructure:"tls_skip_verify"`
	HAProxyV2     bool   `mapstructure:"haproxy_v2"`
}

func (*BackendServer) String

func (n *BackendServer) String() string

type BackendServerMonitoring

type BackendServerMonitoring struct {
	BackendServers []*BackendServer `mapstructure:"backend_servers" validate:"required,dive"`
}

func (*BackendServerMonitoring) String added in v1.3.5

func (n *BackendServerMonitoring) String() string

type BasicAuth

type BasicAuth struct {
	Enabled  bool   `mapstructure:"enabled"`
	Username string `mapstructure:"username" validate:"omitempty,excludesall= "`
	Password string `mapstructure:"password" validate:"omitempty,min=16,alphanumunicode,excludesall= "`
}

BasicAuth represents the configuration for basic HTTP authentication.

func (*BasicAuth) GetPassword added in v1.4.11

func (b *BasicAuth) GetPassword() string

GetPassword retrieves the password for the BasicAuth configuration.

func (*BasicAuth) GetUsername added in v1.4.11

func (b *BasicAuth) GetUsername() string

GetUsername returns the username configured for basic HTTP authentication.

func (*BasicAuth) IsEnabled added in v1.4.11

func (b *BasicAuth) IsEnabled() bool

IsEnabled returns true if basic HTTP authentication is enabled, otherwise false.

type BruteForceRule

type BruteForceRule struct {
	Name           string        `mapstructure:"name" validate:"required"`
	Period         time.Duration `mapstructure:"period" validate:"required,gt=0,max=8760h"`
	CIDR           uint          `mapstructure:"cidr" validate:"required,min=1,max=128"`
	IPv4           bool
	IPv6           bool
	FailedRequests uint `mapstructure:"failed_requests" validate:"required,min=1"`
}

BruteForceRule is the definition of a brute force rule as defined in the configuration file. See the markdown documentation for a description of the field names.

func (*BruteForceRule) String added in v1.4.9

func (b *BruteForceRule) String() string

type BruteForceSection

type BruteForceSection struct {
	SoftWhitelist     `mapstructure:"soft_whitelist"`
	IPWhitelist       []string         `mapstructure:"ip_whitelist" validate:"omitempty,dive,ip_addr|cidr"`
	Buckets           []BruteForceRule `mapstructure:"buckets" validate:"required,dive"`
	Learning          []*Feature       `mapstructure:"learning" validate:"omitempty,dive"`
	ToleratePercent   uint8            `mapstructure:"tolerate_percent" validate:"omitempty,min=0,max=100"`
	CustomTolerations []Tolerate       `mapstructure:"custom_tolerations" validate:"omitempty,dive"`
	TolerateTTL       time.Duration    `mapstructure:"tolerate_ttl" validate:"omitempty,gt=0,max=8760h"`
}

func (*BruteForceSection) GetCustomTolerations added in v1.5.1

func (b *BruteForceSection) GetCustomTolerations() []Tolerate

GetCustomTolerations returns the CustomTolerations slice from the BruteForceSection. Returns nil if the receiver is nil.

func (*BruteForceSection) GetToleratePercent added in v1.5.1

func (b *BruteForceSection) GetToleratePercent() uint8

GetToleratePercent retrieves the ToleratePercent value from the BruteForceSection instance. Returns 0 if the receiver is nil.

func (*BruteForceSection) GetTolerateTTL added in v1.5.1

func (b *BruteForceSection) GetTolerateTTL() time.Duration

GetTolerateTTL retrieves the TolerateTTL value from the BruteForceSection instance. Returns 0 if the receiver is nil.

func (*BruteForceSection) LearnFromFeature added in v1.3.5

func (b *BruteForceSection) LearnFromFeature(input string) bool

LearnFromFeature checks if the given feature is present in the Learning slice of the BruteForceSection. It returns true if the feature is found, otherwise false.

func (*BruteForceSection) String

func (b *BruteForceSection) String() string

type Cluster

type Cluster struct {
	Addresses []string `mapstructure:"addresses" validate:"required,dive,hostname_port"`
	Username  string   `mapstructure:"username" validate:"omitempty,excludesall= "`
	Password  string   `mapstructure:"password" validate:"omitempty,excludesall= "`
}

Cluster represents the configuration for a Redis cluster setup.

func (*Cluster) GetAddresses added in v1.4.11

func (c *Cluster) GetAddresses() []string

GetAddresses retrieves the list of Redis cluster addresses configured in the Cluster instance.

func (*Cluster) GetPassword added in v1.4.11

func (c *Cluster) GetPassword() string

GetPassword retrieves the password configured for the Redis cluster.

func (*Cluster) GetUsername added in v1.4.11

func (c *Cluster) GetUsername() string

GetUsername retrieves the username configured for the Redis cluster.

type DNS

type DNS struct {
	Resolver        string        `mapstructure:"resolver" validate:"omitempty,tcp_addr"`
	Timeout         time.Duration `mapstructure:"timeout" validate:"omitempty,gt=0,max=30s"`
	ResolveClientIP bool          `mapstructure:"resolve_client_ip"`
}

DNS represents the Domain Name System configuration settings, including resolver, timeout, and client IP resolution options.

func (*DNS) GetResolveClientIP added in v1.4.11

func (d *DNS) GetResolveClientIP() bool

GetResolveClientIP returns the value of the ResolveClientIP field indicating whether client IP resolution is enabled.

func (*DNS) GetResolver added in v1.4.11

func (d *DNS) GetResolver() string

GetResolver returns the configured DNS resolver address as a string.

func (*DNS) GetTimeout added in v1.4.11

func (d *DNS) GetTimeout() time.Duration

GetTimeout returns the timeout duration configured for the DNS resolver.

type DbgModule

type DbgModule struct {
	// contains filtered or unexported fields
}

DbgModule represents a debugging module configuration.

func (*DbgModule) Get

func (d *DbgModule) Get() string

Get returns the name of the `DbgModule` instance. The name represents the current debug module. It can be used to identify the debug module when needed.

func (*DbgModule) GetModule

func (d *DbgModule) GetModule() definitions.DbgModule

GetModule returns the `module` field of the `DbgModule` struct. It is used to retrieve the current debug module.

Usage:

module := d.GetModule()

Example:

func main() {
  dbg := &DbgModule{}
  module := dbg.GetModule()
  fmt.Println(module) // Output: 0
}

func (*DbgModule) Set

func (d *DbgModule) Set(value string) error

Set updates the debug module based on the provided value. It returns an error if the value is not valid. Valid values for the debug module are "none", "all", "auth", "hydra", "webauthn", "statistics", "whitelist", "ldap", "ldappool", "sql", "cache", "bf", "rbl", "action", "feature", and "lua". If the value is valid, the module and name fields are updated accordingly. An error of type ErrWrongDebugModule is returned if the value is not valid.

func (*DbgModule) String

func (d *DbgModule) String() string

func (*DbgModule) Type

func (d *DbgModule) Type() string

Type returns the type of the DbgModule, which is always "DebugModule".

type DefaultHTTPRequestHeader added in v1.3.0

type DefaultHTTPRequestHeader struct {
	Username           string `mapstructure:"username" validate:"omitempty,printascii,excludesall= "`
	Password           string `mapstructure:"password" validate:"omitempty,printascii,excludesall= "`
	PasswordEncoded    string `mapstructure:"password_encoded" validate:"omitempty,printascii,excludesall= "`
	Protocol           string `mapstructure:"protocol" validate:"omitempty,printascii,excludesall= "`
	LoginAttempt       string `mapstructure:"login_attempt" validate:"omitempty,printascii,excludesall= "`
	AuthMethod         string `mapstructure:"auth_method" validate:"omitempty,printascii,excludesall= "`
	LocalIP            string `mapstructure:"local_ip" validate:"omitempty,printascii,excludesall= "`
	LocalPort          string `mapstructure:"local_port" validate:"omitempty,printascii,excludesall= "`
	ClientIP           string `mapstructure:"client_ip" validate:"omitempty,printascii,excludesall= "`
	ClientPort         string `mapstructure:"client_port" validate:"omitempty,printascii,excludesall= "`
	ClientHost         string `mapstructure:"client_host" validate:"omitempty,printascii,excludesall= "`
	ClientID           string `mapstructure:"client_id" validate:"omitempty,printascii,excludesall= "`
	SSL                string `mapstructure:"ssl" validate:"omitempty,printascii,excludesall= "`
	SSLSessionID       string `mapstructure:"ssl_session_id" validate:"omitempty,printascii,excludesall= "`
	SSLVerify          string `mapstructure:"ssl_verify" validate:"omitempty,printascii,excludesall= "`
	SSLSubject         string `mapstructure:"ssl_subject" validate:"omitempty,printascii,excludesall= "`
	SSLClientCN        string `mapstructure:"ssl_client_cn" validate:"omitempty,printascii,excludesall= "`
	SSLIssuer          string `mapstructure:"ssl_issuer" validate:"omitempty,printascii,excludesall= "`
	SSLClientNotBefore string `mapstructure:"ssl_client_not_before" validate:"omitempty,printascii,excludesall= "`
	SSLClientNotAfter  string `mapstructure:"ssl_client_not_after" validate:"omitempty,printascii,excludesall= "`
	SSLSubjectDN       string `mapstructure:"ssl_subject_dn" validate:"omitempty,printascii,excludesall= "`
	SSLIssuerDN        string `mapstructure:"ssl_issuer_dn" validate:"omitempty,printascii,excludesall= "`
	SSLClientSubjectDN string `mapstructure:"ssl_client_subject_dn" validate:"omitempty,printascii,excludesall= "`
	SSLClientIssuerDN  string `mapstructure:"ssl_client_issuer_dn" validate:"omitempty,printascii,excludesall= "`
	SSLCipher          string `mapstructure:"ssl_cipher" validate:"omitempty,printascii,excludesall= "`
	SSLProtocol        string `mapstructure:"ssl_protocol" validate:"omitempty,printascii,excludesall= "`
	SSLSerial          string `mapstructure:"ssl_serial" validate:"omitempty,printascii,excludesall= "`
	SSLFingerprint     string `mapstructure:"ssl_fingerprint" validate:"omitempty,printascii,excludesall= "`
}

DefaultHTTPRequestHeader represents the default headers to include in every HTTP request. This struct includes fields for authentication, SSL/TLS, and client/server metadata.

func (*DefaultHTTPRequestHeader) GetAuthMethod added in v1.4.11

func (d *DefaultHTTPRequestHeader) GetAuthMethod() string

GetAuthMethod retrieves the authentication method value from the DefaultHTTPRequestHeader struct.

func (*DefaultHTTPRequestHeader) GetClientHost added in v1.4.11

func (d *DefaultHTTPRequestHeader) GetClientHost() string

GetClientHost retrieves the client host value from the DefaultHTTPRequestHeader struct.

func (*DefaultHTTPRequestHeader) GetClientID added in v1.4.11

func (d *DefaultHTTPRequestHeader) GetClientID() string

GetClientID retrieves the client identifier from the DefaultHTTPRequestHeader struct.

func (*DefaultHTTPRequestHeader) GetClientIP added in v1.4.11

func (d *DefaultHTTPRequestHeader) GetClientIP() string

GetClientIP retrieves the client's IP address from the DefaultHTTPRequestHeader struct.

func (*DefaultHTTPRequestHeader) GetClientPort added in v1.4.11

func (d *DefaultHTTPRequestHeader) GetClientPort() string

GetClientPort retrieves the client port value from the DefaultHTTPRequestHeader struct.

func (*DefaultHTTPRequestHeader) GetLocalIP added in v1.4.11

func (d *DefaultHTTPRequestHeader) GetLocalIP() string

GetLocalIP retrieves the local IP address from the DefaultHTTPRequestHeader struct.

func (*DefaultHTTPRequestHeader) GetLocalPort added in v1.4.11

func (d *DefaultHTTPRequestHeader) GetLocalPort() string

GetLocalPort retrieves the local port value from the DefaultHTTPRequestHeader struct.

func (*DefaultHTTPRequestHeader) GetLoginAttempt added in v1.4.11

func (d *DefaultHTTPRequestHeader) GetLoginAttempt() string

GetLoginAttempt retrieves the login attempt value from the DefaultHTTPRequestHeader struct.

func (*DefaultHTTPRequestHeader) GetPassword added in v1.4.11

func (d *DefaultHTTPRequestHeader) GetPassword() string

GetPassword retrieves the password value from the DefaultHTTPRequestHeader struct.

func (*DefaultHTTPRequestHeader) GetPasswordEncoded added in v1.4.11

func (d *DefaultHTTPRequestHeader) GetPasswordEncoded() string

GetPasswordEncoded retrieves the encoded password value from the DefaultHTTPRequestHeader struct.

func (*DefaultHTTPRequestHeader) GetProtocol added in v1.4.11

func (d *DefaultHTTPRequestHeader) GetProtocol() string

GetProtocol retrieves the protocol value from the DefaultHTTPRequestHeader struct.

func (*DefaultHTTPRequestHeader) GetSSL added in v1.4.11

func (d *DefaultHTTPRequestHeader) GetSSL() string

GetSSL retrieves the SSL value from the DefaultHTTPRequestHeader struct.

func (*DefaultHTTPRequestHeader) GetSSLCipher added in v1.4.11

func (d *DefaultHTTPRequestHeader) GetSSLCipher() string

GetSSLCipher retrieves the SSL cipher value from the DefaultHTTPRequestHeader struct.

func (*DefaultHTTPRequestHeader) GetSSLClientCN added in v1.4.11

func (d *DefaultHTTPRequestHeader) GetSSLClientCN() string

GetSSLClientCN retrieves the Common Name (CN) from the SSL client certificate in the DefaultHTTPRequestHeader struct.

func (*DefaultHTTPRequestHeader) GetSSLClientIssuerDN added in v1.4.11

func (d *DefaultHTTPRequestHeader) GetSSLClientIssuerDN() string

GetSSLClientIssuerDN retrieves the SSL client issuer distinguished name (DN) from the DefaultHTTPRequestHeader struct.

func (*DefaultHTTPRequestHeader) GetSSLClientNotAfter added in v1.4.11

func (d *DefaultHTTPRequestHeader) GetSSLClientNotAfter() string

GetSSLClientNotAfter retrieves the SSL client certificate expiration date from the DefaultHTTPRequestHeader struct.

func (*DefaultHTTPRequestHeader) GetSSLClientNotBefore added in v1.4.11

func (d *DefaultHTTPRequestHeader) GetSSLClientNotBefore() string

GetSSLClientNotBefore retrieves the SSL client certificate start date from the DefaultHTTPRequestHeader struct.

func (*DefaultHTTPRequestHeader) GetSSLClientSubjectDN added in v1.4.11

func (d *DefaultHTTPRequestHeader) GetSSLClientSubjectDN() string

GetSSLClientSubjectDN retrieves the SSL client subject distinguished name (DN) from the DefaultHTTPRequestHeader struct.

func (*DefaultHTTPRequestHeader) GetSSLFingerprint added in v1.4.11

func (d *DefaultHTTPRequestHeader) GetSSLFingerprint() string

GetSSLFingerprint retrieves the SSL fingerprint value from the DefaultHTTPRequestHeader struct.

func (*DefaultHTTPRequestHeader) GetSSLIssuer added in v1.4.11

func (d *DefaultHTTPRequestHeader) GetSSLIssuer() string

GetSSLIssuer retrieves the SSL issuer value from the DefaultHTTPRequestHeader struct.

func (*DefaultHTTPRequestHeader) GetSSLIssuerDN added in v1.4.11

func (d *DefaultHTTPRequestHeader) GetSSLIssuerDN() string

GetSSLIssuerDN retrieves the SSL issuer distinguished name (DN) from the DefaultHTTPRequestHeader struct.

func (*DefaultHTTPRequestHeader) GetSSLProtocol added in v1.4.11

func (d *DefaultHTTPRequestHeader) GetSSLProtocol() string

GetSSLProtocol retrieves the SSL protocol value from the DefaultHTTPRequestHeader struct.

func (*DefaultHTTPRequestHeader) GetSSLSerial added in v1.4.11

func (d *DefaultHTTPRequestHeader) GetSSLSerial() string

GetSSLSerial retrieves the SSL serial number from the DefaultHTTPRequestHeader struct.

func (*DefaultHTTPRequestHeader) GetSSLSessionID added in v1.4.11

func (d *DefaultHTTPRequestHeader) GetSSLSessionID() string

GetSSLSessionID retrieves the SSL session ID from the DefaultHTTPRequestHeader struct.

func (*DefaultHTTPRequestHeader) GetSSLSubject added in v1.4.11

func (d *DefaultHTTPRequestHeader) GetSSLSubject() string

GetSSLSubject retrieves the SSL subject value from the DefaultHTTPRequestHeader struct.

func (*DefaultHTTPRequestHeader) GetSSLSubjectDN added in v1.4.11

func (d *DefaultHTTPRequestHeader) GetSSLSubjectDN() string

GetSSLSubjectDN retrieves the SSL subject distinguished name (DN) from the DefaultHTTPRequestHeader struct.

func (*DefaultHTTPRequestHeader) GetSSLVerify added in v1.4.11

func (d *DefaultHTTPRequestHeader) GetSSLVerify() string

GetSSLVerify retrieves the SSL verification setting from the DefaultHTTPRequestHeader struct.

func (*DefaultHTTPRequestHeader) GetUsername added in v1.4.11

func (d *DefaultHTTPRequestHeader) GetUsername() string

GetUsername retrieves the username value from the DefaultHTTPRequestHeader struct.

type Endpoint added in v1.4.9

type Endpoint struct {
	AuthHeader    bool `mapstructure:"auth_header"`
	AuthJSON      bool `mapstructure:"auth_json"`
	AuthBasic     bool `mapstructure:"auth_basic"`
	AuthNginx     bool `mapstructure:"auth_nginx"`
	AuthSASLAuthd bool `mapstructure:"auth_saslauthd"`
	CustomHooks   bool `mapstructure:"custom_hooks"`
}

Endpoint defines a structure for configuring various types of authentication and custom hooks.

func (*Endpoint) IsAuthBasicEnabled added in v1.4.11

func (e *Endpoint) IsAuthBasicEnabled() bool

IsAuthBasicEnabled checks if Basic authentication is enabled for the endpoint and returns the corresponding boolean value.

func (*Endpoint) IsAuthHeaderEnabled added in v1.4.11

func (e *Endpoint) IsAuthHeaderEnabled() bool

IsAuthHeaderEnabled checks if header-based authentication is enabled for the endpoint and returns the corresponding boolean value.

func (*Endpoint) IsAuthJSONEnabled added in v1.4.11

func (e *Endpoint) IsAuthJSONEnabled() bool

IsAuthJSONEnabled checks if JSON-based authentication is enabled for the endpoint and returns the corresponding boolean value.

func (*Endpoint) IsAuthNginxEnabled added in v1.4.11

func (e *Endpoint) IsAuthNginxEnabled() bool

IsAuthNginxEnabled checks if Nginx-based authentication is enabled for the endpoint and returns the corresponding boolean value.

func (*Endpoint) IsAuthSASLAuthdEnabled added in v1.4.11

func (e *Endpoint) IsAuthSASLAuthdEnabled() bool

IsAuthSASLAuthdEnabled checks if SASL authentication is enabled for the endpoint and returns the corresponding boolean value.

func (*Endpoint) IsCustomHooksEnabled added in v1.4.11

func (e *Endpoint) IsCustomHooksEnabled() bool

IsCustomHooksEnabled checks if custom hooks are enabled for the endpoint and returns the corresponding boolean value.

type Environment added in v1.4.10

type Environment interface {
	// GetSMTPBackendAddress returns the address of the SMTP backend server.
	GetSMTPBackendAddress() string

	// GetSMTPBackendPort returns the port of the SMTP backend server.
	GetSMTPBackendPort() int

	// GetIMAPBackendAddress returns the address of the IMAP backend server.
	GetIMAPBackendAddress() string

	// GetIMAPBackendPort returns the port of the IMAP backend server.
	GetIMAPBackendPort() int

	// GetPOP3BackendAddress returns the address of the POP3 backend server.
	GetPOP3BackendAddress() string

	// GetPOP3BackendPort returns the port of the POP3 backend server.
	GetPOP3BackendPort() int

	// GetWaitDelay returns the delay between connection attempts in seconds.
	GetWaitDelay() uint8

	// GetMaxLoginAttempts returns the maximum number of allowed login attempts.
	GetMaxLoginAttempts() uint8

	// GetDevMode indicates whether the application is in developer mode.
	GetDevMode() bool

	// GetMaxActionWorkers returns the maximum number of simultaneous action workers.
	GetMaxActionWorkers() uint16

	// GetLocalCacheAuthTTL returns the time-to-live duration for local cache authentication.
	GetLocalCacheAuthTTL() time.Duration
}

Environment defines methods for accessing application configuration settings.

func GetEnvironment added in v1.4.10

func GetEnvironment() Environment

GetEnvironment returns the singleton instance of the environmentSettings configuration. Panics if the environment is uninitialized.

func NewEnvironmentConfig added in v1.4.10

func NewEnvironmentConfig() Environment

NewEnvironmentConfig initializes and returns a singleton instance of EnvironmentSettings, setting default and custom configurations.

type EnvironmentSettings added in v1.4.10

type EnvironmentSettings struct {
	// SMTPBackendAddress is the address of the SMTP backend server.
	SMTPBackendAddress string

	// SMTPBackendPort is the port of the SMTP backend server.
	SMTPBackendPort int

	// IMAPBackendAddress is the address of the IMAP backend server.
	IMAPBackendAddress string

	// IMAPBackendPort is the port of the IMAP backend server.
	IMAPBackendPort int

	// POP3BackendAddress is the address of the POP3 backend server.
	POP3BackendAddress string

	// POP3BackendPort is the port of the IMAP POP3 server.
	POP3BackendPort int

	// WaitDelay is the time in seconds to wait between connection attempts.
	WaitDelay uint8

	// MaxLoginAttempts is the maximum number of login attempts.
	MaxLoginAttempts uint8

	// DevMode indicates whether the application is running in developer mode.
	DevMode bool

	// MaxActionWorkers is the maximum number of action workers that can be run simultaneously.
	MaxActionWorkers uint16

	// LocalCacheAuthTTL
	LocalCacheAuthTTL time.Duration
}

EnvironmentSettings represents overall configuration settings for the application.

func (*EnvironmentSettings) GetDevMode added in v1.4.10

func (env *EnvironmentSettings) GetDevMode() bool

GetDevMode returns the DevMode value, indicating whether the application is running in developer mode.

func (*EnvironmentSettings) GetIMAPBackendAddress added in v1.4.10

func (env *EnvironmentSettings) GetIMAPBackendAddress() string

GetIMAPBackendAddress retrieves the address of the IMAP backend server from the EnvironmentSettings instance.

func (*EnvironmentSettings) GetIMAPBackendPort added in v1.4.10

func (env *EnvironmentSettings) GetIMAPBackendPort() int

GetIMAPBackendPort retrieves the port of the IMAP backend server from the EnvironmentSettings instance.

func (*EnvironmentSettings) GetLocalCacheAuthTTL added in v1.4.10

func (env *EnvironmentSettings) GetLocalCacheAuthTTL() time.Duration

GetLocalCacheAuthTTL retrieves the time-to-live duration for local cache authentication from the EnvironmentSettings instance.

func (*EnvironmentSettings) GetMaxActionWorkers added in v1.4.10

func (env *EnvironmentSettings) GetMaxActionWorkers() uint16

GetMaxActionWorkers retrieves the maximum number of action workers allowed from the EnvironmentSettings instance.

func (*EnvironmentSettings) GetMaxLoginAttempts added in v1.4.10

func (env *EnvironmentSettings) GetMaxLoginAttempts() uint8

GetMaxLoginAttempts retrieves the maximum allowed number of login attempts from the EnvironmentSettings instance.

func (*EnvironmentSettings) GetPOP3BackendAddress added in v1.4.10

func (env *EnvironmentSettings) GetPOP3BackendAddress() string

GetPOP3BackendAddress retrieves the address of the POP3 backend server from the EnvironmentSettings instance.

func (*EnvironmentSettings) GetPOP3BackendPort added in v1.4.10

func (env *EnvironmentSettings) GetPOP3BackendPort() int

GetPOP3BackendPort retrieves the port of the POP3 backend server from the EnvironmentSettings instance.

func (*EnvironmentSettings) GetSMTPBackendAddress added in v1.4.10

func (env *EnvironmentSettings) GetSMTPBackendAddress() string

GetSMTPBackendAddress retrieves the address of the SMTP backend server from the EnvironmentSettings instance.

func (*EnvironmentSettings) GetSMTPBackendPort added in v1.4.10

func (env *EnvironmentSettings) GetSMTPBackendPort() int

GetSMTPBackendPort retrieves the port of the SMTP backend server from the EnvironmentSettings instance.

func (*EnvironmentSettings) GetWaitDelay added in v1.4.10

func (env *EnvironmentSettings) GetWaitDelay() uint8

GetWaitDelay retrieves the wait delay in seconds between connection attempts from the EnvironmentSettings instance.

func (*EnvironmentSettings) String added in v1.4.10

func (env *EnvironmentSettings) String() string

String returns the name of the Config object excluding the HTTPOptions.

type Feature

type Feature struct {
	// contains filtered or unexported fields
}

Feature is a container for Nauthilus features.

func (*Feature) Get

func (f *Feature) Get() string

Get gets the name of a feature returned as string.

func (*Feature) Set

func (f *Feature) Set(value string) error

Set updates the feature name based on the provided value. It returns an error if the value is not a valid feature name. Valid feature names are "tls_encryption", "rbl", "relay_domains", and "lua". If the value is valid, the name field of the Feature struct is updated accordingly. An error of type ErrWrongFeature is returned if the value is not valid.

func (*Feature) String

func (f *Feature) String() string

func (*Feature) Type

func (f *Feature) Type() string

Type returns the name of the type.

type File

type File interface {

	// HandleFile processes the configuration file.
	HandleFile() error

	// HaveLuaFeatures checks if Lua features are available.
	HaveLuaFeatures() bool

	// HaveLuaFilters checks if Lua filters are active.
	HaveLuaFilters() bool

	// HaveLuaActions checks if Lua actions are enabled.
	HaveLuaActions() bool

	// HaveLuaHooks checks if Lua hooks are being used.
	HaveLuaHooks() bool

	// HaveLuaInit checks if a Lua initialization script exists.
	HaveLuaInit() bool

	// HaveLua checks if Lua-based configuration in general is available.
	HaveLua() bool

	// GetLuaInitScriptPath returns the path to the Lua initialization script.
	GetLuaInitScriptPath() string

	// GetLuaPackagePath retrieves the Lua package path from the configuration.
	GetLuaPackagePath() string

	// GetLuaScriptPath returns the path to the Lua script.
	GetLuaScriptPath() string

	// GetLuaSearchProtocol retrieves the Lua search protocol for a given protocol name.
	GetLuaSearchProtocol(protocol string, backendName string) (*LuaSearchProtocol, error)

	// GetLuaOptionalBackends retrieves a map of Lua configurations for optional backends, indexed by their names.
	GetLuaOptionalBackends() map[string]*LuaConf

	// HaveLDAPBackend checks if an LDAP backend is being used.
	HaveLDAPBackend() bool

	// LDAPHavePoolOnly checks whether LDAP connections are only handled via a pool.
	LDAPHavePoolOnly(backendName string) bool

	// GetLDAPConfigLookupPoolSize returns the pool size for LDAP lookups.
	GetLDAPConfigLookupPoolSize() int

	// GetLDAPConfigAuthPoolSize returns the pool size for LDAP authentication.
	GetLDAPConfigAuthPoolSize() int

	// GetLDAPConfigConnectAbortTimeout retrieves the timeout duration for aborting LDAP connect attempts.
	GetLDAPConfigConnectAbortTimeout() time.Duration

	// GetLDAPConfigLookupIdlePoolSize retrieves the idle pool size for LDAP lookups.
	GetLDAPConfigLookupIdlePoolSize() int

	// GetLDAPConfigAuthIdlePoolSize retrieves the idle pool size for LDAP authentication.
	GetLDAPConfigAuthIdlePoolSize() int

	// GetLDAPConfigBindDN returns the Bind DN for LDAP.
	GetLDAPConfigBindDN() string

	// GetLDAPConfigBindPW retrieves the password for the LDAP bind.
	GetLDAPConfigBindPW() string

	// GetLDAPConfigTLSCAFile returns the TLS CA file for LDAP.
	GetLDAPConfigTLSCAFile() string

	// GetLDAPConfigTLSClientCert retrieves the TLS client certificate for LDAP.
	GetLDAPConfigTLSClientCert() string

	// GetLDAPConfigTLSClientKey returns the TLS client key for LDAP.
	GetLDAPConfigTLSClientKey() string

	// GetLDAPConfigServerURIs retrieves a list of LDAP server URIs.
	GetLDAPConfigServerURIs() []string

	// GetLDAPConfigStartTLS indicates if StartTLS is enabled for LDAP.
	GetLDAPConfigStartTLS() bool

	// GetLDAPConfigTLSSkipVerify checks whether TLS verification for LDAP is skipped.
	GetLDAPConfigTLSSkipVerify() bool

	// GetLDAPConfigSASLExternal checks if SASL External is configured for LDAP.
	GetLDAPConfigSASLExternal() bool

	// GetLDAPSearchProtocol retrieves the LDAP search protocol for a given protocol name.
	GetLDAPSearchProtocol(protocol string, poolName string) (*LDAPSearchProtocol, error)

	// GetLDAPOptionalPools returns a map of optional LDAP pool configurations, indexed by their respective keys.
	GetLDAPOptionalPools() map[string]*LDAPConf

	// GetBackendServers returns a list of backend servers.
	GetBackendServers() []*BackendServer

	// GetBackendServerMonitoring provides the configuration and status of server monitoring.
	GetBackendServerMonitoring() *BackendServerMonitoring

	// HasFeature checks whether a specific feature is available.
	HasFeature(feature string) bool

	// GetClientHost returns the client's hostname.
	GetClientHost() string

	// GetClientIP retrieves the client's IP address.
	GetClientIP() string

	// GetClientPort returns the client's port.
	GetClientPort() string

	// GetClientID retrieves the client's ID.
	GetClientID() string

	// GetUsername returns the username of the currently authenticated user.
	GetUsername() string

	// GetPassword retrieves the user's password.
	GetPassword() string

	// GetPasswordEncoded returns the encoded password.
	GetPasswordEncoded() string

	// GetLoginAttempt retrieves the current login attempt.
	GetLoginAttempt() string

	// GetAuthMethod provides the authentication method used.
	GetAuthMethod() string

	// GetSkipTOTP checks if TOTP (Two-Factor Authentication) is skipped.
	GetSkipTOTP(string) bool

	// GetSkipConsent checks if consent is skipped.
	GetSkipConsent(string) bool

	// GetLocalIP returns the local IP address.
	GetLocalIP() string

	// GetLocalPort retrieves the local port.
	GetLocalPort() string

	// GetProtocol returns the protocol as a string, typically used to retrieve and determine the communication protocol in use.
	GetProtocol() string

	// GetAllProtocols returns all available protocols.
	GetAllProtocols() []string

	// GetBruteForceRules retrieves the brute force protection rules.
	GetBruteForceRules() []BruteForceRule

	// GetServer retrieves the server section of the configuration.
	GetServer() *ServerSection

	// GetRBLs retrieves the Realtime Block Lists (RBL).
	GetRBLs() *RBLSection

	// GetClearTextList returns a list of clear-text entries configured for the application.
	GetClearTextList() []string

	// GetRelayDomains retrieves the relay domains configuration section of the file.
	GetRelayDomains() *RelayDomainsSection

	// GetBruteForce retrieves the BruteForceSection configuration, containing brute force protection rules and settings.
	GetBruteForce() *BruteForceSection

	// GetLua retrieves the LuaSection from the configuration, containing actions, features, filters, hooks, and related config.
	GetLua() *LuaSection

	// GetOauth2 retrieves the Oauth2Section configuration, containing custom scopes and clients for OAuth2 authentication.
	GetOauth2() *Oauth2Section

	// GetLDAP returns the LDAPSection object containing configuration and search definitions for LDAP operations.
	GetLDAP() *LDAPSection
}

File represents an interface encapsulating various methods for configuration, file handling, and related operations.

func GetFile added in v1.4.10

func GetFile() File

GetFile returns the loaded FileSettings configuration instance.

func NewFile added in v1.4.10

func NewFile() (newCfg File, err error)

NewFile is the constructor for a ConfigFile object.

type FileSettings added in v1.4.10

type FileSettings struct {
	Server                  *ServerSection           `mapstructure:"server" valdiate:"required"`
	RBLs                    *RBLSection              `mapstructure:"realtime_blackhole_lists" valdiate:"omitempty"`
	ClearTextList           []string                 `mapstructure:"cleartext_networks" valdiate:"omitempty,dive"`
	RelayDomains            *RelayDomainsSection     `mapstructure:"relay_domains" valdiate:"omitempty"`
	BackendServerMonitoring *BackendServerMonitoring `mapstructure:"backend_server_monitoring" valdiate:"omitempty"`
	BruteForce              *BruteForceSection       `mapstructure:"brute_force" valdiate:"omitempty"`
	Lua                     *LuaSection              `mapstructure:"lua" valdiate:"omitempty"`
	LDAP                    *LDAPSection             `mapstructure:"ldap" valdiate:"omitempty"`
	Oauth2                  *Oauth2Section           `mapstructure:"oauth2" valdiate:"omitempty"`
	Other                   map[string]any           `mapstructure:",remain"`
	Mu                      sync.Mutex
}

FileSettings represents a comprehensive configuration structure utilized to manage server settings, blackhole lists, brute force, Lua scripting, OAuth2, LDAP, and other miscellaneous configurations. It includes synchronization via a mutex.

func (*FileSettings) GetAllProtocols added in v1.4.10

func (f *FileSettings) GetAllProtocols() []string

GetAllProtocols returns a unique slice of strings (a Set) for all defined protocols in the database search sections.

func (*FileSettings) GetAuthMethod added in v1.4.10

func (f *FileSettings) GetAuthMethod() string

GetAuthMethod returns the HTTP request header for the auth mechanism LOGIN or PLAIN

func (*FileSettings) GetBackendServer added in v1.4.10

func (f *FileSettings) GetBackendServer(protocol string) *BackendServer

GetBackendServer retrieves the first BackendServer that matches the specified protocol from the FileSettings's backend servers. Returns nil if no matching server is found or if the FileSettings object is nil.

func (*FileSettings) GetBackendServerMonitoring added in v1.4.10

func (f *FileSettings) GetBackendServerMonitoring() *BackendServerMonitoring

GetBackendServerMonitoring is a method on the FileSettings struct. It returns the BackendServerMonitoring field from the FileSettings struct.

func (*FileSettings) GetBackendServers added in v1.4.10

func (f *FileSettings) GetBackendServers() []*BackendServer

GetBackendServers retrieves the list of backend servers for the FileSettings instance or returns an empty list if none are configured.

func (*FileSettings) GetBruteForce added in v1.4.10

func (f *FileSettings) GetBruteForce() *BruteForceSection

GetBruteForce returns the BruteForceSection associated with the FileSettings instance. Returns nil if the instance is nil.

func (*FileSettings) GetBruteForceRules added in v1.4.10

func (f *FileSettings) GetBruteForceRules() (rules []BruteForceRule)

GetBruteForceRules retrieves the list of brute force rules defined in the configuration file. If no rules are defined or the FileSettings instance is nil, it returns nil.

func (*FileSettings) GetClearTextList added in v1.4.10

func (f *FileSettings) GetClearTextList() []string

GetClearTextList retrieves a list of clear text strings from the FileSettings instance. Returns nil if the FileSettings instance is nil.

func (*FileSettings) GetClientHost added in v1.4.10

func (f *FileSettings) GetClientHost() string

GetClientHost returns the HTTP request header used to retrieve an optional client hostname

func (*FileSettings) GetClientID added in v1.4.10

func (f *FileSettings) GetClientID() string

GetClientID returns the HTTP request header used to retrieve an optional client ID

func (*FileSettings) GetClientIP added in v1.4.10

func (f *FileSettings) GetClientIP() string

GetClientIP returns the HTTP request header that holds the client IP of the request

func (*FileSettings) GetClientPort added in v1.4.10

func (f *FileSettings) GetClientPort() string

GetClientPort returns the HTTP request header that holds the client TCP port of the request

func (*FileSettings) GetConfig added in v1.4.10

func (f *FileSettings) GetConfig(backend definitions.Backend) any

GetConfig retrieves the configuration for a given backend from the FileSettings receiver or returns nil if unavailable.

func (*FileSettings) GetLDAP added in v1.4.10

func (f *FileSettings) GetLDAP() *LDAPSection

GetLDAP retrieves the LDAPSection from the FileSettings instance. Returns nil if the FileSettings is nil.

func (*FileSettings) GetLDAPConfigAuthIdlePoolSize added in v1.4.10

func (f *FileSettings) GetLDAPConfigAuthIdlePoolSize() int

GetLDAPConfigAuthIdlePoolSize retrieves the authentication idle pool size for the LDAP configuration. It returns the default value if the configuration is nil or not properly set.

func (*FileSettings) GetLDAPConfigAuthPoolSize added in v1.4.10

func (f *FileSettings) GetLDAPConfigAuthPoolSize() int

GetLDAPConfigAuthPoolSize returns the authentication pool size configured for an LDAP backend or a default value if not set.

func (*FileSettings) GetLDAPConfigBindDN added in v1.4.10

func (f *FileSettings) GetLDAPConfigBindDN() string

GetLDAPConfigBindDN returns the BindDN value from the LDAP configuration if available, otherwise it returns an empty string.

func (*FileSettings) GetLDAPConfigBindPW added in v1.4.10

func (f *FileSettings) GetLDAPConfigBindPW() string

GetLDAPConfigBindPW retrieves the BindPW (bind password) from the LDAP configuration if available, or returns an empty string.

func (*FileSettings) GetLDAPConfigConnectAbortTimeout added in v1.5.0

func (f *FileSettings) GetLDAPConfigConnectAbortTimeout() time.Duration

GetLDAPConfigConnectAbortTimeout retrieves the abort timeout duration from the LDAP configuration, or returns 0 if not applicable.

func (*FileSettings) GetLDAPConfigLookupIdlePoolSize added in v1.4.10

func (f *FileSettings) GetLDAPConfigLookupIdlePoolSize() int

GetLDAPConfigLookupIdlePoolSize returns the configured idle connection pool size for LDAP lookups or a default value if unset.

func (*FileSettings) GetLDAPConfigLookupPoolSize added in v1.4.10

func (f *FileSettings) GetLDAPConfigLookupPoolSize() int

GetLDAPConfigLookupPoolSize returns the size of the LDAP lookup connection pool, or a default if no configuration exists.

func (*FileSettings) GetLDAPConfigSASLExternal added in v1.4.10

func (f *FileSettings) GetLDAPConfigSASLExternal() bool

GetLDAPConfigSASLExternal checks if the LDAP configuration uses SASL External authentication and returns its status. It returns false if the FileSettings receiver or the LDAP configuration is nil, or if the type assertion fails.

func (*FileSettings) GetLDAPConfigServerURIs added in v1.4.10

func (f *FileSettings) GetLDAPConfigServerURIs() []string

GetLDAPConfigServerURIs retrieves the LDAP server URIs from the configuration or returns "ldap://localhost" as a default value.

func (*FileSettings) GetLDAPConfigStartTLS added in v1.4.10

func (f *FileSettings) GetLDAPConfigStartTLS() bool

GetLDAPConfigStartTLS determines if StartTLS is enabled for the LDAP configuration in the provided file. Returns false if the file or configuration is nil or not of type *LDAPConf.

func (*FileSettings) GetLDAPConfigTLSCAFile added in v1.4.10

func (f *FileSettings) GetLDAPConfigTLSCAFile() string

GetLDAPConfigTLSCAFile retrieves the TLS CA file for the LDAP configuration if available, returning an empty string if not.

func (*FileSettings) GetLDAPConfigTLSClientCert added in v1.4.10

func (f *FileSettings) GetLDAPConfigTLSClientCert() string

GetLDAPConfigTLSClientCert retrieves the TLS client certificate for the LDAP configuration. Returns an empty string if the file or configuration is nil, or if the assertion of the config type fails.

func (*FileSettings) GetLDAPConfigTLSClientKey added in v1.4.10

func (f *FileSettings) GetLDAPConfigTLSClientKey() string

GetLDAPConfigTLSClientKey retrieves the TLS client key for the LDAP configuration. Returns an empty string if not set.

func (*FileSettings) GetLDAPConfigTLSSkipVerify added in v1.4.10

func (f *FileSettings) GetLDAPConfigTLSSkipVerify() bool

GetLDAPConfigTLSSkipVerify retrieves the TLSSkipVerify value from the LDAP configuration in the file. Returns false if the file or configuration is nil or not of type *LDAPConf.

func (*FileSettings) GetLDAPOptionalPools added in v1.5.0

func (f *FileSettings) GetLDAPOptionalPools() map[string]*LDAPConf

GetLDAPOptionalPools retrieves a map of optional LDAP pool configurations from the file settings. Returns nil if the file settings or LDAP section is not properly configured.

func (*FileSettings) GetLDAPSearchProtocol added in v1.4.10

func (f *FileSettings) GetLDAPSearchProtocol(protocol string, poolName string) (*LDAPSearchProtocol, error)

GetLDAPSearchProtocol retrieves the LDAPSearchProtocol configuration based on the specified protocol. If the protocol is not found, it falls back to the default protocol. Returns an error if the configuration or default protocol is missing.

func (*FileSettings) GetLocalIP added in v1.4.10

func (f *FileSettings) GetLocalIP() string

GetLocalIP returns the HTTP request header that represents the local IP address for the server that accepts client requests

func (*FileSettings) GetLocalPort added in v1.4.10

func (f *FileSettings) GetLocalPort() string

GetLocalPort returns the HTTP request header that represents the local TCP port for the server that accepts client requests

func (*FileSettings) GetLoginAttempt added in v1.4.10

func (f *FileSettings) GetLoginAttempt() string

GetLoginAttempt returns the HTTP request header for login-attempts

func (*FileSettings) GetLua added in v1.4.10

func (f *FileSettings) GetLua() *LuaSection

GetLua retrieves the LuaSection from the FileSettings instance. Returns nil if the FileSettings instance is nil.

func (*FileSettings) GetLuaInitScriptPath added in v1.4.10

func (f *FileSettings) GetLuaInitScriptPath() string

GetLuaInitScriptPath returns the path to the Lua init script specified in the configuration. If the configuration or LuaConf is nil, it returns an empty string.

func (*FileSettings) GetLuaOptionalBackends added in v1.5.0

func (f *FileSettings) GetLuaOptionalBackends() map[string]*LuaConf

GetLuaOptionalBackends retrieves the optional Lua backends configuration from FileSettings. Returns nil if unavailable.

func (*FileSettings) GetLuaPackagePath added in v1.4.10

func (f *FileSettings) GetLuaPackagePath() string

GetLuaPackagePath returns the Lua package path based on the file configuration or a default path if not specified.

func (*FileSettings) GetLuaScriptPath added in v1.4.10

func (f *FileSettings) GetLuaScriptPath() string

GetLuaScriptPath retrieves the backend Lua script file path from the configuration. Returns an empty string if unavailable.

func (*FileSettings) GetLuaSearchProtocol added in v1.4.10

func (f *FileSettings) GetLuaSearchProtocol(protocol string, backendName string) (*LuaSearchProtocol, error)

GetLuaSearchProtocol retrieves a LuaSearchProtocol configuration matching the specified protocol. Returns a default LuaSearchProtocol if the protocol cannot be found and protocol is set to ProtoDefault. Returns a DetailedError if the protocol cannot be found and no default is configured. Accepts a string representing the protocol to search for.

func (*FileSettings) GetOauth2 added in v1.4.10

func (f *FileSettings) GetOauth2() *Oauth2Section

GetOauth2 returns the Oauth2Section of the FileSettings instance. Returns nil if the FileSettings instance is nil.

func (*FileSettings) GetPassword added in v1.4.10

func (f *FileSettings) GetPassword() string

GetPassword returns the HTTP request header for the password

func (*FileSettings) GetPasswordEncoded added in v1.4.10

func (f *FileSettings) GetPasswordEncoded() string

GetPasswordEncoded returns the HTTP request header to indicate if the password was encoded

func (*FileSettings) GetProtocol added in v1.4.10

func (f *FileSettings) GetProtocol() string

GetProtocol returns the HTTP request header for the used protocol

func (*FileSettings) GetProtocols added in v1.4.10

func (f *FileSettings) GetProtocols(backend definitions.Backend) any

GetProtocols retrieves protocol configurations for the specified backend type. Returns nil if the backend is not found or has no associated protocols.

func (*FileSettings) GetRBLs added in v1.4.10

func (f *FileSettings) GetRBLs() *RBLSection

GetRBLs retrieves the RBLSection configuration from the FileSettings instance. Returns nil if the FileSettings instance is nil.

func (*FileSettings) GetRelayDomains added in v1.4.10

func (f *FileSettings) GetRelayDomains() *RelayDomainsSection

GetRelayDomains retrieves the RelayDomainsSection from the FileSettings. Returns nil if the FileSettings is nil.

func (*FileSettings) GetSSL added in v1.4.10

func (f *FileSettings) GetSSL() string

GetSSL returns the HTTP request header used to indicate SSL security for the current client connection

func (*FileSettings) GetSSLCipher added in v1.4.10

func (f *FileSettings) GetSSLCipher() string

GetSSLCipher retrieves the SSL cipher from the default HTTP request header of the server configuration. Returns an empty string if the FileSettings instance is nil.

func (*FileSettings) GetSSLClientCN added in v1.4.10

func (f *FileSettings) GetSSLClientCN() string

GetSSLClientCN retrieves the SSL client common name (CN) from the default HTTP request header.

func (*FileSettings) GetSSLClientIssuerDN added in v1.4.10

func (f *FileSettings) GetSSLClientIssuerDN() string

GetSSLClientIssuerDN returns the distinguished name (DN) of the SSL client issuer from the default HTTP request header.

func (*FileSettings) GetSSLClientNotAfter added in v1.4.10

func (f *FileSettings) GetSSLClientNotAfter() string

GetSSLClientNotAfter retrieves the SSL client certificate's "not after" expiration date as a string. Returns an empty string if the FileSettings is nil.

func (*FileSettings) GetSSLClientNotBefore added in v1.4.10

func (f *FileSettings) GetSSLClientNotBefore() string

GetSSLClientNotBefore retrieves the "SSLClientNotBefore" value from the default HTTP request header of the server. Returns an empty string if the FileSettings instance is nil.

func (*FileSettings) GetSSLClientSubjectDN added in v1.4.10

func (f *FileSettings) GetSSLClientSubjectDN() string

GetSSLClientSubjectDN returns the SSL client subject distinguished name from the default HTTP request header. If the FileSettings receiver is nil, it returns an empty string.

func (*FileSettings) GetSSLFingerprint added in v1.4.10

func (f *FileSettings) GetSSLFingerprint() string

GetSSLFingerprint retrieves the SSL fingerprint from the server's default HTTP request header. If the FileSettings is nil, it returns an empty string.

func (*FileSettings) GetSSLIssuer added in v1.4.10

func (f *FileSettings) GetSSLIssuer() string

GetSSLIssuer retrieves the SSL certificate issuer from the default HTTP request header of the server configuration.

func (*FileSettings) GetSSLIssuerDN added in v1.4.10

func (f *FileSettings) GetSSLIssuerDN() string

GetSSLIssuerDN retrieves the Distinguished Name (DN) of the SSL issuer from the default HTTP request header.

func (*FileSettings) GetSSLProtocol added in v1.4.10

func (f *FileSettings) GetSSLProtocol() string

GetSSLProtocol retrieves the SSL protocol from the DefaultHTTPRequestHeader of the Server configuration.

func (*FileSettings) GetSSLSerial added in v1.4.10

func (f *FileSettings) GetSSLSerial() string

GetSSLSerial retrieves the SSL serial number from the default HTTP request header of the server configuration. Returns an empty string if the FileSettings receiver is nil.

func (*FileSettings) GetSSLSessionID added in v1.4.10

func (f *FileSettings) GetSSLSessionID() string

GetSSLSessionID retrieves the SSL session ID from the file's default HTTP request header. Returns an empty string if the file is nil.

func (*FileSettings) GetSSLSubject added in v1.4.10

func (f *FileSettings) GetSSLSubject() string

GetSSLSubject retrieves the SSL subject from the default HTTP request header. Returns an empty string if the file is nil.

func (*FileSettings) GetSSLSubjectDN added in v1.4.10

func (f *FileSettings) GetSSLSubjectDN() string

GetSSLSubjectDN returns the SSL subject distinguished name from the Server's default HTTP request header.

func (*FileSettings) GetSSLVerify added in v1.4.10

func (f *FileSettings) GetSSLVerify() string

GetSSLVerify retrieves the SSL verification status from the default HTTP request header configuration. If the FileSettings receiver is nil, it returns an empty string.

func (*FileSettings) GetSection added in v1.4.10

func (f *FileSettings) GetSection(backend definitions.Backend) any

GetSection retrieves the section corresponding to the provided backend type from the FileSettings. Returns nil if not found.

func (*FileSettings) GetServer added in v1.4.10

func (f *FileSettings) GetServer() *ServerSection

GetServer retrieves the ServerSection from the FileSettings. Returns nil if the FileSettings is nil or if no Server is present.

func (*FileSettings) GetSkipConsent added in v1.4.10

func (f *FileSettings) GetSkipConsent(clientId string) (skip bool)

GetSkipConsent returns a boolean true, if the consent dialog shall be skipped for an OAuth-2 client.

func (*FileSettings) GetSkipTOTP added in v1.4.10

func (f *FileSettings) GetSkipTOTP(clientId string) (skip bool)

GetSkipTOTP returns a boolean true, if TOTP two-factor authentication shall be skipped for an OAuth-2 client.

func (*FileSettings) GetUsername added in v1.4.10

func (f *FileSettings) GetUsername() string

GetUsername returns the HTTP request header for the username

func (*FileSettings) HandleFile added in v1.4.10

func (f *FileSettings) HandleFile() (err error)

HandleFile applies the configuration settings loaded from the configuration file. It does sanity checks to make sure Nauthilus has a working configuration.

func (*FileSettings) HasFeature added in v1.4.10

func (f *FileSettings) HasFeature(feature string) bool

HasFeature checks if the given feature exists in the LoadableConfig's Features list

func (*FileSettings) HaveLDAPBackend added in v1.4.10

func (f *FileSettings) HaveLDAPBackend() bool

HaveLDAPBackend checks if the configuration includes an LDAP backend and returns true if it exists, otherwise false.

func (*FileSettings) HaveLua added in v1.4.10

func (f *FileSettings) HaveLua() bool

HaveLua is a method on the FileSettings struct. It checks if the Lua field in the FileSettings struct is not nil. It returns a boolean value indicating whether Lua is present or not.

func (*FileSettings) HaveLuaActions added in v1.4.10

func (f *FileSettings) HaveLuaActions() bool

HaveLuaActions is a method on the FileSettings struct. It checks if the FileSettings struct has Lua actions. It returns true if the FileSettings struct has Lua actions, otherwise returns false.

func (*FileSettings) HaveLuaFeatures added in v1.4.10

func (f *FileSettings) HaveLuaFeatures() bool

HaveLuaFeatures is a method on the FileSettings struct. It checks if the FileSettings struct has Lua features. It returns true if there are Lua features, and false otherwise.

func (*FileSettings) HaveLuaFilters added in v1.4.10

func (f *FileSettings) HaveLuaFilters() bool

HaveLuaFilters is a method on the FileSettings struct. It checks if the FileSettings struct has Lua filters. It returns true if there are Lua filters, and false otherwise.

func (*FileSettings) HaveLuaHooks added in v1.4.10

func (f *FileSettings) HaveLuaHooks() bool

HaveLuaHooks returns true if the FileSettings instance has Lua hooks associated with it, otherwise returns false.

func (*FileSettings) HaveLuaInit added in v1.4.10

func (f *FileSettings) HaveLuaInit() bool

HaveLuaInit checks if the Lua initialization script path is set in the configuration. It first confirms that the FileSettings instance supports Lua by invoking HaveLua method. Then, it retrieves the Lua configuration using GetConfig with the definitions.BackendLua constant. If the retrieved configuration is of type *LuaConf and the InitScriptPath is not empty, it returns true. Otherwise, it returns false.

func (*FileSettings) HaveServer added in v1.4.10

func (f *FileSettings) HaveServer() bool

HaveServer is a method on the FileSettings struct. It returns true if the Server field in the FileSettings struct is not nil, indicating that a server exists.

func (*FileSettings) LDAPHavePoolOnly added in v1.4.10

func (f *FileSettings) LDAPHavePoolOnly(backendName string) bool

LDAPHavePoolOnly checks if the LDAP configuration is set to use the `PoolOnly` mode. Returns false if any element is nil.

func (*FileSettings) RetrieveGetterMap added in v1.4.10

func (f *FileSettings) RetrieveGetterMap() map[definitions.Backend]GetterHandler

RetrieveGetterMap returns a map associating each supported backend with its corresponding GetterHandler implementation. This method initializes a new map for the backends, and populates it by checking if certain backend sections exist. If the provided FileSettings object is nil, it returns nil.

type Frontend added in v1.1.0

type Frontend struct {
	Enabled            bool   `mapstructure:"enabled"`
	CSRFSecret         string `mapstructure:"csrf_secret" validate:"omitempty,len=32,alphanumunicode,excludesall= "`
	CookieStoreAuthKey string `mapstructure:"cookie_store_auth_key" validate:"omitempty,len=32,alphanumunicode,excludesall= "`
	CookieStoreEncKey  string `mapstructure:"cookie_store_encryption_key" validate:"omitempty,alphanumunicode,excludesall= ,validateCookieStoreEncKey"`
}

Frontend represents configuration options for the frontend of the application.

type GetterHandler

type GetterHandler interface {
	// GetConfig retrieves the configuration associated with the implementing object or returns nil if unavailable.
	GetConfig() any

	// GetProtocols retrieves protocol configurations associated with the implementing object or returns nil if unavailable.
	GetProtocols() any
}

GetterHandler is an interface that provides methods to retrieve configuration and protocol information.

type HTTPClient added in v1.3.0

type HTTPClient struct {
	MaxConnsPerHost     int           `mapstructure:"max_connections_per_host" validate:"omitempty,gte=1"`
	MaxIdleConns        int           `mapstructure:"max_idle_connections" validate:"omitempty,gte=1"`
	MaxIdleConnsPerHost int           `mapstructure:"max_idle_connections_per_host" validate:"omitempty,gte=0"`
	IdleConnTimeout     time.Duration `mapstructure:"idle_connection_timeout" validate:"omitempty,gte=0"`
	Proxy               string        `mapstructure:"proxy"`
}

func (*HTTPClient) GetIdleConnTimeout added in v1.4.11

func (c *HTTPClient) GetIdleConnTimeout() time.Duration

GetIdleConnTimeout returns the idle connection timeout duration configured for the HTTP client.

func (*HTTPClient) GetMaxConnsPerHost added in v1.4.11

func (c *HTTPClient) GetMaxConnsPerHost() int

GetMaxConnsPerHost returns the maximum number of connections allowed per host for the HTTP client.

func (*HTTPClient) GetMaxIdleConns added in v1.4.11

func (c *HTTPClient) GetMaxIdleConns() int

GetMaxIdleConns returns the maximum number of idle connections allowed for the HTTP client.

func (*HTTPClient) GetMaxIdleConnsPerHost added in v1.4.11

func (c *HTTPClient) GetMaxIdleConnsPerHost() int

GetMaxIdleConnsPerHost returns the maximum number of idle connections allowed per host for the HTTP client.

func (*HTTPClient) GetProxy added in v1.4.11

func (c *HTTPClient) GetProxy() string

GetProxy returns the proxy URL configured for the HTTP client.

type IdTokenClaims

type IdTokenClaims struct {
	// Scope: profile.
	Name              string `mapstructure:"name" validate:"omitempty,printascii,excludesall= "`
	GivenName         string `mapstructure:"given_name" validate:"omitempty,printascii,excludesall= "`
	FamilyName        string `mapstructure:"family_name" validate:"omitempty,printascii,excludesall= "`
	MiddleName        string `mapstructure:"middle_name" validate:"omitempty,printascii,excludesall= "`
	NickName          string `mapstructure:"nickname" validate:"omitempty,printascii,excludesall= "`
	PreferredUserName string `mapstructure:"preferred_username" validate:"omitempty,printascii,excludesall= "`
	Profile           string `mapstructure:"profile" validate:"omitempty,printascii,excludesall= "`
	Website           string `mapstructure:"website" validate:"omitempty,printascii,excludesall= "`
	Picture           string `mapstructure:"picture" validate:"omitempty,printascii,excludesall= "`
	Gender            string `mapstructure:"gender" validate:"omitempty,printascii,excludesall= "`
	Birthdate         string `mapstructure:"birthdate" validate:"omitempty,printascii,excludesall= "`
	ZoneInfo          string `mapstructure:"zoneinfo" validate:"omitempty,printascii,excludesall= "`
	Locale            string `mapstructure:"locale" validate:"omitempty,printascii,excludesall= "`
	UpdatedAt         string `mapstructure:"updated_at" validate:"omitempty,printascii,excludesall= "`

	// Scope: email.
	Email         string `mapstructure:"email" validate:"omitempty,printascii,excludesall= "`
	EmailVerified string `mapstructure:"email_verified" validate:"omitempty,printascii,excludesall= "`

	// Scope: phone.
	PhoneNumber         string `mapstructure:"phone_number" validate:"omitempty,printascii,excludesall= "`
	PhoneNumberVerified string `mapstructure:"phone_number_verified" validate:"omitempty,printascii,excludesall= "`

	// Scope: address.
	Address string `mapstructure:"address" validate:"omitempty,printascii,excludesall= "`

	// Scope: groups.
	Groups string `mapstructure:"groups" validate:"omitempty,printascii,excludesall= "`

	// Scope: user defined.
	CustomClaims map[string]any `mapstructure:",remain"`
}

func (*IdTokenClaims) String

func (i *IdTokenClaims) String() string

type Insights

type Insights struct {
	EnablePprof        bool `mapstructure:"enable_pprof"`
	EnableBlockProfile bool `mapstructure:"enable_block_profile"`
}

Insights is a configuration structure for enabling profiling and block profiling capabilities.

func (*Insights) IsBlockProfileEnabled added in v1.4.11

func (i *Insights) IsBlockProfileEnabled() bool

IsBlockProfileEnabled checks if block profiling is enabled in the Insights configuration.

func (*Insights) IsPprofEnabled added in v1.4.11

func (i *Insights) IsPprofEnabled() bool

IsPprofEnabled checks if pprof profiling is enabled in the Insights configuration.

type LDAPAttributeMapping

type LDAPAttributeMapping struct {
	AccountField      string `mapstructure:"account_field" validate:"required"` // Webauthn is not implemented, yet.
	TOTPSecretField   string `mapstructure:"totp_secret_field" validate:"omitempty"`
	TOTPRecoveryField string `mapstructure:"totp_recovery_field" validate:"omitempty"`
	DisplayNameField  string `mapstructure:"display_name_field" validate:"omitempty"`
	CredentialObject  string `mapstructure:"credential_object" validate:"omitempty"`
	CredentialIDField string `mapstructure:"credential_id_field" validate:"omitempty"`
	PublicKeyField    string `mapstructure:"public_key_field" validate:"omitempty"`
	UniqueUserIDField string `mapstructure:"unique_user_id_field" validate:"omitempty"`
	AAGUIDField       string `mapstructure:"aaguid_field" validate:"omitempty"`
	SignCountField    string `mapstructure:"sign_count_field" validate:"omitempty"`
}

type LDAPConf

type LDAPConf struct {
	PoolOnly      bool `mapstructure:"pool_only"`
	StartTLS      bool
	TLSSkipVerify bool `mapstructure:"tls_skip_verify"`
	SASLExternal  bool `mapstructure:"sasl_external"`

	LookupPoolSize     int `mapstructure:"lookup_pool_size" validate:"required,min=1"`
	LookupIdlePoolSize int `mapstructure:"lookup_idle_pool_size" validate:"omitempty,min=0"`
	AuthPoolSize       int `mapstructure:"auth_pool_size" validate:"validateAuthPoolRequired"`
	AuthIdlePoolSize   int `mapstructure:"auth_idle_pool_size" validate:"omitempty,min=0"`

	BindDN        string `mapstructure:"bind_dn" validate:"omitempty,printascii"`
	BindPW        string `mapstructure:"bind_pw" validate:"omitempty"`
	TLSCAFile     string `mapstructure:"tls_ca_cert" validate:"omitempty,file"`
	TLSClientCert string `mapstructure:"tls_client_cert" validate:"omitempty,file"`
	TLSClientKey  string `mapstructure:"tls_client_key" validate:"omitempty,file"`

	ConnectAbortTimeout time.Duration `mapstructure:"connect_abort_timeout" validate:"omitempty,max=10m"`
	ServerURIs          []string      `mapstructure:"server_uri" validate:"required,dive,uri"`
}

func (*LDAPConf) String

func (l *LDAPConf) String() string

type LDAPFilter

type LDAPFilter struct {
	User                string `mapstructure:"user" validate:"omitempty"`
	ListAccounts        string `mapstructure:"list_accounts" validate:"omitempty"`
	WebAuthnCredentials string `mapstructure:"webauthn_credentials" validate:"omitempty"`
}

type LDAPScope

type LDAPScope struct {
	// contains filtered or unexported fields
}

LDAPScope is the search scope for an LDAP server.

func (*LDAPScope) Get

func (l *LDAPScope) Get() int

Get returns the numeric LDAP search scope.

func (*LDAPScope) Set

func (l *LDAPScope) Set(value string) error

Set sets the numeric LDAP search scope by its string representation.

func (*LDAPScope) String

func (l *LDAPScope) String() string

func (*LDAPScope) Type

func (l *LDAPScope) Type() string

Type returns the name of the type.

type LDAPSearchProtocol

type LDAPSearchProtocol struct {
	Protocols []string `mapstructure:"protocol" validate:"required"`
	CacheName string   `mapstructure:"cache_name" validate:"required,printascii,excludesall= "`
	PoolName  string   `mapstructure:"pool_name" validate:"omitempty,printascii,excludesall= "`
	BaseDN    string   `mapstructure:"base_dn" validate:"required,printascii"`
	Scope     string   `mapstructure:"scope" validate:"omitempty,oneof=base one sub"`

	LDAPFilter           `mapstructure:"filter" validate:"required"`
	LDAPAttributeMapping `mapstructure:"mapping" validate:"required"`

	// LDAP result attributes
	Attributes []string `mapstructure:"attribute" validate:"required,dive,printascii,excludesall= "`
}

func (*LDAPSearchProtocol) GetAccountField

func (p *LDAPSearchProtocol) GetAccountField() (string, error)

GetAccountField returns the LDAP attribute for an account. It returns a DetailedError, if no value has been configured.

func (*LDAPSearchProtocol) GetAttributes

func (p *LDAPSearchProtocol) GetAttributes() ([]string, error)

GetAttributes returns a list of attributes that are requested from the LDAP server. It returns a DetailedError, if no value has been configured.

func (*LDAPSearchProtocol) GetBaseDN

func (p *LDAPSearchProtocol) GetBaseDN() (string, error)

GetBaseDN returns the base DN that is used for each specific protocol. It returns a DetailedError, if no value has been configured.

func (*LDAPSearchProtocol) GetCacheName

func (p *LDAPSearchProtocol) GetCacheName() (string, error)

GetCacheName returns the Redis cache domain. It returns a DetailedError, if no value has been configured.

func (*LDAPSearchProtocol) GetListAccountsFilter

func (p *LDAPSearchProtocol) GetListAccountsFilter() (string, error)

GetListAccountsFilter returns an LDAP filter which is used to find all user accounts. It returns a DetailedError, if no value has been configured.

func (*LDAPSearchProtocol) GetPoolName added in v1.5.0

func (p *LDAPSearchProtocol) GetPoolName() string

GetPoolName returns the configured pool name. If no pool name is configured, it defaults to DefaultBackendName.

func (*LDAPSearchProtocol) GetScope

func (p *LDAPSearchProtocol) GetScope() (*LDAPScope, error)

GetScope returns an LDAP search scope. If no scope was defined, it automatically sets the subtree scope. If a scope has been defined and is unknown, it returns a DetailedError.

func (*LDAPSearchProtocol) GetUserFilter

func (p *LDAPSearchProtocol) GetUserFilter() (string, error)

GetUserFilter returns an LDAP search filter to find a user. It returns a DetailedError, if no value has been configured.

type LDAPSection

type LDAPSection struct {
	Config            *LDAPConf            `mapstructure:"config" validate:"required"`
	OptionalLDAPPools map[string]*LDAPConf `mapstructure:"optional_ldap_pools" validate:"omitempty,dive"`
	Search            []LDAPSearchProtocol `mapstructure:"search" validate:"omitempty,dive"`
}

func (*LDAPSection) GetConfig

func (l *LDAPSection) GetConfig() any

GetConfig retrieves the LDAP configuration from the receiver. Returns nil if the receiver is nil.

func (*LDAPSection) GetOptionalLDAPPools added in v1.5.0

func (l *LDAPSection) GetOptionalLDAPPools() map[string]*LDAPConf

GetOptionalLDAPPools returns a map of LDAP pool configurations if available, or nil if the receiver is nil.

func (*LDAPSection) GetProtocols

func (l *LDAPSection) GetProtocols() any

GetProtocols returns the search protocols of the LDAP configuration, or nil if the receiver is nil.

func (*LDAPSection) String

func (l *LDAPSection) String() string

type Log

type Log struct {
	JSON       bool         `mapstructure:"json"`
	Color      bool         `mapstructure:"color"`
	Level      Verbosity    `mapstructure:"level"`
	DbgModules []*DbgModule `mapstructure:"debug_modules" validate:"omitempty,dive"`
}

Log represents the configuration for logging.

func (*Log) GetDebugModules added in v1.4.11

func (l *Log) GetDebugModules() []*DbgModule

GetDebugModules retrieves the list of debug modules configured in the Log instance.

func (*Log) GetLogLevel added in v1.4.11

func (l *Log) GetLogLevel() int

GetLogLevel returns the name of the current logging level configured in the Log instance.

func (*Log) GetLogLevelName added in v1.4.11

func (l *Log) GetLogLevelName() string

GetLogLevelName returns the name of the current logging level as a string.

func (*Log) IsLogFormatJSON added in v1.4.11

func (l *Log) IsLogFormatJSON() bool

IsLogFormatJSON indicates whether the log format is set to JSON based on the `JSON` field in the `Log` struct.

func (*Log) IsLogUsesColor added in v1.4.11

func (l *Log) IsLogUsesColor() bool

IsLogUsesColor determines if colored output is enabled for logging.

type LuaAction

type LuaAction struct {
	ActionType string `mapstructure:"type" validate:"required,oneof=brute_force rbl tls_encryption relay_domains lua post"`
	ScriptName string `mapstructure:"name" validate:"required"`
	ScriptPath string `mapstructure:"script_path" validate:"required,file"`
}

func (*LuaAction) GetAction

func (l *LuaAction) GetAction() (string, string, string)

GetAction returns the ActionType, ScriptName, and ScriptPath of a LuaAction. It is a method of the LuaAction struct. The ActionType field represents the type of the Lua action. The ScriptName field represents the name of the Lua script. The ScriptPath field represents the path to the Lua script file. It returns these values as strings.

func (*LuaAction) String

func (l *LuaAction) String() string

type LuaConf

type LuaConf struct {
	PackagePath       string `mapstructure:"package_path"`
	BackendScriptPath string `mapstructure:"backend_script_path" validate:"omitempty,file"`
	InitScriptPath    string `mapstructure:"init_script_path" validate:"omitempty,file"`
}

func (*LuaConf) String

func (l *LuaConf) String() string

type LuaFeature

type LuaFeature struct {
	Name       string `mapstructure:"name" validate:"required"`
	ScriptPath string `mapstructure:"script_path" validate:"required,file"`
}

func (*LuaFeature) String

func (l *LuaFeature) String() string

type LuaFilter

type LuaFilter struct {
	Name       string `mapstructure:"name" validate:"required"`
	ScriptPath string `mapstructure:"script_path" validate:"required,file"`
}

func (*LuaFilter) String

func (l *LuaFilter) String() string

type LuaHooks added in v1.3.9

type LuaHooks struct {
	Location   string `mapstructure:"http_location" validate:"required,printascii,excludesall= "`
	Method     string `mapstructure:"http_method" validate:"required,oneof=GET POST PUT DELETE PATCH"`
	ScriptPath string `mapstructure:"script_path" validate:"required,file"`
}

func (*LuaHooks) String added in v1.3.9

func (l *LuaHooks) String() string

type LuaSearchProtocol

type LuaSearchProtocol struct {
	Protocols   []string `mapstructure:"protocol"`
	CacheName   string   `mapstructure:"cache_name" validate:"required,printascii,excludesall= "`
	BackendName string   `mapstructure:"backend_name" validate:"omitempty,printascii,excludesall= "`
}

func (*LuaSearchProtocol) GetBackendName added in v1.5.0

func (l *LuaSearchProtocol) GetBackendName() string

GetBackendName returns the backend name configured in LuaSearchProtocol or a default value if not specified.

func (*LuaSearchProtocol) GetCacheName

func (l *LuaSearchProtocol) GetCacheName() (string, error)

GetCacheName returns the Redis cache domain. It returns a DetailedError, if no value has been configured.

type LuaSection

type LuaSection struct {
	Actions             []LuaAction         `mapstructure:"actions" validate:"omitempty,dive"`
	Features            []LuaFeature        `mapstructure:"features" validate:"omitempty,dive"`
	Filters             []LuaFilter         `mapstructure:"filters" validate:"omitempty,dive"`
	Hooks               []LuaHooks          `mapstructure:"custom_hooks" validate:"omitempty,dive"`
	Config              *LuaConf            `mapstructure:"config" validate:"omitempty"`
	OptionalLuaBackends map[string]*LuaConf `mapstructure:"optional_lua_backends" validate:"omitempty,dive,validateOptionalLuaBackend"`
	Search              []LuaSearchProtocol `mapstructure:"search" validate:"omitempty,dive"`
}

func (*LuaSection) GetConfig

func (l *LuaSection) GetConfig() any

GetConfig retrieves the `Config` field from the LuaSection. Returns nil if the LuaSection is nil.

func (*LuaSection) GetOptionalLuaBackends added in v1.5.0

func (l *LuaSection) GetOptionalLuaBackends() map[string]*LuaConf

GetOptionalLuaBackends retrieves the `OptionalLuaBackends` field from the LuaSection. Returns nil if the LuaSection is nil.

func (*LuaSection) GetProtocols

func (l *LuaSection) GetProtocols() any

GetProtocols retrieves the search protocols from the LuaSection. Returns nil if the LuaSection is nil.

func (*LuaSection) String

func (l *LuaSection) String() string

type Master

type Master struct {
	Address  string `mapstructure:"address" validate:"omitempty,hostname_port"`
	Username string `mapstructure:"username" validate:"omitempty,excludesall= "`
	Password string `mapstructure:"password" validate:"omitempty,excludesall= "`
}

Master represents the configuration for the master Redis instance. Includes fields for address, username, and password for the master instance.

func (Master) GetAddress added in v1.4.11

func (m Master) GetAddress() string

GetAddress returns the address of the master Redis instance stored in the Master struct.

func (Master) GetPassword added in v1.4.11

func (m Master) GetPassword() string

GetPassword returns the password of the master Redis instance stored in the Master struct.

func (Master) GetUsername added in v1.4.11

func (m Master) GetUsername() string

GetUsername returns the username of the master Redis instance stored in the Master struct.

type MasterUser

type MasterUser struct {
	Enabled   bool   `mapstructure:"enabled"`
	Delimiter string `mapstructure:"delimiter" validate:"omitempty,len=1,printascii"`
}

MasterUser represents a user configuration with flags for enabling and setting delimiters.

func (*MasterUser) GetDelimiter added in v1.4.11

func (m *MasterUser) GetDelimiter() string

GetDelimiter retrieves the delimiter value associated with the MasterUser configuration.

func (*MasterUser) IsEnabled added in v1.4.11

func (m *MasterUser) IsEnabled() bool

IsEnabled determines if the MasterUser is enabled by checking the Enabled field.

type OIDCCustomClaim

type OIDCCustomClaim struct {
	Name string
	Type string
}

type Oauth2Client

type Oauth2Client struct {
	SkipConsent bool          `mapstructure:"skip_consent"`
	SkipTOTP    bool          `mapstructure:"skip_totp"`
	ClientName  string        `mapstructure:"name" validate:"required"`
	ClientId    string        `mapstructure:"client_id" validate:"required"`
	Subject     string        `mapstructure:"subject" validate:"required,alphanumunicode,excludesall= "`
	Claims      IdTokenClaims `mapstructure:"claims" validate:"required"`
}

type Oauth2CustomScope

type Oauth2CustomScope struct {
	Name        string            `mapstructure:"name" validate:"required,alphanumunicode,excludesall= "`
	Description string            `mapstructure:"description" validate:"required"`
	Claims      []OIDCCustomClaim `mapstructure:"claims" validate:"required,dive"`
	Other       map[string]any    `mapstructure:",remain"`
}

type Oauth2Section

type Oauth2Section struct {
	CustomScopes []Oauth2CustomScope `mapstructure:"custom_scopes" validate:"omitempty,dive"`
	Clients      []Oauth2Client      `mapstructure:"clients" validate:"omitempty,dive"`
}

func (*Oauth2Section) String

func (o *Oauth2Section) String() string

type PrometheusTimer added in v1.1.0

type PrometheusTimer struct {
	Enabled bool     `mapstructure:"enabled"`
	Labels  []string `` /* 138-byte string literal not displayed */
}

PrometheusTimer is a configuration structure for enabling and setting labels for Prometheus metrics timers.

func (*PrometheusTimer) GetLabels added in v1.4.11

func (p *PrometheusTimer) GetLabels() []string

GetLabels returns the list of labels configured for the PrometheusTimer.

func (*PrometheusTimer) IsEnabled added in v1.4.11

func (p *PrometheusTimer) IsEnabled() bool

IsEnabled indicates whether the Prometheus timer is enabled based on the Enabled property of PrometheusTimer.

type Protocol

type Protocol struct {
	// contains filtered or unexported fields
}

Protocol is the protocol used between a remote client and a server. This server sets the protocol in an HTTP request header "Auth-Protocol" (Nginx protocol).

func NewProtocol

func NewProtocol(protocol string) *Protocol

NewProtocol creates a new Protocol object with the given protocol string. It initializes the name field of the Protocol object.

Example usage: protocol := NewProtocol("http")

func (*Protocol) Get

func (p *Protocol) Get() string

Get returns the string for a protocol.

func (*Protocol) Set

func (p *Protocol) Set(value string)

Set sets the name of the protocol.

func (*Protocol) String

func (p *Protocol) String() string

func (*Protocol) Type

func (p *Protocol) Type() string

Type returns the name of the type.

type RBL

type RBL struct {
	Name         string `mapstructure:"name" validate:"required"`
	RBL          string `mapstructure:"rbl" validate:"required,hostname"`
	IPv4         bool
	IPv6         bool
	AllowFailure bool   `mapstructure:"allow_failure"`
	ReturnCode   string `mapstructure:"return_code" validate:"required,ip4_addr"`
	Weight       int    `mapstructure:"weight" validate:"omitempty,min=-100,max=100"`
}

type RBLSection

type RBLSection struct {
	SoftWhitelist `mapstructure:"soft_whitelist"`
	Lists         []RBL    `mapstructure:"lists" validate:"required,dive"`
	Threshold     int      `mapstructure:"threshold" validate:"omitempty,min=0,max=100"`
	IPWhiteList   []string `mapstructure:"ip_whitelist" validate:"omitempty,dive,ip_addr|cidr"`
}

func (*RBLSection) String

func (r *RBLSection) String() string

type Redis

type Redis struct {
	DatabaseNmuber int           `mapstructure:"database_number" validate:"omitempty,gte=0,lte=15"`
	Prefix         string        `mapstructure:"prefix" validate:"omitempty,printascii,excludesall= "`
	PasswordNonce  string        `mapstructure:"password_nonce" validate:"omitempty,min=16,alphanumunicode,excludesall= "`
	PoolSize       int           `mapstructure:"pool_size" validate:"omitempty,gte=1"`
	IdlePoolSize   int           `mapstructure:"idle_pool_size" validate:"omitempty,gte=0"`
	TLS            TLS           `mapstructure:"tls" validate:"omitempty"`
	PosCacheTTL    time.Duration `mapstructure:"positive_cache_ttl" validate:"omitempty,max=8760h"`
	NegCacheTTL    time.Duration `mapstructure:"negative_cache_ttl" validate:"omitempty,max=8760h"`
	Master         Master        `mapstructure:"master" validate:"omitempty"`
	Replica        Replica       `mapstructure:"replica" validate:"omitempty"`
	Sentinels      Sentinels     `mapstructure:"sentinels" validate:"omitempty"`
	Cluster        Cluster       `mapstructure:"cluster" validate:"omitempty"`
}

Redis represents the configuration settings for a Redis instance, including master, replica, sentinel, and cluster setups.

func (*Redis) GetCluster added in v1.4.11

func (r *Redis) GetCluster() *Cluster

GetCluster returns a pointer to the Cluster configuration of the Redis instance.

func (*Redis) GetDatabaseNumber added in v1.4.11

func (r *Redis) GetDatabaseNumber() int

GetDatabaseNumber retrieves the configured database number for the Redis instance.

func (*Redis) GetIdlePoolSize added in v1.4.11

func (r *Redis) GetIdlePoolSize() int

GetIdlePoolSize retrieves the number of idle connections allowed in the connection pool.

func (*Redis) GetNegCacheTTL added in v1.4.11

func (r *Redis) GetNegCacheTTL() time.Duration

GetNegCacheTTL retrieves the negative cache time-to-live (TTL) duration configured for the Redis instance.

func (*Redis) GetPasswordNonce added in v1.4.11

func (r *Redis) GetPasswordNonce() string

GetPasswordNonce retrieves the password nonce configured for the Redis instance.

func (*Redis) GetPoolSize added in v1.4.11

func (r *Redis) GetPoolSize() int

GetPoolSize retrieves the size of the connection pool configured for the Redis instance.

func (*Redis) GetPosCacheTTL added in v1.4.11

func (r *Redis) GetPosCacheTTL() time.Duration

GetPosCacheTTL retrieves the positive cache time-to-live (TTL) duration configured for the Redis instance.

func (*Redis) GetPrefix added in v1.4.11

func (r *Redis) GetPrefix() string

GetPrefix retrieves the prefix associated with the Redis instance configuration.

func (*Redis) GetSentinel added in v1.4.11

func (r *Redis) GetSentinel() *Sentinels

GetSentinel returns a pointer to the Sentinels configuration of the Redis instance.

func (*Redis) GetStandaloneMaster added in v1.4.11

func (r *Redis) GetStandaloneMaster() Master

GetStandaloneMaster returns a pointer to the Master configuration of the Redis instance.

func (*Redis) GetStandaloneReplica added in v1.4.11

func (r *Redis) GetStandaloneReplica() Replica

GetStandaloneReplica returns a pointer to the Replica configuration of the Redis instance.

func (*Redis) GetTLS added in v1.4.11

func (r *Redis) GetTLS() *TLS

GetTLS returns a pointer to the TLS configuration of the Redis instance.

type RelayDomainsSection

type RelayDomainsSection struct {
	SoftWhitelist `mapstructure:"soft_whitelist"`
	StaticDomains []string `mapstructure:"static" validate:"required,dive,hostname"`
}

func (*RelayDomainsSection) String

func (r *RelayDomainsSection) String() string

type Replica

type Replica struct {
	Address   string   `mapstructure:"address" validate:"omitempty,hostname_port"`
	Addresses []string `mapstructure:"addresses" validate:"omitempty,dive,hostname_port"`
}

Replica represents the configuration for a Redis replica instance.

func (Replica) GetAddress added in v1.4.11

func (r Replica) GetAddress() string

GetAddress returns the address of the Redis replica instance as a string. Deprecated: Use GetAddresses() instead for retrieving all replica addresses

func (Replica) GetAddresses added in v1.4.11

func (r Replica) GetAddresses() []string

GetAddresses retrieves the list of addresses associated with the Redis replica instance.

type Sentinels

type Sentinels struct {
	Master    string   `mapstructure:"master" validate:"required,printascii,excludesall= "`
	Addresses []string `mapstructure:"addresses" validate:"required,dive,hostname_port"`
	Username  string   `mapstructure:"username" validate:"omitempty,excludesall= "`
	Password  string   `mapstructure:"password" validate:"omitempty,excludesall= "`
}

Sentinels represents the configuration for Redis Sentinel.

func (*Sentinels) GetAddresses added in v1.4.11

func (s *Sentinels) GetAddresses() []string

GetAddresses returns the list of addresses for the Redis Sentinel configuration.

func (*Sentinels) GetMasterName added in v1.4.11

func (s *Sentinels) GetMasterName() string

GetMasterName returns the name of the master Redis instance configured in the Sentinels struct.

func (*Sentinels) GetPassword added in v1.4.11

func (s *Sentinels) GetPassword() string

GetPassword retrieves the password configured for the Redis Sentinel connection.

func (*Sentinels) GetUsername added in v1.4.11

func (s *Sentinels) GetUsername() string

GetUsername retrieves the username configured for the Redis Sentinel connection.

type ServerSection

type ServerSection struct {
	Address                   string                   `mapstructure:"address" validate:"omitempty,tcp_addr"`
	MaxConcurrentRequests     int32                    `mapstructure:"max_concurrent_requests" validate:"required,gte=1"`
	MaxPasswordHistoryEntries int32                    `mapstructure:"max_password_history_entries" validate:"omitempty,gte=1"`
	HTTP3                     bool                     `mapstructure:"http3"`
	HAproxyV2                 bool                     `mapstructure:"haproxy_v2"`
	DisabledEndpoints         Endpoint                 `mapstructure:"disabled_endpoints" validate:"omitempty"`
	TLS                       TLS                      `mapstructure:"tls" validate:"omitempty"`
	BasicAuth                 BasicAuth                `mapstructure:"basic_auth" validate:"omitempty"`
	InstanceName              string                   `mapstructure:"instance_name" validate:"omitempty,max=255,printascii"`
	Log                       Log                      `mapstructure:"log" validate:"omitempty"`
	Backends                  []*Backend               `mapstructure:"backends" validate:"omitempty,dive"`
	Features                  []*Feature               `mapstructure:"features" validate:"omitempty,dive"`
	BruteForceProtocols       []*Protocol              `mapstructure:"brute_force_protocols" validate:"omitempty,dive"`
	HydraAdminUrl             string                   `mapstructure:"ory_hydra_admin_url" validate:"omitempty,http_url"`
	DNS                       DNS                      `mapstructure:"dns" validate:"omitempty"`
	Insights                  Insights                 `mapstructure:"insights" validate:"omitempty"`
	Redis                     Redis                    `mapstructure:"redis" vslidate:"required"`
	MasterUser                MasterUser               `mapstructure:"master_user" validate:"omitempty"`
	Frontend                  Frontend                 `mapstructure:"frontend" validate:"omitempty"`
	PrometheusTimer           PrometheusTimer          `mapstructure:"prometheus_timer" validate:"omitempty"`
	DefaultHTTPRequestHeader  DefaultHTTPRequestHeader `mapstructure:"default_http_request_header" validate:"omitempty"`
	HTTPClient                HTTPClient               `mapstructure:"http_client" validate:"omitempty"`
}

ServerSection represents the configuration for a server, including network settings, TLS, logging, backends, features, protocol handling, and integrations with other systems such as Redis and Prometheus.

func (*ServerSection) GetBackends added in v1.4.11

func (s *ServerSection) GetBackends() []*Backend

GetBackends retrieves the list of backends configured in the ServerSection instance.

func (*ServerSection) GetBasicAuth added in v1.4.11

func (s *ServerSection) GetBasicAuth() *BasicAuth

GetBasicAuth retrieves a pointer to the BasicAuth configuration from the ServerSection instance.

func (*ServerSection) GetBruteForceProtocols added in v1.4.11

func (s *ServerSection) GetBruteForceProtocols() []*Protocol

GetBruteForceProtocols retrieves the list of brute force protection protocols configured in the ServerSection.

func (*ServerSection) GetDNS added in v1.4.11

func (s *ServerSection) GetDNS() *DNS

GetDNS retrieves the DNS configuration from the ServerSection instance.

func (*ServerSection) GetDefaultHTTPRequestHeader added in v1.4.11

func (s *ServerSection) GetDefaultHTTPRequestHeader() *DefaultHTTPRequestHeader

GetDefaultHTTPRequestHeader retrieves a pointer to the DefaultHTTPRequestHeader configuration from the ServerSection instance.

func (*ServerSection) GetEndpoint added in v1.4.11

func (s *ServerSection) GetEndpoint() *Endpoint

GetEndpoint retrieves a pointer to the DisabledEndpoints configuration from the ServerSection instance.

func (*ServerSection) GetFeatures added in v1.4.11

func (s *ServerSection) GetFeatures() []*Feature

GetFeatures retrieves the list of features configured in the ServerSection instance.

func (*ServerSection) GetHTTPClient added in v1.4.11

func (s *ServerSection) GetHTTPClient() *HTTPClient

GetHTTPClient retrieves the HTTP client configuration from the ServerSection instance.

func (*ServerSection) GetInsights added in v1.4.11

func (s *ServerSection) GetInsights() *Insights

GetInsights retrieves a pointer to the Insights configuration from the ServerSection instance.

func (*ServerSection) GetInstanceName added in v1.4.11

func (s *ServerSection) GetInstanceName() string

GetInstanceName retrieves the instance name defined in the ServerSection configuration.

func (*ServerSection) GetListenAddress added in v1.4.11

func (s *ServerSection) GetListenAddress() string

GetListenAddress retrieves the server's listen address from the ServerSection configuration.

func (*ServerSection) GetLog added in v1.4.11

func (s *ServerSection) GetLog() *Log

GetLog retrieves the logging configuration of the ServerSection instance.

func (*ServerSection) GetMasterUser added in v1.4.11

func (s *ServerSection) GetMasterUser() *MasterUser

GetMasterUser retrieves a pointer to the MasterUser configuration from the ServerSection instance.

func (*ServerSection) GetMaxConcurrentRequests added in v1.4.11

func (s *ServerSection) GetMaxConcurrentRequests() int32

GetMaxConcurrentRequests retrieves the maximum number of concurrent requests allowed as configured in ServerSection.

func (*ServerSection) GetMaxPasswordHistoryEntries added in v1.4.11

func (s *ServerSection) GetMaxPasswordHistoryEntries() int32

GetMaxPasswordHistoryEntries retrieves the maximum number of password history entries defined in the ServerSection configuration.

func (*ServerSection) GetPrometheusTimer added in v1.4.11

func (s *ServerSection) GetPrometheusTimer() *PrometheusTimer

GetPrometheusTimer retrieves a pointer to the PrometheusTimer configuration from the ServerSection instance.

func (*ServerSection) GetRedis added in v1.4.11

func (s *ServerSection) GetRedis() *Redis

GetRedis returns a pointer to the Redis configuration of the ServerSection instance.

func (*ServerSection) GetTLS added in v1.4.11

func (s *ServerSection) GetTLS() *TLS

GetTLS retrieves the TLS configuration from the ServerSection instance.

func (*ServerSection) IsHAproxyProtocolEnabled added in v1.4.11

func (s *ServerSection) IsHAproxyProtocolEnabled() bool

IsHAproxyProtocolEnabled checks if the HAProxy protocol (version 2) is enabled in the server configuration and returns the result.

func (*ServerSection) IsHTTP3Enabled added in v1.4.11

func (s *ServerSection) IsHTTP3Enabled() bool

IsHTTP3Enabled checks if HTTP/3 protocol support is enabled in the server configuration and returns the corresponding boolean value.

type SoftWhitelist added in v1.4.0

type SoftWhitelist map[string][]string

SoftWhitelist is a type that represents a map linking a string key to a slice of string values. Typically used to associate users with a list of CIDR networks.

func NewSoftWhitelist added in v1.4.0

func NewSoftWhitelist() SoftWhitelist

NewSoftWhitelist creates and returns a new instance of SoftWhitelist initialized as an empty map of string slices.

func (SoftWhitelist) Delete added in v1.4.0

func (s SoftWhitelist) Delete(username, network string)

Delete removes the specified network from the user's whitelist in the SoftWhitelist. If the network is the only entry, the user is removed from the whitelist. The function does nothing if the whitelist is nil or if the user does not exist.

func (SoftWhitelist) Get added in v1.4.0

func (s SoftWhitelist) Get(username string) []string

Get retrieves the list of networks associated with the specified username from the SoftWhitelist. If the SoftWhitelist is nil or the username does not exist, it returns nil.

func (SoftWhitelist) HasSoftWhitelist added in v1.4.0

func (s SoftWhitelist) HasSoftWhitelist() bool

HasSoftWhitelist checks if the SoftWhitelist is non-nil and contains at least one entry.

func (SoftWhitelist) Set added in v1.4.0

func (s SoftWhitelist) Set(username, network string)

Set adds a specified network to a user's whitelist if the network is valid and the username is not empty.

func (SoftWhitelist) String added in v1.4.0

func (s SoftWhitelist) String() string

type SoftWhitelistProvider added in v1.4.0

type SoftWhitelistProvider interface {
	// HasSoftWhitelist checks if there is at least one entry in the soft whitelist, returning true if it exists, otherwise false.
	HasSoftWhitelist() bool

	// Get retrieves the list of networks associated with the given username from the soft whitelist.
	Get(username string) []string

	// Set adds a specified network to a user's whitelist if the network is valid and the username is not empty.
	Set(username, network string)

	// Delete removes a specified network from the user's soft whitelist identified by the provided username.
	Delete(username, network string)
}

SoftWhitelistProvider defines the methods for managing a soft whitelist of networks associated with usernames. The interface allows checking the existence of a whitelist, retrieving, setting, and deleting networks.

type StringSet

type StringSet map[string]any

StringSet is a storage container that ensures unique keys.

func NewStringSet

func NewStringSet() StringSet

NewStringSet constructs a new StringSet

func (*StringSet) GetStringSlice

func (s *StringSet) GetStringSlice() (result []string)

GetStringSlice returns all values for a StringSet as a slice of strings.

func (*StringSet) Set

func (s *StringSet) Set(value string)

Set adds an element to the StringSet

func (*StringSet) String added in v1.3.5

func (s *StringSet) String() string

type TLS

type TLS struct {
	Enabled              bool   `mapstructure:"enabled"`
	Cert                 string `mapstructure:"cert" validate:"omitempty,file"`
	Key                  string `mapstructure:"key" validate:"omitempty,file"`
	HTTPClientSkipVerify bool   `mapstructure:"http_client_skip_verify"`
}

TLS represents the configuration for enabling TLS and managing certificates.

func (*TLS) GetCert added in v1.4.11

func (t *TLS) GetCert() string

GetCert returns the TLS certificate as a string.

func (*TLS) GetHTTPClientSkipVerify added in v1.4.11

func (t *TLS) GetHTTPClientSkipVerify() bool

GetHTTPClientSkipVerify returns the value of the HTTPClientSkipVerify field, indicating whether TLS verification is skipped.

func (*TLS) GetKey added in v1.4.11

func (t *TLS) GetKey() string

GetKey returns the TLS key as a string.

func (*TLS) IsEnabled added in v1.4.11

func (t *TLS) IsEnabled() bool

IsEnabled returns true if TLS is enabled, otherwise false.

type Tolerate added in v1.5.1

type Tolerate struct {
	IPAddress       string        `mapstructure:"ip_address" validate:"required,ip_addr|cidr"`
	ToleratePercent uint8         `mapstructure:"tolerate_percent" validate:"required,min=0,max=100"`
	TolerateTTL     time.Duration `mapstructure:"tolerate_ttl" validate:"required,gt=0,max=8760h"`
}

Tolerate represents a configuration item for toleration settings based on IP, percentage, and Time-to-Live (TTL).

type Verbosity

type Verbosity struct {
	// contains filtered or unexported fields
}

Verbosity is a type that represents the verbosity details.

func (*Verbosity) Get

func (v *Verbosity) Get() string

Get returns the name of the log level as string.

func (*Verbosity) Level

func (v *Verbosity) Level() int

Level returns the verbosity level of the Verbosity instance.

func (*Verbosity) Set

func (v *Verbosity) Set(value string) error

Set updates the verbosity level and name based on the provided value. It returns an error if the value is not valid. Valid values for the verbosity level are "none", "error", "warn", "info", and "debug". If the value is valid, the verboseLevel and name fields are updated accordingly. An error of type ErrWrongVerboseLevel is returned if the value is not valid.

func (*Verbosity) String

func (v *Verbosity) String() string

func (*Verbosity) Type

func (v *Verbosity) Type() string

Type returns the type of the Verbosity struct.

Jump to

Keyboard shortcuts

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