Allow reverse proxy auth for unix socket (#2701)

This commit is contained in:
Kendall Garner 2023-12-12 11:06:27 +00:00 committed by Joe Stump
parent e8861b22a0
commit ed43e620cf
No known key found for this signature in database
GPG Key ID: 29151C3EC48A0EB9

View File

@ -278,7 +278,7 @@ func UsernameFromToken(r *http.Request) string {
}
func UsernameFromReverseProxyHeader(r *http.Request) string {
if conf.Server.ReverseProxyWhitelist == "" {
if conf.Server.ReverseProxyWhitelist == "" && !strings.HasPrefix(conf.Server.Address, "unix:") {
return ""
}
if !validateIPAgainstList(r.RemoteAddr, conf.Server.ReverseProxyWhitelist) {
@ -401,6 +401,12 @@ func handleLoginFromHeaders(ds model.DataStore, r *http.Request) map[string]inte
}
func validateIPAgainstList(ip string, comaSeparatedList string) bool {
// Per https://github.com/golang/go/issues/49825, the remote address
// on a unix socket is '@'
if ip == "@" && strings.HasPrefix(conf.Server.Address, "unix:") {
return true
}
if comaSeparatedList == "" || ip == "" {
return false
}