Documentation ¶
Index ¶
- Constants
- Variables
- func CreateToken(ci CustomerInfo) (ts string, err error)
- func GetIRoutes(relativePath string) gin.IRoutes
- func GetJwtHandler() gin.HandlerFunc
- func RemoveToken(uid int)
- func SetCustomerInfo(c *gin.Context, claims BaseClaims)
- type BaseClaims
- type ClaimsParserFunc
- type CustomerInfo
- type JWTConfig
- type MultiPoint
Constants ¶
View Source
const (
TOKEN_CUSTOMER_INFO = "TOKEN_CUSTOMER_INFO" // 用户信息(claims.CustomerInfo)
)
Variables ¶
Functions ¶
func CreateToken ¶
func CreateToken(ci CustomerInfo) (ts string, err error)
需要创建token,这里已经抽象化,可以不用更改,要改,就改CustomerInfo、GetCustomerInfo、SetCustomerInfo
func GetIRoutes ¶
func GetJwtHandler ¶
func GetJwtHandler() gin.HandlerFunc
func RemoveToken ¶ added in v0.1.3
func RemoveToken(uid int)
Types ¶
type ClaimsParserFunc ¶ added in v0.1.2
type ClaimsParserFunc func(jwt.Claims) *BaseClaims
var CustomClaimsParser ClaimsParserFunc
type CustomerInfo ¶
type CustomerInfo struct {
Uid int `json:"uid,omitempty"` // 通用用户唯一标记,尽量不动这个,否则,其他的代码可能需要更改
}
用户信息,可以放置一些业务字段
func GetCustomerInfoFromTokenString ¶ added in v0.1.3
func GetCustomerInfoFromTokenString(ts string) (ci CustomerInfo, err error)
type JWTConfig ¶
type JWTConfig struct { Enable bool `mapstructure:"enable" json:"enable" yaml:"enable"` // 是否开启 TokenHeader string `mapstructure:"token-header" json:"tokenHeader" yaml:"token-header"` // 请求中的header名 NewTokenHeader string `mapstructure:"new-token-header" json:"newTokenHeader" yaml:"new-token-header"` // 响应新token的header名 SignKey string `mapstructure:"sign-key" json:"signKey" yaml:"sign-key"` // jwt签名 ExpireTime int64 `mapstructure:"expire-time" json:"expireTime" yaml:"expire-time"` // 过期时间 RefreshIntervalMin int64 `mapstructure:"refresh-interval-min" json:"refreshIntervalMin" yaml:"refresh-interval-min"` // 刷新token的最小间隔时间 Issuer string `mapstructure:"issuer" json:"issuer" yaml:"issuer"` // 签发者 HijackCheckEnable bool `mapstructure:"hijack-check-enable" json:"hijackCheckEnable" yaml:"hijack-check-enable"` // 是否开启劫持检测 MultiPoint MultiPoint `mapstructure:"multi-point" json:"multiPoint" yaml:"multi-point"` // 多点登录拦截 }
type MultiPoint ¶
type MultiPoint struct { Enable bool `mapstructure:"enable" json:"enable" yaml:"enable"` // 是否开启 MultiTimeDiffTolerate int64 `mapstructure:"multi-time-diff-tolerate" json:"multiTimeDiffTolerate" yaml:"multi-time-diff-tolerate"` // 服务器时间差容忍值 HashName string `mapstructure:"hash-name" json:"hashName" yaml:"hash-name"` // 缓存hash }
集群中间件配置
Click to show internal directories.
Click to hide internal directories.