mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-11 13:18:53 +00:00
net/tshttpproxy: support basic auth when available (#1354)
This allows proxy URLs such as: http://azurediamond:hunter2@192.168.122.154:38274 to be used in order to dial out to control, logs or derp servers. Signed-off-by: Christine Dodrill <xe@tailscale.com>
This commit is contained in:

committed by
GitHub

parent
d98ef5699d
commit
3e5c3e932c
@@ -74,6 +74,18 @@ func GetAuthHeader(u *url.URL) (string, error) {
|
||||
if sysAuthHeader != nil {
|
||||
return sysAuthHeader(u)
|
||||
}
|
||||
|
||||
if user := u.User.Username(); user != "" {
|
||||
pass, ok := u.User.Password()
|
||||
if !ok {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
req := &http.Request{Header: make(http.Header)}
|
||||
req.SetBasicAuth(user, pass)
|
||||
return req.Header.Get("Authorization"), nil
|
||||
}
|
||||
|
||||
return "", nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user