fix(proxy): reorder method validation for proxy authentication

This commit is contained in:
Pushpinder Singh
2025-12-19 11:18:23 -05:00
parent ca2ec6cc01
commit 5a046bcfb2

View File

@@ -55,15 +55,6 @@ func (controller *ProxyController) proxyHandler(c *gin.Context) {
return return
} }
if req.Proxy != "envoy" && c.Request.Method != http.MethodGet {
log.Warn().Str("method", c.Request.Method).Msg("Invalid method for proxy authentication")
c.JSON(405, gin.H{
"status": 405,
"message": "Method Not Allowed",
})
return
}
if req.Proxy != "nginx" && req.Proxy != "traefik" && req.Proxy != "caddy" && req.Proxy != "envoy" { if req.Proxy != "nginx" && req.Proxy != "traefik" && req.Proxy != "caddy" && req.Proxy != "envoy" {
log.Warn().Str("proxy", req.Proxy).Msg("Invalid proxy") log.Warn().Str("proxy", req.Proxy).Msg("Invalid proxy")
c.JSON(400, gin.H{ c.JSON(400, gin.H{
@@ -73,6 +64,15 @@ func (controller *ProxyController) proxyHandler(c *gin.Context) {
return return
} }
if req.Proxy != "envoy" && c.Request.Method != http.MethodGet {
log.Warn().Str("method", c.Request.Method).Msg("Invalid method for proxy")
c.JSON(405, gin.H{
"status": 405,
"message": "Method Not Allowed",
})
return
}
isBrowser := strings.Contains(c.Request.Header.Get("Accept"), "text/html") isBrowser := strings.Contains(c.Request.Header.Get("Accept"), "text/html")
if isBrowser { if isBrowser {