Skip to content

Commit

Permalink
Allow parsing remote address headers over unix sockets
Browse files Browse the repository at this point in the history
When listening to a unix socket there is no RemoteAddr for http.Request.
Instead of setting nil, Go sets it to '@'. Marking the IP as trusted if
RemoteAddr allows rest of the settings for parsing remote address in
headers to be applied.

Signed-off-by: Josef Johansson <[email protected]>
  • Loading branch information
isodude committed Oct 23, 2024
1 parent e00c7a7 commit bc8e716
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion oauthproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,9 @@ func (p *OAuthProxy) isAPIPath(req *http.Request) bool {

// isTrustedIP is used to check if a request comes from a trusted client IP address.
func (p *OAuthProxy) isTrustedIP(req *http.Request) bool {
if p.trustedIPs == nil {
// RemoteAddr @ means unix socket
// https://github.com/golang/go/blob/0fa53e41f122b1661d0678a6d36d71b7b5ad031d/src/syscall/syscall_linux.go#L506-L511
if p.trustedIPs == nil && req.RemoteAddr != "@" {
return false
}

Expand Down

0 comments on commit bc8e716

Please sign in to comment.