Use forwarded headers for SCIM event client IP
The SCIM event handler read the client address from r.RemoteAddr only, so when probod runs behind an HTTP load balancer every event row recorded the load balancer's internal IP. Switch to clientip.Extract, which honors the Forwarded / X-Forwarded-For headers already validated by trustedproxy middleware. Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
@@ -32,6 +32,7 @@ import (
|
||||
"go.probo.inc/probo/pkg/gid"
|
||||
"go.probo.inc/probo/pkg/iam"
|
||||
scimservice "go.probo.inc/probo/pkg/iam/scim"
|
||||
"go.probo.inc/probo/pkg/server/api/clientip"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -337,12 +338,7 @@ func (h *scimResourceHandler) Delete(r *http.Request, id string) error {
|
||||
}
|
||||
|
||||
func getIPAddress(r *http.Request) net.IP {
|
||||
host, _, err := net.SplitHostPort(r.RemoteAddr)
|
||||
if err != nil {
|
||||
host = r.RemoteAddr
|
||||
}
|
||||
|
||||
if ip := net.ParseIP(host); ip != nil {
|
||||
if ip := net.ParseIP(clientip.Extract(r)); ip != nil {
|
||||
return ip
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user