outposts/proxy: make logged user more consistent, set FlushInterval

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens Langhammer 2023-01-14 23:29:51 +01:00
parent 2deb185550
commit 9b2ceb0d44
No known key found for this signature in database
2 changed files with 9 additions and 6 deletions

View file

@ -113,9 +113,9 @@ func NewApplication(p api.ProxyOutpostConfig, c *http.Client, cs *ak.CryptoStore
return l return l
} }
if c.PreferredUsername != "" { if c.PreferredUsername != "" {
return l.WithField("request_username", c.PreferredUsername) return l.WithField("user", c.PreferredUsername)
} }
return l.WithField("request_username", c.Sub) return l.WithField("user", c.Sub)
})) }))
mux.Use(func(inner http.Handler) http.Handler { mux.Use(func(inner http.Handler) http.Handler {
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {

View file

@ -27,11 +27,14 @@ func (a *Application) configureProxy() error {
if err != nil { if err != nil {
return err return err
} }
rp := &httputil.ReverseProxy{Director: a.proxyModifyRequest(u)}
rsp := sentry.StartSpan(context.TODO(), "authentik.outposts.proxy.application_transport") rsp := sentry.StartSpan(context.TODO(), "authentik.outposts.proxy.application_transport")
rp.Transport = web.NewTracingTransport(rsp.Context(), a.getUpstreamTransport()) rp := &httputil.ReverseProxy{
rp.ErrorHandler = a.newProxyErrorHandler() Director: a.proxyModifyRequest(u),
rp.ModifyResponse = a.proxyModifyResponse Transport: web.NewTracingTransport(rsp.Context(), a.getUpstreamTransport()),
ErrorHandler: a.newProxyErrorHandler(),
ModifyResponse: a.proxyModifyResponse,
FlushInterval: -1,
}
a.mux.PathPrefix("/").HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { a.mux.PathPrefix("/").HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
defer func() { defer func() {
err := recover() err := recover()