Version: v0.0.0-...-040c84b Latest Latest

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

Go to latest
Published: Jul 7, 2017 License: AGPL-3.0 Imports: 8 Imported by: 0




This section is empty.


View Source
var (
	// ErrUserNotFound used when we fail to retrieve a user
	ErrUserNotFound = errors.New("User Not Found")
	// ErrInvalidCredential used with attempting to compare mismatched
	// credential types
	ErrInvalidCredential = errors.New("Invlaid Credential")


func GenerateKey

func GenerateKey(password string) ([]byte, error)

GenerateKey derives an encryption key from a password


type Authenticator

type Authenticator interface {
	Authenticate(credential Credential) (bool, error)

Authenticator interface used authenticate a request

func NewAuthenticator

func NewAuthenticator(credStore CredStore) Authenticator

NewAuthenticator instantiates a new authenticator

type CredStore

type CredStore interface {
	RetrieveCredential(id UserID) (Credential, error)

CredStore abstraction for credential lookup

func NewJWTCredStore

func NewJWTCredStore(secret []byte, method jwt.SigningMethod) CredStore

NewJWTCredStore instantiates a cred store for checking jwts

type Credential

type Credential interface {
	UserID() UserID
	Check(Credential) (bool, error)

Credential used for authentication

func NewJWTCredential

func NewJWTCredential(tokenStr string) (Credential, error)

NewJWTCredential creates a new JWTCredential

func NewPlainTextCredential

func NewPlainTextCredential(user string, password string) Credential

NewPlainTextCredential creates a simple credential using a user id and password

type HashedMapStore

type HashedMapStore struct {
	// contains filtered or unexported fields

HashedMapStore simple in memory credstore

func NewHashedMapStore

func NewHashedMapStore(data map[string]string) (*HashedMapStore, error)

NewHashedMapStore takes a map of user ids as keys and plain text passwords as values, salts and hashes them, and indexes them by user ids and creates a HashedMapStore/CredStore for authentication

func (*HashedMapStore) RetrieveCredential

func (m *HashedMapStore) RetrieveCredential(userID UserID) (Credential, error)

RetrieveCredential looksup a credential by userID

type JWTCredential

type JWTCredential struct {
	// contains filtered or unexported fields

JWTCredential javascript web token

func (*JWTCredential) Check

func (j *JWTCredential) Check(other Credential) (bool, error)

Check cant really verify against itself, so this is not implemented

func (*JWTCredential) UserID

func (j *JWTCredential) UserID() UserID

UserID returns the user id

type PlainTextCredential

type PlainTextCredential struct {
	// contains filtered or unexported fields

PlainTextCredential plain text username/password

func (PlainTextCredential) Check

func (b PlainTextCredential) Check(other Credential) (bool, error)

Check checks the plain text credential against another

func (PlainTextCredential) UserID

func (b PlainTextCredential) UserID() UserID

UserID returns the user id

type UserID

type UserID interface {

UserID basic user identifier

Jump to

Keyboard shortcuts

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