Merge branch 'next'
This commit is contained in:
commit
a73d50d379
|
@ -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) {
|
||||||
|
|
|
@ -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()
|
||||||
|
|
|
@ -17,7 +17,6 @@ type responseLogger struct {
|
||||||
w http.ResponseWriter
|
w http.ResponseWriter
|
||||||
status int
|
status int
|
||||||
size int
|
size int
|
||||||
upstream string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Header returns the ResponseWriter's Header
|
// Header returns the ResponseWriter's Header
|
||||||
|
@ -98,15 +97,18 @@ func (h loggingHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
responseLogger := &responseLogger{w: w}
|
responseLogger := &responseLogger{w: w}
|
||||||
h.handler.ServeHTTP(responseLogger, req)
|
h.handler.ServeHTTP(responseLogger, req)
|
||||||
duration := float64(time.Since(t)) / float64(time.Millisecond)
|
duration := float64(time.Since(t)) / float64(time.Millisecond)
|
||||||
|
scheme := "http"
|
||||||
|
if req.TLS != nil {
|
||||||
|
scheme = "https"
|
||||||
|
}
|
||||||
h.afterHandler(h.logger.WithFields(log.Fields{
|
h.afterHandler(h.logger.WithFields(log.Fields{
|
||||||
"remote": req.RemoteAddr,
|
"remote": req.RemoteAddr,
|
||||||
"host": GetHost(req),
|
"host": GetHost(req),
|
||||||
"runtime": fmt.Sprintf("%0.3f", duration),
|
"runtime": fmt.Sprintf("%0.3f", duration),
|
||||||
"method": req.Method,
|
"method": req.Method,
|
||||||
"scheme": req.URL.Scheme,
|
"scheme": scheme,
|
||||||
"size": responseLogger.Size(),
|
"size": responseLogger.Size(),
|
||||||
"status": responseLogger.Status(),
|
"status": responseLogger.Status(),
|
||||||
"upstream": responseLogger.upstream,
|
|
||||||
"user_agent": req.UserAgent(),
|
"user_agent": req.UserAgent(),
|
||||||
}), req).Info(url.RequestURI())
|
}), req).Info(url.RequestURI())
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue