2022-09-17 11:22:55 +08:00
|
|
|
package global
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/WHUPRJ/woj-server/internal/e"
|
2022-09-20 14:34:30 +08:00
|
|
|
"github.com/WHUPRJ/woj-server/internal/repo/model"
|
2022-09-17 11:22:55 +08:00
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"github.com/golang-jwt/jwt/v4"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Claim struct {
|
2022-09-20 14:34:30 +08:00
|
|
|
UID uint `json:"id"`
|
|
|
|
Role model.Role `json:"role"`
|
|
|
|
Version int64 `json:"version"`
|
2022-09-17 11:22:55 +08:00
|
|
|
jwt.RegisteredClaims
|
|
|
|
}
|
|
|
|
|
|
|
|
type JwtService interface {
|
2022-09-20 14:15:21 +08:00
|
|
|
ParseToken(tokenText string) (*Claim, e.Status)
|
|
|
|
SignClaim(claim *Claim) (string, e.Status)
|
2022-09-17 18:10:06 +08:00
|
|
|
Validate(claim *Claim) bool
|
2022-09-17 11:22:55 +08:00
|
|
|
|
|
|
|
Handler() gin.HandlerFunc
|
|
|
|
}
|