errors

package
v4.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package errors provides errors functionality.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAllBackendConfigError reports that every configured backend section failed validation.
	ErrAllBackendConfigError = NewDetailedError("configuration errors in all Database sections")
	// ErrUnsupportedMediaType reports an unsupported request content type.
	ErrUnsupportedMediaType = errors.New("unsupported media type")
	// ErrBackendHealthChecksDisabled reports that backend health checks are not enabled.
	ErrBackendHealthChecksDisabled = errors.New("backend_health_checks not enabled")
	// ErrMonitoringBackendServersEmpty reports that backend monitoring has no configured targets.
	ErrMonitoringBackendServersEmpty = errors.New("no monitoring backend servers configured")
	// ErrInvalidUsername reports a syntactically invalid username.
	ErrInvalidUsername = errors.New("invalid username")
	// ErrEmptyUsername reports an empty username.
	ErrEmptyUsername = errors.New("empty_username")
	// ErrEmptyPassword reports an empty password.
	ErrEmptyPassword = errors.New("empty_password")
	// ErrPasswordEncoding reports a password encoding failure.
	ErrPasswordEncoding = errors.New("password encoding error")
	// ErrIncorrectCache reports an unexpected cache backend state.
	ErrIncorrectCache = errors.New("incorrect cache")
	// ErrUnregisteredComponent reports an unknown application component.
	ErrUnregisteredComponent = errors.New("unregistered component")
)
View Source
var (
	// ErrWrongVerboseLevel reports an invalid verbosity configuration value.
	ErrWrongVerboseLevel = errors.New("wrong verbose level: <%s>")
	// ErrWrongLDAPScope reports an invalid LDAP scope configuration value.
	ErrWrongLDAPScope = errors.New("wrong LDAP scope: <%s>")
	// ErrWrongPassDB reports an invalid passdb backend configuration value.
	ErrWrongPassDB = errors.New("wrong passdb backend: <%s>")
	// ErrWrongRuntimeModule reports an invalid runtime module configuration value.
	ErrWrongRuntimeModule = errors.New("wrong runtime module: <%s>")
	// ErrWrongDebugModule reports an invalid debug module configuration value.
	ErrWrongDebugModule = errors.New("wrong debug module: <%s>")
)
View Source
var (
	// ErrNoLDAPSection reports that the LDAP backend root is missing.
	ErrNoLDAPSection = errors.New("no 'auth.backends.ldap' section found")
	// ErrNoLDAPSearchSection reports that no LDAP protocol mappings are configured.
	ErrNoLDAPSearchSection = errors.New("no 'auth.backends.ldap.search' section found")
)
View Source
var (
	// ErrLDAPConnect is an exported package value.
	ErrLDAPConnect = NewDetailedError("ldap_servers_connect_error")
	// ErrLDAPConfig is an exported package value.
	ErrLDAPConfig = NewDetailedError("ldap_config_error")
	// ErrNoLDAPSearchResult reports that an LDAP search returned no matching entry.
	ErrNoLDAPSearchResult = NewDetailedError("ldap_no_search_result")
	// ErrLDAPConnectTimeout reports that an LDAP connection attempt timed out.
	ErrLDAPConnectTimeout = NewDetailedError("ldap_connect_timeout")
	// ErrLDAPSearchTimeout reports that an LDAP search operation timed out.
	ErrLDAPSearchTimeout = NewDetailedError("ldap_search_timeout")
	// ErrLDAPBindTimeout reports that an LDAP bind operation timed out.
	ErrLDAPBindTimeout = NewDetailedError("ldap_bind_timeout")
	// ErrLDAPModify reports that an LDAP modify operation failed.
	ErrLDAPModify = NewDetailedError("ldap_modify_error")
	// ErrLDAPPoolExhausted indicates that the LDAP pool could not serve the request
	// within the allotted time (capacity token acquisition or waiting for a free
	// connection timed out). Callers should treat this as a temporary failure and
	// avoid mapping it to "user not found".
	ErrLDAPPoolExhausted = NewDetailedError("ldap_pool_exhausted")
	// ErrBackendTemporaryFailure indicates that a backend could not make an auth
	// decision because of a temporary technical failure.
	ErrBackendTemporaryFailure = NewDetailedError("backend_temporary_failure")
	// ErrBackendNotResponsible indicates that a backend declined to handle the
	// request at all, because its configuration does not cover this protocol or
	// operation. It is not a failure: the remaining backends still answer.
	ErrBackendNotResponsible = NewDetailedError("backend_not_responsible")
)
View Source
var (
	// ErrLuaConfig is an exported package value.
	ErrLuaConfig = NewDetailedError("lua_config_error")
	// ErrBackendLuaWrongUserData is an exported package value.
	ErrBackendLuaWrongUserData = NewDetailedError("wrong_user_data_result")
	// ErrBackendLua reports a Lua script execution failure.
	ErrBackendLua = NewDetailedError("script_execution_failed")
)
View Source
var (
	// ErrUnsupportedAlgorithm is an exported package value.
	ErrUnsupportedAlgorithm = errors.New("unsupported hash algorithm")
	// ErrUnsupportedPasswordOption is an exported package value.
	ErrUnsupportedPasswordOption = errors.New("unsupported password option")
)
View Source
var (
	// ErrNoPassDBResult is an exported package value.
	ErrNoPassDBResult = errors.New("no pass Database result")
	// ErrUnknownCause is an exported package value.
	ErrUnknownCause = errors.New("something went wrong")
	// ErrDurationTooHigh reports an out-of-range duration value.
	ErrDurationTooHigh = errors.New("duration of too high")
)
View Source
var (
	// ErrRuleNoIPv4AndIPv6 is an exported package value.
	ErrRuleNoIPv4AndIPv6 = errors.New("do not set 'ipv4' and 'ipv6' at the same time in a rule")
	// ErrRuleMissingIPv4AndIPv6 is an exported package value.
	ErrRuleMissingIPv4AndIPv6 = errors.New("neither 'ipv4' nor 'ipv6' specified in rule")
	// ErrWrongIPAddress reports an invalid IP address value.
	ErrWrongIPAddress = errors.New("unable to parse IP address")
)
View Source
var (
	// ErrNoAccount is an exported package value.
	ErrNoAccount = errors.New("no account found")
	// ErrNoTLS is an exported package value.
	ErrNoTLS = errors.New("no tls connection")
	// ErrTOTPCodeInvalid reports an invalid TOTP code.
	ErrTOTPCodeInvalid = errors.New("totp code invalid")
	// ErrNoTOTPCode reports that no TOTP code was provided.
	ErrNoTOTPCode = errors.New("totp code not found")
	// ErrBruteForceAttack reports that brute-force protections blocked the request.
	ErrBruteForceAttack = errors.New("please contact the support")
)
View Source
var (
	// ErrLanguageNotFound is an exported package value.
	ErrLanguageNotFound = errors.New("requested language not found")
	// ErrUnauthorized is an exported package value.
	ErrUnauthorized = errors.New("unauthorized")
)
View Source
var (
	// ErrNotLoggedIn is an exported package value.
	ErrNotLoggedIn = errors.New("user not logged in")
	// ErrNoTOTPURL is an exported package value.
	ErrNoTOTPURL = errors.New("no TOTP URL found")
)
View Source
var (
	// ErrWebAuthnSessionData is an exported package value.
	ErrWebAuthnSessionData = errors.New("no webauthn session data found")
	// ErrNoDisplayName is an exported package value.
	ErrNoDisplayName = errors.New("no display name found")
	// ErrUnknownDatabaseBackend reports an unsupported database backend.
	ErrUnknownDatabaseBackend = errors.New("unknown Database backend")
)
View Source
var (
	// ErrEnvironmentSourceLuaNameMissing indicates a Lua environment source without a name.
	ErrEnvironmentSourceLuaNameMissing = errors.New("environment source 'name' attribute missing")

	// ErrEnvironmentSourceLuaScriptPathEmpty indicates a Lua environment source without a script path.
	ErrEnvironmentSourceLuaScriptPathEmpty = errors.New("environment source 'script_path' attribute missing")
)
View Source
var (
	// ErrNoRuntimeModuleDefined indicates that a required runtime module was not configured.
	ErrNoRuntimeModuleDefined = errors.New("no runtime module defined")

	// ErrNoSubjectSourcesDefined indicates that no Lua subject sources are configured.
	ErrNoSubjectSourcesDefined = errors.New("no subject sources defined")

	// ErrSubjectSourceLuaNameMissing indicates a Lua subject source without a name.
	ErrSubjectSourceLuaNameMissing = errors.New("subject source 'name' attribute missing")

	// ErrSubjectSourceLuaScriptPathEmpty indicates a Lua subject source without a script path.
	ErrSubjectSourceLuaScriptPathEmpty = errors.New("subject source 'script_path' attribute missing")
)
View Source
var (
	// ErrNotImplemented is an exported package value.
	ErrNotImplemented = errors.New("not implemented yet")
	// ErrInvalidRange is an exported package value.
	ErrInvalidRange = errors.New("invalid range")
)
View Source
var (
	// ErrDNSResolver is an exported package value.
	ErrDNSResolver = errors.New("resolver failed")
)
View Source
var (
	// ErrMissingTLS is an exported package value.
	ErrMissingTLS = errors.New("missing TLS connection")
)
View Source
var ErrTokenValidationUnavailable = errors.New("token validation unavailable")

