basicauth

package
v0.0.0-...-84d4900 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ErrInvName is the error for invalid name.
	ErrInvName = "invalid user name"
	// ErrBlankPass is the error for blank password
	ErrBlankPass = "blank password isn't allowed"
	//ErrInvHash is the error for invalid hash type
	ErrInvHash = "invalid password hash type"
)
View Source
const ErrDecodeUsrPass = "failed to decode the user and password string"
View Source
const ErrInvalidAuthHeader = "invalid authorization header"
View Source
const ErrInvalidAuthScheme = "invalid authorization scheme"
View Source
const ErrInvalidAuthString = "invalid authorization string"
View Source
const ErrInvalidUsrPassString = "invalid user pass string"
View Source
const ErrNoAuthHeader = "no authorization header found"

Variables

View Source
var Hash map[string]hash.Hash

Functions

func Basic

func Basic(r *http.Request) (user, pass string, err error)

Basic gets the first scheme in Authorization header and return the userid and the password.

func BasicAuth

func BasicAuth(realm string, v Validator, handler http.HandlerFunc) http.HandlerFunc

Types

type Users

type Users map[string]string

func (Users) SetPass

func (u Users) SetPass(user, plainpass, hashtype string) error

func (Users) SetRaw

func (u Users) SetRaw(user, pass string) error

func (Users) Validate

func (u Users) Validate(user, plainpass string) bool

type Validator

type Validator interface {
	Validate(user, pass string) bool
}

Jump to

Keyboard shortcuts

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