auth

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2017 License: GPL-3.0 Imports: 7 Imported by: 2

Documentation

Overview

Package auth defines potentially multiple mechanisms to determine whether supplied user credentials via an IMAP session can be found in a defined user information system. Examples include an authenticator based on a user database in a PostgreSQL database and a simple lookup function if username and password match.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileAuthenticator

type FileAuthenticator struct {
	File      string
	Separator string
	Users     []User
	// contains filtered or unexported fields
}

FileAuthenticator contains file based authentication information including the in-memory map of username to password mapping.

func NewFileAuthenticator

func NewFileAuthenticator(file string, sep string) (*FileAuthenticator, error)

NewFileAuthenticator 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 (*FileAuthenticator) AuthenticatePlain

func (f *FileAuthenticator) 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 (*FileAuthenticator) GetWorkerForUser

func (f *FileAuthenticator) 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 PlainAuthenticator

type PlainAuthenticator interface {

	// GetWorkerForUser allows us to route an IMAP request to the
	// worker node responsible for a specific user.
	GetWorkerForUser(workers map[string]config.Worker, id int) (string, error)

	// AuthenticatePlain will be implemented by each of the
	// authentication methods of type PLAIN to perform the
	// actual part of checking supplied credentials.
	AuthenticatePlain(username string, password string, clientAddr string) (int, string, error)
}

PlainAuthenticator defines the methods required to perform an IMAP AUTH=PLAIN authentication in order to reach authenticated state (also LOGIN).

type User

type User struct {
	ID       int
	Name     string
	Password string
}

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

type UsersByName

type UsersByName []User

UsersByName defines a list type of users to search efficiently.

func (UsersByName) Len

func (u UsersByName) Len() int

Make list of users searchable efficiently.

func (UsersByName) Less

func (u UsersByName) Less(i, j int) bool

func (UsersByName) Swap

func (u UsersByName) Swap(i, j int)

Jump to

Keyboard shortcuts

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