添加超级token权限
This commit is contained in:
parent
3135efa1b0
commit
785779d0c5
16
main.go
16
main.go
|
|
@ -123,6 +123,22 @@ func JWTAuthMiddleware() gin.HandlerFunc {
|
|||
return
|
||||
}
|
||||
}
|
||||
//查看token是否在超级token中
|
||||
if worker.IsContainSet("super_permission_tokens", tokenString) {
|
||||
s_id := c.Request.Header.Get("super_id")
|
||||
if s_id == "" {
|
||||
c.AbortWithStatus(200)
|
||||
c.JSON(200, gin.H{
|
||||
"message": "NOT_LOGIN",
|
||||
"error": "super_id is empty",
|
||||
"code": proto.TokenIsNull,
|
||||
})
|
||||
return
|
||||
}
|
||||
c.Set("id", s_id)
|
||||
c.Next()
|
||||
return
|
||||
}
|
||||
|
||||
// 使用加密secret 解析 JWT 令牌
|
||||
token, err := jwt.Parse(tokenString, func(token *jwt.Token) (interface{}, error) {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import (
|
|||
var Config ConfigStruct
|
||||
var SigningKey = []byte{}
|
||||
var Url_map = map[string]bool{"/login": true, "/register": true, "/uuid": true, "/gqr": true, "/cid/callback": true, "/tool/monitor": true} // 不需要token验证的url
|
||||
var per_meru_map = map[string]bool{"/video/": true, "/device/": true, "/cid/": true}
|
||||
|
||||
const (
|
||||
MYSQL_USER = "video_t2"
|
||||
|
|
|
|||
Loading…
Reference in New Issue