Fix 127.0.0.1 bug in isHostIntranet()

This commit is contained in:
Yang Luo 2023-10-13 23:29:37 +08:00
parent 69b144d80f
commit 43d849086f
2 changed files with 6 additions and 1 deletions

View File

@ -37,6 +37,11 @@ func (c *ApiController) Enforce() {
resourceId := c.Input().Get("resourceId")
enforcerId := c.Input().Get("enforcerId")
if len(c.Ctx.Input.RequestBody) == 0 {
c.ResponseError("The request body should not be empty")
return
}
var request object.CasbinRequest
err := json.Unmarshal(c.Ctx.Input.RequestBody, &request)
if err != nil {

View File

@ -190,5 +190,5 @@ func isHostIntranet(s string) bool {
return false
}
return ip.IsPrivate()
return ip.IsPrivate() || ip.IsLoopback() || ip.IsLinkLocalUnicast() || ip.IsLinkLocalMulticast()
}