apisign

package module
v0.0.0-...-fbd9b9b Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2018 License: Apache-2.0 Imports: 13 Imported by: 1

README

apisign

An APIBox middleware to implement API signature verification.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorDefines = map[api.ErrorType]*api.ErrorDefine{
	// contains filtered or unexported fields
}

Functions

func CheckSign

func CheckSign(values url.Values, key string, sign []byte) bool

CheckSign return true if specified sign is the signature of url values.

func EncodeValues

func EncodeValues(v url.Values) string

EncodeValues encodes the values into "URL encoded" form ("bar=baz&foo=quux") sorted by key and values. Changed from url.Values.Encode()

func MakeSign

func MakeSign(values url.Values, key string) []byte

MakeSign return the signature of url values signed by hmac/md5 with specified sign key.

func MakeSignString

func MakeSignString(values url.Values, key string) string

MakeSignString return the signature of url values as string signed by hmac/md5 with specified sign key.

Types

type Sign

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

func NewSign

func NewSign(app *api.App) *Sign

func (*Sign) Disable

func (s *Sign) Disable()

Disable disable the middle ware.

func (*Sign) Enable

func (s *Sign) Enable()

Enable enable the middle ware.

func (*Sign) GetSignKey

func (s *Sign) GetSignKey() string

GetSignKey return current sign key as string.

func (*Sign) ServeHTTP

func (s *Sign) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)

func (*Sign) SetSignKey

func (s *Sign) SetSignKey(signKey string)

SetSignKey allow you update sign key dynamically.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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