ErrTokenValidationUnavailable reports that a token could not be validated because authoritative token state or signing key material was unreachable.

It is never a verdict about the token. Callers must answer with a temporary failure and must not count it as a failed caller authentication: counting it would lock out every caller that shares the source address as soon as the token store degrades.

Functions

func IsBackendNotResponsible

func IsBackendNotResponsible(err error) bool

IsBackendNotResponsible reports whether err means a backend declined the request rather than failed it.

The difference decides whether a later backend's verdict counts. A backend that declines leaves the chain intact, so the next backend's answer is authoritative. A backend that failed leaves the request undecided, and a negative answer taken from elsewhere would present that outage as a wrong password.

Only ErrBackendNotResponsible qualifies, and it is minted at the few places that genuinely decide "this backend does not serve this request". Configuration errors are deliberately excluded: most of them mean a broken or half-configured backend, and some are raised after the user was already found. Reading those as declines would let a broken backend hand the verdict to one that knows nothing about the user.

func IsBackendTechnicalFailure

func IsBackendTechnicalFailure(err error) bool

IsBackendTechnicalFailure reports whether err describes a backend that could not decide, as opposed to a backend that decided against the credentials.

func IsTokenValidationUnavailable

func IsTokenValidationUnavailable(err error) bool

IsTokenValidationUnavailable reports whether err means that token validation could not reach a decision, as opposed to a token that was rejected.

