1
0

feat: 合并代码

This commit is contained in:
TsMask
2023-10-17 19:43:49 +08:00
parent 5f5a2e2e9e
commit e2d17640ef
10 changed files with 100 additions and 41 deletions

View File

@@ -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,16 +62,15 @@ func referer(c *gin.Context) {
}
}
if enable && okType {
ok := false
for _, domain := range refererWhiteList {
if domain == host {
ok = true
}
}
if !ok {
c.AbortWithStatusJSON(200, result.ErrMsg("无效 Referer "+host))
return
// 遍历检查
ok := false
for _, domain := range refererWhiteList {
if domain == host {
ok = true
}
}
if !ok {
c.AbortWithStatusJSON(200, result.ErrMsg("无效 Referer "+host))
return
}
}