Skip to content

Commit b98fa34

Browse files
committed
fix: review comments
1 parent 1c7ef96 commit b98fa34

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

internal/controller/proxy_controller.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ const (
2727

2828
var BrowserUserAgentRegex = regexp.MustCompile("Chrome|Gecko|AppleWebKit|Opera|Edge")
2929

30-
var SupportedProxies = []string{"nginx", "traefik", "caddy", "envoy"}
31-
3230
type Proxy struct {
3331
Proxy string `uri:"proxy" binding:"required"`
3432
}
@@ -366,7 +364,17 @@ func (controller *ProxyController) getAuthRequestContext(c *gin.Context) (ProxyC
366364
}
367365

368366
host := url.Host
367+
368+
if strings.TrimSpace(host) == "" {
369+
return ProxyContext{}, errors.New("host not found")
370+
}
371+
369372
proto := url.Scheme
373+
374+
if strings.TrimSpace(proto) == "" {
375+
return ProxyContext{}, errors.New("proto not found")
376+
}
377+
370378
path := url.Path
371379
method := c.Request.Method
372380

@@ -411,14 +419,14 @@ func (controller *ProxyController) getExtAuthzContext(c *gin.Context) (ProxyCont
411419

412420
func (controller *ProxyController) determineAuthModules(proxy string) []AuthModuleType {
413421
switch proxy {
414-
case "traefik":
422+
case "traefik", "caddy":
415423
return []AuthModuleType{ForwardAuth}
416424
case "envoy":
417425
return []AuthModuleType{ExtAuthz, ForwardAuth}
418426
case "nginx":
419427
return []AuthModuleType{AuthRequest, ForwardAuth}
420428
default:
421-
return []AuthModuleType{ForwardAuth}
429+
return []AuthModuleType{}
422430
}
423431
}
424432

@@ -456,10 +464,12 @@ func (controller *ProxyController) getProxyContext(c *gin.Context) (ProxyContext
456464

457465
tlog.App.Debug().Msgf("Proxy: %v", req.Proxy)
458466

459-
tlog.App.Trace().Interface("headers", c.Request.Header).Msg("Request headers")
460-
461467
authModules := controller.determineAuthModules(req.Proxy)
462468

469+
if len(authModules) == 0 {
470+
return ProxyContext{}, fmt.Errorf("no auth modules supported for proxy: %v", req.Proxy)
471+
}
472+
463473
var ctx ProxyContext
464474

465475
for _, module := range authModules {

0 commit comments

Comments
 (0)