Documentation ¶
Overview ¶
Package auth defines potentially multiple mechanisms to determine whether supplied user credentials in an IMAP session can be found in a defined user information system. Examples include an authenticator based on a user table in a PostgreSQL database and a simple (potentially insecure) plain user text file. It is easily possible to implement new authenticators that fit specific requirements.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type File ¶ added in v0.4.1
type File struct {
Users []User
}
File contains file based authentication information including the in-memory map of username to password mapping.
func NewFile ¶ added in v0.4.1
NewFile takes in a file name and a separator, reads in specified file and parses it line by line as username - password elements separated by the separator. At the end, the returned struct contains the information and an in-memory map of username mapped to password.
func (*File) AuthenticatePlain ¶ added in v0.4.1
func (f *File) AuthenticatePlain(username string, password string, clientAddr string) (int, string, error)
AuthenticatePlain performs the actual authentication process by taking supplied credentials and attempting to find a matching entry the in-memory list taken from the authentication file.
type PostgresAuthenticator ¶ added in v0.1.6
type PostgresAuthenticator struct {
Conn *pgx.Conn
}
PostgresAuthenticator carries all relevant information needed to allow the PostgreSQL-based authenticator to properly authenticate incoming client requests.
func NewPostgresAuthenticator ¶ added in v0.1.6
func NewPostgresAuthenticator(ip string, port uint16, db string, user string, password string, useTLS bool) (*PostgresAuthenticator, error)
NewPostgresAuthenticator expects to be supplied with PostgreSQL database connection information from the config file. It then tries to connect to the database and returns an initialized struct above.
func (*PostgresAuthenticator) AuthenticatePlain ¶ added in v0.1.6
func (p *PostgresAuthenticator) AuthenticatePlain(username string, password string, clientAddr string) (int, string, error)
AuthenticatePlain is used to perform the actual process of looking up if the client supplied user credentials exist and match with an user entry in the PostgreSQL database.
func (*PostgresAuthenticator) GetWorkerForUser ¶ added in v0.1.6
func (p *PostgresAuthenticator) GetWorkerForUser(workers map[string]config.Worker, id int) (string, error)
GetWorkerForUser returns the name of the worker node that is responsible for handling the user's mailbox.