Documentation ¶
Index ¶
Constants ¶
View Source
const (
// AuthenticatorTypePasswordString represents an authenticator type of password as a string.
AuthenticatorTypePasswordString = "password"
)
Variables ¶
View Source
var ( ErrInvalid = errors.New("invalid") ErrAuthentication = errors.New("authentication failed") )
Functions ¶
func NewErrInvalidUserPassword ¶
func NewErrInvalidUserPassword() error
NewErrInvalidUserPassword returns an error for invalid username or password.
Types ¶
type AuthManager ¶
type AuthManager interface { // AddAuthenticator adds a new authenticator. AddAuthenticator(authenticator Authenticator) // ClearAuthenticators clears all authenticators. ClearAuthenticators() // AuthenticatePassword authenticates a user with a password. AuthenticatePassword(conn Conn, username string, password string) (bool, error) }
AuthManager represent an authenticator manager interface.
func NewAuthManager ¶
func NewAuthManager() AuthManager
NewAuthManager returns a new authenticator manager.
type Authenticator ¶
type Authenticator interface { }
Authenticator is an interface for authenticator.
type AuthenticatorType ¶
type AuthenticatorType int
AuthenticatorType represents an authenticator type.
const ( // AuthenticatorTypeNone represents an authenticator type of none. AuthenticatorTypeNone AuthenticatorType = iota // AuthenticatorTypePassword represents an authenticator type of password. AuthenticatorTypePassword )
func NewAuthenticatorTypeFrom ¶
func NewAuthenticatorTypeFrom(str string) (AuthenticatorType, error)
NewAuthenticatorTypeFrom returns an authenticator type from the specified string.
func (AuthenticatorType) String ¶
func (t AuthenticatorType) String() string
String returns a string representation of the authenticator type.
type Config ¶
type Config struct { Type string `mapstructure:"type"` Enabled bool `mapstructure:"enabled"` User string `mapstructure:"user"` Password string `mapstructure:"password"` }
Config represents a configuration for authenticator.
type Conn ¶
type Conn interface { // RemoteAddr returns the remote network address, if known. RemoteAddr() net.Addr }
Conn is an interface for connections.
type PasswordAuthenticator ¶
type PasswordAuthenticator interface { // User returns the authorized user. User() string // Password returns the authorized password. Password() string // AuthenticatePassword authenticates a user with a password. AuthenticatePassword(conn Conn, username string, password string) (bool, error) }
PasswordAuthenticator is an interface for password authenticator.
Click to show internal directories.
Click to hide internal directories.