git.iko.soy/typeable/oauth2-proxy
on master help sign in
Allow parsing remote address headers over unix sockets

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 <josef@oderland.se>

commitbc8e7162db7dd050c58fb2f2a92c094b7b5a22f9 authorJosef Johansson <josef@oderland.se> dateSun 25 Feb 2024, 12:29 (3 years ago) parente00c7a7
1 file changed+3−1
oauthproxy.go+3−1
oauthproxy.go+3−1
@@ -606,7 +606,9 @@ func (p *OAuthProxy) isAPIPath(req *http.Request) bool {
606606
607607// isTrustedIP is used to check if a request comes from a trusted client IP address.
608608func (p *OAuthProxy) isTrustedIP(req *http.Request) bool {
609− if p.trustedIPs == nil {
609+ // RemoteAddr @ means unix socket
610+ // https://github.com/golang/go/blob/0fa53e41f122b1661d0678a6d36d71b7b5ad031d/src/syscall/syscall_linux.go#L506-L511
611+ if p.trustedIPs == nil && req.RemoteAddr != "@" {
610612 return false
611613 }
612614