Back to godoc.org

Package api

v0.0.0-...-baf7d71
Latest Go to latest

The latest major version is .

Published: May 30, 2020 | License: Apache-2.0 | Module: github.com/Eric-GreenComb/contrib

Index

Variables

var (
	ErrTokenExpired     error = errors.New("凭证过期")
	ErrTokenNotValidYet error = errors.New("凭证还未校验")
	ErrTokenMalformed   error = errors.New("凭证格式错误")
	ErrTokenInvalid     error = errors.New("凭证无效")
	ErrTokenIssuer      error = errors.New("凭证发放者不符")
)

Err

func AbortWithError

func AbortWithError(c *gin.Context, code int, message string)

AbortWithError AbortWithError

func BindJSON

func BindJSON(data io.Reader, dest interface{}) error

BindJSON BindJSON

func CalcSign

func CalcSign(mReq map[string]interface{}, salt, sign string) string

CalcSign api 签名规则 md5key为签名参数的key,salt加在前部

func CreateJWTString

func CreateJWTString(id, sub, issuer, key string, expire int) string

CreateJWTString CreateJWTString

func FilterXSS

func FilterXSS(s string) string

FilterXSS FilterXSS

func FormAuth

func FormAuth(salt, appid, sign string, salts map[string]interface{}) gin.HandlerFunc

FormAuth FormAuth salt:默认salt; appid:appid的key; sign: 签名的key; salts: salt组

如果请求参数中有appid的key,则匹配salts中配置的该app的salt,否则取默认的salt

func GetLangContent

func GetLangContent(code, lang, _default string) string

GetLangContent GetLangContent

func JSONAuth

func JSONAuth(salt, appid, sign string, salts map[string]interface{}) gin.HandlerFunc

JSONAuth JSONAuth FormAuth FormAuth salt:默认salt; appid:appid的key; sign: 签名的key; salts: salt组

如果请求参数中有appid的key,则匹配salts中配置的该app的salt,否则取默认的salt

func JWTAbortWithError

func JWTAbortWithError(c *gin.Context, code int, message, realm string)

JWTAbortWithError JWTAbortWithError

func JWTAuth

func JWTAuth(issuer, key string) gin.HandlerFunc

JWTAuth JWTAuth

func StripBearerPrefixFromTokenString

func StripBearerPrefixFromTokenString(tok string) (string, error)

StripBearerPrefixFromTokenString Strips 'Bearer ' prefix from bearer token string

func WechatSign

func WechatSign(mReq map[string]interface{}, salt, sign string) string

WechatSign api md5key为签名参数的key,salt加在后部,如果value没有,不参与签名

func WhitelistAuth

func WhitelistAuth(whitelist map[string]interface{}) gin.HandlerFunc

WhitelistAuth WhitelistAuth

type JWT

type JWT struct {
	SigningKey []byte
}

JWT JWT

func (*JWT) Create

func (j *JWT) Create(claims jwt.StandardClaims) (string, error)

Create 创建token

func (*JWT) Parse

func (j *JWT) Parse(tokenString string) (*jwt.StandardClaims, error)

Parse 解析token

func (*JWT) Refresh

func (j *JWT) Refresh(tokenString, issuer string, expire int) (string, error)

Refresh 更新token

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier