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 {
|
if v := config.Get("security.csrf.enable"); v != nil {
|
||||||
enable = v.(bool)
|
enable = v.(bool)
|
||||||
}
|
}
|
||||||
|
if !enable {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// csrf 校验类型
|
// csrf 校验类型
|
||||||
okType := false
|
okType := false
|
||||||
@@ -59,16 +62,15 @@ func referer(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if enable && okType {
|
// 遍历检查
|
||||||
ok := false
|
ok := false
|
||||||
for _, domain := range refererWhiteList {
|
for _, domain := range refererWhiteList {
|
||||||
if domain == host {
|
if domain == host {
|
||||||
ok = true
|
ok = true
|
||||||
}
|
|
||||||
}
|
|
||||||
if !ok {
|
|
||||||
c.AbortWithStatusJSON(200, result.ErrMsg("无效 Referer "+host))
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if !ok {
|
||||||
|
c.AbortWithStatusJSON(200, result.ErrMsg("无效 Referer "+host))
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user