auth

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

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.

func NewConfigWith

func NewConfigWith(config config.Config, path ...string) ([]Config, error)

NewConfigWith returns a new configuration for authenticator with the specified configuration.

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.

Jump to

Keyboard shortcuts

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