Skip to content

Commit 438d413

Browse files
authored
fix: compare authentication scheme case-insensitively (#2386)
1 parent 140d892 commit 438d413

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

listener/http/utils.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ func removeExtraHTTPHostPort(req *http.Request) {
6363
// parseBasicProxyAuthorization parse header Proxy-Authorization and return base64-encoded credential
6464
func parseBasicProxyAuthorization(request *http.Request) string {
6565
value := request.Header.Get("Proxy-Authorization")
66-
if !strings.HasPrefix(value, "Basic ") {
66+
const prefix = "Basic "
67+
// According to RFC7617, the scheme should be case-insensitive.
68+
// In practice, some implementations do use different case styles, causing authentication to fail
69+
// eg: https://github.com/algesten/ureq/blob/381fd42cfcb80a5eb709d64860aa0ae726f17b8e/src/unversioned/transport/connect.rs#L118
70+
if len(value) < len(prefix) || !strings.EqualFold(value[:len(prefix)], prefix) {
6771
return ""
6872
}
6973

0 commit comments

Comments
 (0)