mirror of
https://github.com/grafana/grafana.git
synced 2026-08-13 06:34:55 -05:00
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:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user