internal: restore /ping behaviour for embedded outpost (#11568)

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens L.
2024-09-30 18:44:03 +02:00
committed by GitHub
parent 524f9ff18e
commit dc1562a7de

View File

@ -6,6 +6,7 @@ import (
"errors" "errors"
"net" "net"
"net/http" "net/http"
"strings"
"sync" "sync"
sentryhttp "github.com/getsentry/sentry-go/http" sentryhttp "github.com/getsentry/sentry-go/http"
@ -70,12 +71,20 @@ func NewProxyServer(ac *ak.APIController) *ProxyServer {
} }
func (ps *ProxyServer) HandleHost(rw http.ResponseWriter, r *http.Request) bool { func (ps *ProxyServer) HandleHost(rw http.ResponseWriter, r *http.Request) bool {
// Always handle requests for outpost paths that should answer regardless of hostname
if strings.HasPrefix(r.URL.Path, "/outpost.goauthentik.io/ping") ||
strings.HasPrefix(r.URL.Path, "/outpost.goauthentik.io/static") {
ps.mux.ServeHTTP(rw, r)
return true
}
// lookup app by hostname
a, _ := ps.lookupApp(r) a, _ := ps.lookupApp(r)
if a == nil { if a == nil {
return false return false
} }
// check if the app should handle this URL, or is setup in proxy mode
if a.ShouldHandleURL(r) || a.Mode() == api.PROXYMODE_PROXY { if a.ShouldHandleURL(r) || a.Mode() == api.PROXYMODE_PROXY {
a.ServeHTTP(rw, r) ps.mux.ServeHTTP(rw, r)
return true return true
} }
return false return false