mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-04 21:30:24 +08:00
feat: add Internet-Only captcha rule (#3919)
This commit is contained in:
@ -185,17 +185,3 @@ func removePort(s string) string {
|
||||
}
|
||||
return ipStr
|
||||
}
|
||||
|
||||
func isHostIntranet(s string) bool {
|
||||
ipStr, _, err := net.SplitHostPort(s)
|
||||
if err != nil {
|
||||
ipStr = s
|
||||
}
|
||||
|
||||
ip := net.ParseIP(ipStr)
|
||||
if ip == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return ip.IsPrivate() || ip.IsLoopback() || ip.IsLinkLocalUnicast() || ip.IsLinkLocalMulticast()
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ func CorsFilter(ctx *context.Context) {
|
||||
setCorsHeaders(ctx, origin)
|
||||
} else if originHostname == host {
|
||||
setCorsHeaders(ctx, origin)
|
||||
} else if isHostIntranet(host) {
|
||||
} else if util.IsHostIntranet(host) {
|
||||
setCorsHeaders(ctx, origin)
|
||||
} else {
|
||||
ok, err := object.IsOriginAllowed(origin)
|
||||
|
Reference in New Issue
Block a user