fix: use X-Forwarded-Uri if it exists for pathRegex match
the functions `isApiPath` and `isAllowedPath` use the `req.URL.Path` property which leads to faulty behavior when behind a reverse proxy. The correct path can be inferred from the `X-Forwarded-Uri` header by making use of the already provided `requestutil.GetRequestURI` function. Co-authored-by: Jan Wystub <jan@bam-bam-bam.com>
This commit is contained in:
parent
7b3a36b854
commit
7529095e1a
|
|
@ -554,7 +554,7 @@ func isAllowedMethod(req *http.Request, route allowedRoute) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func isAllowedPath(req *http.Request, route allowedRoute) bool {
|
func isAllowedPath(req *http.Request, route allowedRoute) bool {
|
||||||
matches := route.pathRegex.MatchString(req.URL.Path)
|
matches := route.pathRegex.MatchString(requestutil.GetRequestURI(req))
|
||||||
|
|
||||||
if route.negate {
|
if route.negate {
|
||||||
return !matches
|
return !matches
|
||||||
|
|
@ -575,7 +575,7 @@ func (p *OAuthProxy) isAllowedRoute(req *http.Request) bool {
|
||||||
|
|
||||||
func (p *OAuthProxy) isAPIPath(req *http.Request) bool {
|
func (p *OAuthProxy) isAPIPath(req *http.Request) bool {
|
||||||
for _, route := range p.apiRoutes {
|
for _, route := range p.apiRoutes {
|
||||||
if route.pathRegex.MatchString(req.URL.Path) {
|
if route.pathRegex.MatchString(requestutil.GetRequestURI(req)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue