Auth Proxy: encoding of non-ASCII headers (#44797)

* Decode auth proxy headers using URL encoding

* Header encoding configuration via settings file

* Rename configuration setting to headers_encoded

* Quoted-printable encoding

* Tests for AuthProxy

* Fix encoding name

* Remove authproxy init
This commit is contained in:
Sergey Kostrukov
2022-03-04 04:58:27 -05:00
committed by GitHub
parent 9b5a42845d
commit 1dca39fb91
8 changed files with 140 additions and 14 deletions
+11
View File
@@ -6,6 +6,8 @@ import (
"encoding/base64"
"encoding/hex"
"errors"
"io"
"mime/quotedprintable"
"strings"
"golang.org/x/crypto/pbkdf2"
@@ -71,3 +73,12 @@ func RandomHex(n int) (string, error) {
}
return hex.EncodeToString(bytes), nil
}
// decodeQuotedPrintable decodes quoted-printable UTF-8 string
func DecodeQuotedPrintable(encodedValue string) string {
decodedBytes, err := io.ReadAll(quotedprintable.NewReader(strings.NewReader(encodedValue)))
if err != nil {
return encodedValue
}
return string(decodedBytes)
}