auth

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: May 11, 2017 License: GPL-3.0 Imports: 10 Imported by: 0

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

func NewFile(file string, sep string) (*File, error)

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.

func (*File) GetWorkerForUser added in v0.4.1

func (f *File) 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.

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.

type User

type User struct {
	ID       int
	Name     string
	Password string
}

User holds name and password from one line from users file.

Jump to

Keyboard shortcuts

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