Documentation
¶
Index ¶
- Variables
- func PlainEncrypt(passwd any, args ...any) (any, error)
- type Conn
- type Credential
- type CredentialAuthenticator
- type CredentialOptionFn
- type CredentialStore
- type CredentialStoreRegistrar
- type EncryptFunc
- type Manager
- type Query
- type QueryOption
- type QueryOptionFn
- func WithQueryArguments(args ...any) QueryOptionFn
- func WithQueryEncryptFunc(encryptFunc EncryptFunc) QueryOptionFn
- func WithQueryGroup(group string) QueryOptionFn
- func WithQueryMechanism(mech string) QueryOptionFn
- func WithQueryOptions(opt ...any) QueryOptionFn
- func WithQueryPassword(password any) QueryOptionFn
- func WithQueryUsername(username string) QueryOptionFn
Constants ¶
This section is empty.
Variables ¶
var ErrNoCredential = errors.New("no credential")
ErrNoCredential is the error that is returned when no credential is found.
var ErrNoCredentialStore = errors.New("no credential store")
ErrNoCredentialStore is the error that is returned when no credential store is found.
Functions ¶
Types ¶
type Conn ¶
type Conn interface { // RemoteAddr returns the remote network address, if known. RemoteAddr() net.Addr }
Conn represents a connection interface.
type Credential ¶
type Credential interface { Group() string // Username returns the username. Username() string // Password returns the password. Password() any }
Credential represents a credential interface.
func NewCredential ¶
func NewCredential(opts ...CredentialOptionFn) Credential
NewCredential returns a new credential with options.
type CredentialAuthenticator ¶
type CredentialAuthenticator interface { // VerifyCredential verifies the client credential. VerifyCredential(conn Conn, q Query) (bool, error) }
CredentialAuthenticator is the interface for authenticating a client using credential.
func NewDefaultCredentialAuthenticator ¶
func NewDefaultCredentialAuthenticator() CredentialAuthenticator
NewDefaultCredentialAuthenticator returns a new default credential authenticator.
type CredentialOptionFn ¶
type CredentialOptionFn func(*cred)
CredentialOptionFn represents an option for a credential.
func WithCredentialGroup ¶
func WithCredentialGroup(group string) CredentialOptionFn
WithCredentialGroup returns an option to set the group.
func WithCredentialPassword ¶
func WithCredentialPassword(password any) CredentialOptionFn
WithCredentialPassword returns an option to set the password.
func WithCredentialUsername ¶
func WithCredentialUsername(username string) CredentialOptionFn
WithCredentialUsername returns an option to set the username.
type CredentialStore ¶
type CredentialStore interface { // LookupCredential looks up a credential by the given query. // // Parameters: // q - The query used to look up the credential. // // Returns: // Credential - The credential associated with the query. // bool - A boolean indicating whether the credential was found (true) or not (false). // error - An error if there was an issue during the lookup process, or nil if the lookup was successful. // // If the credential is not found, the function returns an empty Credential, false, and nil error. // If an error occurs during the lookup process, the function returns an empty Credential, false, and the error. LookupCredential(q Query) (Credential, bool, error) }
CredentialStore represents a credential store interface.
type CredentialStoreRegistrar ¶ added in v1.2.3
type CredentialStoreRegistrar interface { // SetCredentialStore sets the credential store. SetCredentialStore(credStore CredentialStore) }
CredentialStore is the interface for storing credentials.
type EncryptFunc ¶ added in v1.2.4
EncryptFunc represents an encrypt function.
type Manager ¶
type Manager interface { // SetCredentialAuthenticator sets the credential authenticator. SetCredentialAuthenticator(auth CredentialAuthenticator) // SetCredentialStore sets the credential store. SetCredentialStore(credStore CredentialStore) // CredentialStore returns the credential store. CredentialStore() CredentialStore // VerifyCredential verifies the client credential. VerifyCredential(conn Conn, q Query) (bool, error) }
Manager represents a auth manager interface.
type Query ¶
type Query interface { // SetGroup sets the group. SetGroup(group string) // SetUsername sets the username. SetUsername(username string) // SetPassword sets the password. SetPassword(password any) // SetMechanism sets the mechanism. SetMechanism(mech string) // SetOptions sets the options. SetOptions(opts ...any) // SetArguments sets the arguments. SetArguments(args ...any) // SetEncryptFunc sets the encrypt function. SetEncryptFunc(encryptFunc EncryptFunc) // Group returns the group. Group() string // Username returns the username. Username() string // Password returns the password. Password() any // Mechanism returns the mechanism. Mechanism() string // Options returns the options. Options() []any // EncryptFunc returns the encrypt function. EncryptFunc() EncryptFunc // Arguments returns the arguments for the encrypt function. Arguments() []any }
Query represents a query interface.
func NewQuery ¶
func NewQuery(opts ...QueryOptionFn) (Query, error)
NewQuery returns a new query with options.
type QueryOptionFn ¶
QueryOptionFn represents an option function for a query.
func WithQueryArguments ¶ added in v1.2.4
func WithQueryArguments(args ...any) QueryOptionFn
WithQueryArguments returns an option to set the arguments for the encrypt function.
func WithQueryEncryptFunc ¶ added in v1.2.4
func WithQueryEncryptFunc(encryptFunc EncryptFunc) QueryOptionFn
WithQueryEncryptFunc returns an option to set the encrypt function.
func WithQueryGroup ¶
func WithQueryGroup(group string) QueryOptionFn
WithQueryGroup returns an option to set the group.
func WithQueryMechanism ¶
func WithQueryMechanism(mech string) QueryOptionFn
WithQueryMechanism returns an option to set the mechanism.
func WithQueryOptions ¶ added in v1.2.4
func WithQueryOptions(opt ...any) QueryOptionFn
WithQueryOptions returns an option to set the options.
func WithQueryPassword ¶
func WithQueryPassword(password any) QueryOptionFn
WithQueryPassword returns an option to set the password.
func WithQueryUsername ¶
func WithQueryUsername(username string) QueryOptionFn
WithQueryUsername returns an option to set the username.