hauth

package module
v0.0.0-...-39c36f5 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2020 License: MIT Imports: 9 Imported by: 0

README

hauth

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidAuthorization = &HAuthError{http.StatusUnauthorized, "invalid header[Authorization]"}
	ErrInvalidDate          = &HAuthError{http.StatusUnauthorized, "invalid header[Date], requires RFC1123 format"}
	ErrInvalidContentMD5    = &HAuthError{http.StatusUnauthorized, "invalid header[Content-MD5]"}
	ErrInvalidContentType   = &HAuthError{http.StatusUnauthorized, "invalid header[Content-Type]"}
	ErrInvalidAccessKey     = &HAuthError{http.StatusUnauthorized, "invalid access key"}
	ErrInvalidParameter     = &HAuthError{http.StatusUnauthorized, "invalid parameter in header string"}
	ErrInvalidSignature     = &HAuthError{http.StatusUnauthorized, "invalid signature"}
	ErrInvalidIP            = &HAuthError{http.StatusUnauthorized, "invalid IP"}
	ErrInvalidAPIVersion    = &HAuthError{http.StatusUnauthorized, "invalid APIVersion"}
	ErrInvalidBody          = &HAuthError{http.StatusUnauthorized, "invalid request body"}
	ErrTimestampOutOfRange  = &HAuthError{http.StatusUnauthorized, "timestamp out of range"}
	ErrSignatureExpired     = &HAuthError{http.StatusUnauthorized, "signature expired"}
	ErrSecretKeyRequired    = &HAuthError{http.StatusUnauthorized, "HAuth Secret Key Locator Required"}
	ErrMissingAuthorization = &HAuthError{http.StatusUnauthorized, "missing header[Authorization]"}
	ErrMissingDate          = &HAuthError{http.StatusUnauthorized, "missing header[Date]"}
	ErrMissingAPIVersion    = &HAuthError{http.StatusUnauthorized, "missing parameter[APIVersion] in header[Authorization] string"}
	ErrMissingAPIKey        = &HAuthError{http.StatusUnauthorized, "missing parameter[APIKey] in header[Authorization] string"}
	ErrMissingSignature     = &HAuthError{http.StatusUnauthorized, "missing parameter[Signature] in header[Authorization] string"}
	ErrAccessDenied         = &HAuthError{http.StatusForbidden, "access denied"}
)

Functions

This section is empty.

Types

type AppSecretKeyQuerier

type AppSecretKeyQuerier func(accessKey string) string

type AppValidator

type AppValidator func(accessKey string) bool

type HAuth

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

func NewHAuth

func NewHAuth(getAppSecretKey AppSecretKeyQuerier, options *Options) *HAuth

func (*HAuth) Auth

func (hauth *HAuth) Auth(req *http.Request) *HAuthError

func (*HAuth) GetAccessKey

func (hauth *HAuth) GetAccessKey(req *http.Request) (string, error)

type HAuthError

type HAuthError struct {
	Status  int
	Message string
}

func (HAuthError) Error

func (err HAuthError) Error() string

type LogHandler

type LogHandler func(level string, content string)

type Options

type Options struct {
	WriteLog              LogHandler
	APIVerions            []string
	IPWhiteList           []string
	SignatureExpiresIn    int
	MaxNegativeTimeOffset int
}

Jump to

Keyboard shortcuts

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