auth

package
v1.0.31 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoAuthHeader = no authorization header
	ErrNoAuthHeader = errors.New("missing authorization header of type Basic")
	// ErrAuthHeaderHasInvalidLen = auth header has invalid length
	ErrAuthHeaderHasInvalidLen = errors.New("auth header has invalid length")
	// ErrAuthHeaderNotBasic = auth header expected to be \"Basic ...\"
	ErrAuthHeaderNotBasic = errors.New("auth header expected to be \"Basic ...\"")
	// ErrAuthHeaderInvalidFormat = auth header has invalid format, expect \"Basic keyID:sha512(Key)\"
	ErrAuthHeaderInvalidFormat = errors.New("auth header has invalid format, expect \"Basic keyID:sha512(Key)\"")
	// ErrAuthHeaderInvalid = auth header is invalid
	ErrAuthHeaderInvalid = errors.New("auth header is invalid")
)

Functions

func GenAuthHeaderKey

func GenAuthHeaderKey(id, key string) string

GenAuthHeaderKey generates a authentication header value

Types

type Helper

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

Helper helps authenticate a user

func NewHelper

func NewHelper(dbConn db.Connection) *Helper

NewHelper returns a new instance of AuthHelper

func (*Helper) RemoveKeyCache

func (h *Helper) RemoveKeyCache(id string)

RemoveKeyCache removes a cached key

func (*Helper) Valid

func (h *Helper) Valid(authorizationHeader string) (*models.APIKey, error)

Valid validates an authorizationHeader

Jump to

Keyboard shortcuts

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