auth

package
v0.0.0-...-91c0e42 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnauthorized indicates an unauthorized
	// request attempt
	ErrUnauthorized = errors.New("unauthorized")
)

Functions

func CheckHash

func CheckHash(s, hash string) bool

CheckHash returns if the passed, bcrypt generated hash matches the passed string.

func CreateHash

func CreateHash(s string, rounds int) (string, error)

CreateHash creates a hash from a string using the blowfish algorithm.

Types

type Provider

type Provider interface {
	// Authenticate takes the context of a HTTP
	// request and returns an object which should
	// describe the authenticated user/account and
	// and error if the authentication failes.
	Authenticate(ctx *routing.Context) (interface{}, error)
}

Provider describes which functions an Authentication provider must provide.

type TokenAuthProvider

type TokenAuthProvider struct {
	// contains filtered or unexported fields
}

TokenAuthProvider provides an authentication method using basic header based authentication tokens.

func NewTokenAuthProvider

func NewTokenAuthProvider(tokenHash string) *TokenAuthProvider

NewTokenAuthProvider creates a new instance of TokenAuthProvider passing the token to be used for authentication as bcrypt hash.

func (*TokenAuthProvider) Authenticate

func (tap *TokenAuthProvider) Authenticate(ctx *routing.Context) (interface{}, error)

Authenticate checks the Authorization header for a Basic token and checks equality to the defined reference API token.

Jump to

Keyboard shortcuts

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