mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2026-03-13 02:02:04 +00:00
fix: make a x forwarded uri an non required header
This commit is contained in:
@@ -90,10 +90,13 @@ func (controller *ProxyController) proxyHandler(c *gin.Context) {
|
||||
tlog.App.Debug().Msg("Request identified as (most likely) coming from a non-browser client")
|
||||
}
|
||||
|
||||
uri, ok := controller.requireHeader(c, "x-forwarded-uri")
|
||||
uri, ok := controller.getHeader(c, "x-forwarded-uri")
|
||||
|
||||
if !ok {
|
||||
return
|
||||
originalUri, ok := controller.getHeader(c, "x-original-uri")
|
||||
if ok {
|
||||
uri = originalUri
|
||||
}
|
||||
}
|
||||
|
||||
host, ok := controller.requireHeader(c, "x-forwarded-host")
|
||||
@@ -334,8 +337,8 @@ func (controller *ProxyController) handleError(c *gin.Context, req Proxy, isBrow
|
||||
}
|
||||
|
||||
func (controller *ProxyController) requireHeader(c *gin.Context, header string) (string, bool) {
|
||||
val := c.Request.Header.Get(header)
|
||||
if strings.TrimSpace(val) == "" {
|
||||
val, ok := controller.getHeader(c, header)
|
||||
if !ok {
|
||||
tlog.App.Error().Str("header", header).Msg("Header not found")
|
||||
c.JSON(400, gin.H{
|
||||
"status": 400,
|
||||
@@ -345,3 +348,8 @@ func (controller *ProxyController) requireHeader(c *gin.Context, header string)
|
||||
}
|
||||
return val, true
|
||||
}
|
||||
|
||||
func (controller *ProxyController) getHeader(c *gin.Context, header string) (string, bool) {
|
||||
val := c.Request.Header.Get(header)
|
||||
return val, strings.TrimSpace(val) != ""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user