woj-server/internal/global/jwt.go

22 lines
409 B
Go
Raw Normal View History

2022-09-17 11:22:55 +08:00
package global
import (
"github.com/WHUPRJ/woj-server/internal/e"
"github.com/gin-gonic/gin"
"github.com/golang-jwt/jwt/v4"
)
type Claim struct {
UID uint `json:"id"`
Version int64 `json:"version"`
2022-09-17 11:22:55 +08:00
jwt.RegisteredClaims
}
type JwtService interface {
ParseToken(tokenText string) (*Claim, e.Err)
SignClaim(claim *Claim) (string, e.Err)
Validate(claim *Claim) bool
2022-09-17 11:22:55 +08:00
Handler() gin.HandlerFunc
}