Documentation ¶
Index ¶
- Constants
- func Abs(v int64) int64
- func DefaultNoiseRand() string
- func HashMac(f func() hash.Hash, secret string, rawArr ...string) string
- func HashMacMD5(secret string, rawArr ...string) string
- func HashMacSha1(secret string, rawArr ...string) string
- func NewOption() *option
- func NewSignInHeadRequest(s Signature, rawQuery url.Values) func(context.Context, string, string, io.Reader) (*http.Request, error)
- func NewSignInURLRequest(s Signature, rawQuery url.Values) func(context.Context, string, string, io.Reader) (*http.Request, error)
- func NewUnSignRequest(_ Signature, rawQuery url.Values) func(context.Context, string, string, io.Reader) (*http.Request, error)
- func RandString(n int, allowedChars ...[]rune) string
- func VerifySign(req *http.Request, opts ...OptionFunc) error
- type DefaultSignature
- type GenerateFunc
- type GenerateParam
- type OptionFunc
- func WithAppID(v string) OptionFunc
- func WithExpire(v time.Duration) OptionFunc
- func WithHmacFunc(f func(secret string, rawArr ...string) string) OptionFunc
- func WithNoiseFunc(f func() string) OptionFunc
- func WithSecret(v string) OptionFunc
- func WithToken(iswith bool) OptionFunc
- func WithUnSignedKey(v ...string) OptionFunc
- type RequestWithContext
- type SignSetMode
- type Signature
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func DefaultNoiseRand ¶
func DefaultNoiseRand() string
func HashMacMD5 ¶ added in v1.2.0
HashMacMD5 hmac md5
func NewSignInHeadRequest ¶ added in v1.2.0
func NewSignInURLRequest ¶ added in v1.2.0
func NewUnSignRequest ¶ added in v1.2.0
func RandString ¶
func VerifySign ¶
func VerifySign(req *http.Request, opts ...OptionFunc) error
Types ¶
type DefaultSignature ¶
func (*DefaultSignature) GetAppID ¶ added in v1.1.2
func (s *DefaultSignature) GetAppID() string
func (*DefaultSignature) GetNoise ¶
func (s *DefaultSignature) GetNoise() string
func (*DefaultSignature) GetSign ¶
func (s *DefaultSignature) GetSign() string
func (*DefaultSignature) GetTimestamp ¶
func (s *DefaultSignature) GetTimestamp() int64
func (*DefaultSignature) ToMap ¶ added in v1.2.0
func (s *DefaultSignature) ToMap() url.Values
type GenerateFunc ¶
type GenerateFunc func(GenerateParam, ...OptionFunc) (Signature, error)
type GenerateParam ¶ added in v1.2.0
type OptionFunc ¶
type OptionFunc func(*option)
func WithAppID ¶ added in v1.2.0
func WithAppID(v string) OptionFunc
WithAppID set app_id, when generate
func WithExpire ¶
func WithExpire(v time.Duration) OptionFunc
WithExpire set timestamp expire, when verify
func WithHmacFunc ¶
func WithHmacFunc(f func(secret string, rawArr ...string) string) OptionFunc
WithHmacFunc set hmac func, when generate & verify. default is hmac sha1
func WithNoiseFunc ¶
func WithNoiseFunc(f func() string) OptionFunc
WithNoiseFunc set noise generate func, when generate
func WithSecret ¶
func WithSecret(v string) OptionFunc
WithSecret set secret, when generate or verify
func WithToken ¶ added in v1.3.0
func WithToken(iswith bool) OptionFunc
WithToken sign hmac with token
func WithUnSignedKey ¶ added in v1.1.1
func WithUnSignedKey(v ...string) OptionFunc
WithUnSignedKey set unsigned field, when generate & verify
type RequestWithContext ¶ added in v1.2.0
type SignSetMode ¶ added in v1.2.0
type SignSetMode uint8
const ( SignSetNil SignSetMode = iota SignSetInHead SignSetlInURL )
Click to show internal directories.
Click to hide internal directories.