func NewTokenValidationUnavailable

func NewTokenValidationUnavailable(cause error) error

NewTokenValidationUnavailable marks cause as a technical token validation failure. It returns nil for a nil cause and leaves already marked errors unchanged, so repeated classification along a call chain stays idempotent.

Types

type DetailedError

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

DetailedError describes the exported DetailedError type.

func NewDetailedError

func NewDetailedError(err string) *DetailedError

NewDetailedError provides the exported NewDetailedError function.

func (*DetailedError) Error

func (d *DetailedError) Error() string

func (*DetailedError) GetDetails

func (d *DetailedError) GetDetails() string

GetDetails provides the exported GetDetails method.

func (*DetailedError) GetGUID

func (d *DetailedError) GetGUID() string

GetGUID provides the exported GetGUID method.

func (*DetailedError) GetInstance

func (d *DetailedError) GetInstance() string

GetInstance provides the exported GetInstance method.

func (*DetailedError) Is

func (d *DetailedError) Is(target error) bool

Is reports whether target matches this DetailedError. Two DetailedErrors match when they share the same underlying error string, so copies produced by WithDetail/WithGUID/WithInstance still match the original sentinel.

func (*DetailedError) Unwrap

func (d *DetailedError) Unwrap() error

Unwrap returns the underlying error, enabling errors.Is to match copies created by WithDetail/WithGUID/WithInstance against the original sentinel.

func (*DetailedError) WithDetail

func (d *DetailedError) WithDetail(detail string) *DetailedError

WithDetail provides the exported WithDetail method.

func (*DetailedError) WithGUID

func (d *DetailedError) WithGUID(guid string) *DetailedError

WithGUID provides the exported WithGUID method.

func (*DetailedError) WithInstance

func (d *DetailedError) WithInstance(instance string) *DetailedError

WithInstance provides the exported WithInstance method.

Jump to

Keyboard shortcuts

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