mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2026-03-15 11:12:02 +00:00
fix: review comments
This commit is contained in:
@@ -27,8 +27,6 @@ const (
|
|||||||
|
|
||||||
var BrowserUserAgentRegex = regexp.MustCompile("Chrome|Gecko|AppleWebKit|Opera|Edge")
|
var BrowserUserAgentRegex = regexp.MustCompile("Chrome|Gecko|AppleWebKit|Opera|Edge")
|
||||||
|
|
||||||
var SupportedProxies = []string{"nginx", "traefik", "caddy", "envoy"}
|
|
||||||
|
|
||||||
type Proxy struct {
|
type Proxy struct {
|
||||||
Proxy string `uri:"proxy" binding:"required"`
|
Proxy string `uri:"proxy" binding:"required"`
|
||||||
}
|
}
|
||||||
@@ -366,7 +364,17 @@ func (controller *ProxyController) getAuthRequestContext(c *gin.Context) (ProxyC
|
|||||||
}
|
}
|
||||||
|
|
||||||
host := url.Host
|
host := url.Host
|
||||||
|
|
||||||
|
if strings.TrimSpace(host) == "" {
|
||||||
|
return ProxyContext{}, errors.New("host not found")
|
||||||
|
}
|
||||||
|
|
||||||
proto := url.Scheme
|
proto := url.Scheme
|
||||||
|
|
||||||
|
if strings.TrimSpace(proto) == "" {
|
||||||
|
return ProxyContext{}, errors.New("proto not found")
|
||||||
|
}
|
||||||
|
|
||||||
path := url.Path
|
path := url.Path
|
||||||
method := c.Request.Method
|
method := c.Request.Method
|
||||||
|
|
||||||
@@ -411,14 +419,14 @@ func (controller *ProxyController) getExtAuthzContext(c *gin.Context) (ProxyCont
|
|||||||
|
|
||||||
func (controller *ProxyController) determineAuthModules(proxy string) []AuthModuleType {
|
func (controller *ProxyController) determineAuthModules(proxy string) []AuthModuleType {
|
||||||
switch proxy {
|
switch proxy {
|
||||||
case "traefik":
|
case "traefik", "caddy":
|
||||||
return []AuthModuleType{ForwardAuth}
|
return []AuthModuleType{ForwardAuth}
|
||||||
case "envoy":
|
case "envoy":
|
||||||
return []AuthModuleType{ExtAuthz, ForwardAuth}
|
return []AuthModuleType{ExtAuthz, ForwardAuth}
|
||||||
case "nginx":
|
case "nginx":
|
||||||
return []AuthModuleType{AuthRequest, ForwardAuth}
|
return []AuthModuleType{AuthRequest, ForwardAuth}
|
||||||
default:
|
default:
|
||||||
return []AuthModuleType{ForwardAuth}
|
return []AuthModuleType{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -456,10 +464,12 @@ func (controller *ProxyController) getProxyContext(c *gin.Context) (ProxyContext
|
|||||||
|
|
||||||
tlog.App.Debug().Msgf("Proxy: %v", req.Proxy)
|
tlog.App.Debug().Msgf("Proxy: %v", req.Proxy)
|
||||||
|
|
||||||
tlog.App.Trace().Interface("headers", c.Request.Header).Msg("Request headers")
|
|
||||||
|
|
||||||
authModules := controller.determineAuthModules(req.Proxy)
|
authModules := controller.determineAuthModules(req.Proxy)
|
||||||
|
|
||||||
|
if len(authModules) == 0 {
|
||||||
|
return ProxyContext{}, fmt.Errorf("no auth modules supported for proxy: %v", req.Proxy)
|
||||||
|
}
|
||||||
|
|
||||||
var ctx ProxyContext
|
var ctx ProxyContext
|
||||||
|
|
||||||
for _, module := range authModules {
|
for _, module := range authModules {
|
||||||
|
|||||||
Reference in New Issue
Block a user