Documentation
¶
Index ¶
- Constants
- type Claims
- type Config
- type JWT
- func (j *JWT) DecodeHS256Token(token string) (*Claims, error)
- func (j *JWT) DecodeRS256Token(token string) (*Claims, error)
- func (j *JWT) DecodeTokenUnverified(token string) (*Claims, error)
- func (j *JWT) GenHS256Token(payload string, kvs map[string]interface{}) (string, error)
- func (j *JWT) GenRS256Token(payload string, kvs map[string]interface{}) (string, error)
Constants ¶
View Source
const ( KeyIat = "iat" KeyExp = "exp" KeyPayload = "payload" KeyKVs = "kvs" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { MaxAge time.Duration `mapstructure:"max_age"` // 会话有效时长,如:20s // HS256相关 HS256SecretIsBase64 bool `mapstructure:"hs256_secret_is_base64"` // 密钥是否为base64编码 HS256Secret string `mapstructure:"hs256_secret"` // 密钥 // RS256相关 PrivateKeyPath string `mapstructure:"private_key_path"` // 私钥路径 PublicKeyPath string `mapstructure:"public_key_path"` // 公钥路径 }
type JWT ¶
type JWT struct { Cfg Config HS256Secret []byte PublicKey *rsa.PublicKey PrivateKey *rsa.PrivateKey }
func (*JWT) DecodeTokenUnverified ¶
func (*JWT) GenHS256Token ¶
Click to show internal directories.
Click to hide internal directories.