auth

package
v0.0.0-...-e48fc18 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2016 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotConnected = fmt.Errorf("database not connected")
)

Functions

func CheckPassword

func CheckPassword(plainPassword, hash []byte) bool

CheckPassword checks if the hash was the result of hashing this specific plainPassword

func HashPassword

func HashPassword(plainPassword []byte) ([]byte, error)

HashPassword hashes the plainPassword using the bcrypt.DefaultCost

Types

type AuthStore

type AuthStore interface {
	// Authenticate attempts to authenticate the given credentials
	Authenticate(username, plainPassword string) (success bool, err error)

	// CreateUser creates a user with the given username
	CreateUser(username, plainPassword string) error

	// ResetPassword resets the password for the given username
	ResetPassword(username, plainPassword string) error

	// ListUsers lists all information about the users
	// TODO: this could be very neat for the sysadmin, but probably a lot of metadata
	// 		 about users is desired, and not just the usernames.
	ListUsers() (usernames []string, err error)

	// DeleteUser removes the username from the database entirely
	DeleteUser(username string) error
}

AuthStore contacts the backend to query about the users. It is used for database interaction only.

type DummyAuthBackend

type DummyAuthBackend struct {
}

func (DummyAuthBackend) Authenticate

func (d DummyAuthBackend) Authenticate(u, p string) (bool, error)

func (DummyAuthBackend) CreateUser

func (d DummyAuthBackend) CreateUser(u, p string) error

func (DummyAuthBackend) DeleteUser

func (d DummyAuthBackend) DeleteUser(u string) error

func (DummyAuthBackend) ListUsers

func (d DummyAuthBackend) ListUsers() ([]string, error)

func (DummyAuthBackend) ResetPassword

func (d DummyAuthBackend) ResetPassword(u, p string) error

Directories

Path Synopsis
Package boltstore holds an implementation of github.com/alienscience/imapsrv/auth - AuthStore, using github.com/boltdb/bolt - DB.
Package boltstore holds an implementation of github.com/alienscience/imapsrv/auth - AuthStore, using github.com/boltdb/bolt - DB.
Package mysqlstore holds an implementation of github.com/alienscience/imapsrv/auth - AuthStore, using MySQL
Package mysqlstore holds an implementation of github.com/alienscience/imapsrv/auth - AuthStore, using MySQL

Jump to

Keyboard shortcuts

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