Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/mod/auth/sso/forward/util.go

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to see a regression test for this behavior

Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,22 @@ func stringInSliceFold(needle string, haystack []string) bool {
}

func rSetIPHeader(r, req *http.Request, headers ...string) {
if r.RemoteAddr == "" || len(headers) == 0 {
if len(headers) == 0 {
return
}

before, _, _ := strings.Cut(r.RemoteAddr, ":")
host, _, err := net.SplitHostPort(r.RemoteAddr)
if err != nil {
host = r.RemoteAddr
}

ip := net.ParseIP(before)
ip := net.ParseIP(host)
if ip == nil {
// We should never leave a client supplied value in these headers when the address cannot be determined.
for _, header := range headers {
req.Header.Del(header)
}

return
}

Expand Down