Validate X-Forwarded-Prefix value for dashboard redirect
Co-authored-by: Kevin Pollet <pollet.kevin@gmail.com>
This commit is contained in:
parent
1778ff3bac
commit
4de6d6b902
2 changed files with 55 additions and 1 deletions
|
|
@ -79,7 +79,13 @@ func Append(router *mux.Router, basePath string, customAssets fs.FS) error {
|
|||
router.Methods(http.MethodGet).
|
||||
Path(basePath).
|
||||
HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {
|
||||
prefix := strings.TrimSuffix(req.Header.Get("X-Forwarded-Prefix"), "/")
|
||||
xfPrefix := req.Header.Get("X-Forwarded-Prefix")
|
||||
if strings.Contains(xfPrefix, "//") {
|
||||
log.Error().Msgf("X-Forwarded-Prefix contains an invalid value: %s, defaulting to empty prefix", xfPrefix)
|
||||
xfPrefix = ""
|
||||
}
|
||||
|
||||
prefix := strings.TrimSuffix(xfPrefix, "/")
|
||||
http.Redirect(resp, req, prefix+dashboardPath, http.StatusFound)
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue