makeProxyAuthHeader creates a Proxy-Authorization header value from URL user info. Valid formats: - username:password -> Basic auth with both credentials - username: or username -> Basic auth with username only (empty password) - :password -> Basic auth with empty username (token-based proxies) Re
(userInfo *url.Userinfo)
| 703 | // |
| 704 | // Returns empty string when both username and password are empty. |
| 705 | func makeProxyAuthHeader(userInfo *url.Userinfo) string { |
| 706 | if userInfo == nil { |
| 707 | return "" |
| 708 | } |
| 709 | |
| 710 | username := userInfo.Username() |
| 711 | password, _ := userInfo.Password() |
| 712 | |
| 713 | // Reject only when both username and password are empty (no credentials). |
| 714 | if username == "" && password == "" { |
| 715 | return "" |
| 716 | } |
| 717 | |
| 718 | return "Basic " + base64.StdEncoding.EncodeToString([]byte(userInfo.String())) |
| 719 | } |
| 720 | |
| 721 | // extractCoderTokenFromProxyAuth extracts the Coder token from the |
| 722 | // Proxy-Authorization header. The token is expected to be in the password |