mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2025-12-23 16:42:28 +00:00
fix(proxy): reorder method validation for proxy authentication
This commit is contained in:
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user