Init
func init() {
if s := os.Getenv("JWT_SECRET"); s != "" {
jwtutil.SetJwtSecret(s)
}
}
Generate JWT token
token, err := jwtutil.NewToken(map[string]string{
"iss": "account",
"aud": "pangpanglabs",
"username": "jack",
"tenant": "github",
})
Generate JWT token with secret
token, err := jwtutil.NewTokenWithSecret(map[string]string{
"iss": "account",
"aud": "pangpanglabs",
"username": "jack",
"tenant": "github",
}, myJwtSecret)
Extract claim info
claim, err := jwtutil.Extract(token)
Extract claim info with secret
claim, err := jwtutil.Extract(token, secret)
Renew token
newToken, err := jwtutil.Renew(oldToken)