fix(security): 修复 P0 安全漏洞 (Session越权+CORS白名单+用户名枚举)

This commit is contained in:
2026-05-21 16:12:54 +08:00
parent 702d4ee1fe
commit 380cc24913
7 changed files with 161 additions and 15 deletions
@@ -55,3 +55,12 @@ func GetUserID(c *gin.Context) string {
}
return userID.(string)
}
// GetIsAdmin 从上下文获取是否为管理员
func GetIsAdmin(c *gin.Context) bool {
isAdmin, _ := c.Get(IsAdminKey)
if isAdmin == nil {
return false
}
return isAdmin.(bool)
}