Reverse proxy authentication support (#1152)
* feat(auth): reverse proxy authentication support - #176 * address PR remarks * Fix redaction of UI appConfig Co-authored-by: Deluan <deluan@navidrome.org>
This commit is contained in:
@@ -24,6 +24,11 @@ var redacted = &Hook{
|
||||
"(Secret:\")[\\w]*",
|
||||
"(Spotify.*ID:\")[\\w]*",
|
||||
|
||||
// UI appConfig
|
||||
"(subsonicToken:)[\\w]+(\\s)",
|
||||
"(subsonicSalt:)[\\w]+(\\s)",
|
||||
"(token:)[^\\s]+",
|
||||
|
||||
// Subsonic query params
|
||||
"([^\\w]t=)[\\w]+",
|
||||
"([^\\w]s=)[^&]+",
|
||||
|
||||
@@ -4,6 +4,7 @@ package log
|
||||
// Copyright (c) 2018 William Huang
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"regexp"
|
||||
|
||||
@@ -47,6 +48,10 @@ func (h *Hook) Fire(e *logrus.Entry) error {
|
||||
case reflect.String:
|
||||
e.Data[k] = re.ReplaceAllString(v.(string), "$1[REDACTED]$2")
|
||||
continue
|
||||
case reflect.Map:
|
||||
s := fmt.Sprintf("%+v", v)
|
||||
e.Data[k] = re.ReplaceAllString(s, "$1[REDACTED]$2")
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -121,6 +121,13 @@ func TestEntryDataValues(t *testing.T) {
|
||||
expected: logrus.Fields{"Description": "His name is [REDACTED]"},
|
||||
description: "William should have been redacted, but was not.",
|
||||
},
|
||||
{
|
||||
name: "map value",
|
||||
redactionList: []string{"William"},
|
||||
logFields: logrus.Fields{"Description": map[string]string{"name": "His name is William"}},
|
||||
expected: logrus.Fields{"Description": "map[name:His name is [REDACTED]]"},
|
||||
description: "William should have been redacted, but was not.",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
||||
Reference in New Issue
Block a user