feat(god):基本完成天神模式所使用的数据服务。

This commit is contained in:
徐涛
2022-09-06 10:45:20 +08:00
parent c4ab500235
commit 901cbf23bb
3 changed files with 603 additions and 0 deletions

View File

@@ -76,3 +76,16 @@ func OPSAuthorize(c *gin.Context) {
}
c.Next()
}
// 用于对用户会话进行是否核心运维用户的判断
// ! 通过该中间件以后,是可以保证上下文中一定具有用户会话信息的。
func SingularityAuthorize(c *gin.Context) {
session, exists := c.Get("session")
if !exists {
c.AbortWithStatus(http.StatusForbidden)
}
if sess, ok := session.(*model.Session); !ok || sess.Type != model.USER_TYPE_OPS || sess.Uid != "000" {
c.AbortWithStatus(http.StatusForbidden)
}
c.Next()
}