diff options
| author | Christine Dodrill <xe@tailscale.com> | 2021-02-17 13:21:43 -0500 |
|---|---|---|
| committer | Christine Dodrill <xe@tailscale.com> | 2021-02-17 14:23:15 -0500 |
| commit | f08d616c3e3d3957375f083abacd73a86e4dcf87 (patch) | |
| tree | 8f26f435fd54e960e633a5dd48d6c961e9418806 /net/tshttpproxy/tshttpproxy.go | |
| parent | 7038c09bc91c7f65ff33afb777187ef9acca214c (diff) | |
| download | tailscale-Xe/derphttp-panic-fix.tar.xz tailscale-Xe/derphttp-panic-fix.zip | |
net/tshttpproxy: support basic auth when availableXe/derphttp-panic-fix
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>
Diffstat (limited to 'net/tshttpproxy/tshttpproxy.go')
| -rw-r--r-- | net/tshttpproxy/tshttpproxy.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/net/tshttpproxy/tshttpproxy.go b/net/tshttpproxy/tshttpproxy.go index 56d4d57de..98f67a31a 100644 --- a/net/tshttpproxy/tshttpproxy.go +++ b/net/tshttpproxy/tshttpproxy.go @@ -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 } |
