fix: refere开启同时类型满足才支持
This commit is contained in:
@@ -15,6 +15,9 @@ func referer(c *gin.Context) {
|
||||
if v := config.Get("security.csrf.enable"); v != nil {
|
||||
enable = v.(bool)
|
||||
}
|
||||
if !enable {
|
||||
return
|
||||
}
|
||||
|
||||
// csrf 校验类型
|
||||
okType := false
|
||||
@@ -59,7 +62,7 @@ func referer(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
if enable && okType {
|
||||
// 遍历检查
|
||||
ok := false
|
||||
for _, domain := range refererWhiteList {
|
||||
if domain == host {
|
||||
@@ -70,5 +73,4 @@ func referer(c *gin.Context) {
|
||||
c.AbortWithStatusJSON(200, result.ErrMsg("无效 Referer "+host))
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user