api

package
v0.0.0-...-2083224 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Err

Functions

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 GenPropsByBody

func GenPropsByBody(contentType string, body []byte) (map[string]interface{}, error)

GenPropsByBody 根据类型分解参数

func GetLangContent

func GetLangContent(code, lang, _default string) string

GetLangContent GetLangContent

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 SignedAuth

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

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

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

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

Types

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

Jump to

Keyboard shortcuts

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