Documentation ¶
Index ¶
- Variables
- type JwtAuth
- func (a *JwtAuth) GenTokenWithClaims(payload map[string]interface{}) (string, error)
- func (a *JwtAuth) GenTokenWithPayload(payload Payload) (string, error)
- func (a *JwtAuth) GetPayloadFromToken(token string, payload Payload) error
- func (a *JwtAuth) GetToken(token string) (map[string]interface{}, error)
- func (a *JwtAuth) GetTokenString(c *http_proxy.Context) (string, error)
- type Option
- type Options
- type Payload
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type JwtAuth ¶
type JwtAuth struct {
// contains filtered or unexported fields
}
JwtAuth jwt鉴权模块,包装常用的jwt工具函数
func (*JwtAuth) GenTokenWithClaims ¶
GenTokenWithClaims 使用用户自定义map生成 jwt token param payload 用户自定义data map return jwt 字符串
func (*JwtAuth) GenTokenWithPayload ¶
GenTokenWithPayload 生成jwt token 字符串 param payload 用户自定义data, 能序列化为json return jwt 字符串
func (*JwtAuth) GetPayloadFromToken ¶
GetPayloadFromToken 解析token,并尝试读取payload信息 param token token 字符串 payload 用户自定义payload结构体指针 return 解析成功返回nil, 否则返回错误
func (*JwtAuth) GetTokenString ¶
func (a *JwtAuth) GetTokenString(c *http_proxy.Context) (string, error)
GetTokenString 鉴权函数,提取token 字符串 param c http 请求上下文 return token 完整字符串 return error 解析是否发生错误,失败会返回ErrInvalidTokenType
type Options ¶
type Options struct { // Enable 是否启用Auth模块 Enable bool `yaml:"enable"` //AuthHeader http头部中用于鉴权的字段名 AuthHeader string `yaml:"auth_header"` //TokenType token 类型 如 Bearer TokenType string `yaml:"token_type"` //TokenExpires token 过期时间 TokenExpiresTime int `yaml:"token_expires_time"` //TokenRefreshTime token 刷新续期时间 TokenRefreshTime int `yaml:"token_refresh_time"` //Encryption 编码方式,如HS256 Encryption string `yaml:"encryption"` //Secret 密钥 Secret string `yaml:"secret"` }
Click to show internal directories.
Click to hide internal directories.