From 22a7c255266c00cd51734f8775b904b041efdf2e Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Tue, 12 Oct 2021 13:33:20 +0200 Subject: [PATCH] internal: call GetStore on application to improve logging Signed-off-by: Jens Langhammer --- internal/outpost/proxyv2/application/application.go | 2 +- internal/outpost/proxyv2/application/session.go | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/internal/outpost/proxyv2/application/application.go b/internal/outpost/proxyv2/application/application.go index 7d34c3271..a78b81b89 100644 --- a/internal/outpost/proxyv2/application/application.go +++ b/internal/outpost/proxyv2/application/application.go @@ -73,11 +73,11 @@ func NewApplication(p api.ProxyOutpostConfig, c *http.Client, cs *ak.CryptoStore endpint: endpoint, oauthConfig: oauth2Config, tokenVerifier: verifier, - sessions: GetStore(p), proxyConfig: p, httpClient: c, mux: mux, } + a.sessions = a.getStore(p) muxLogger := log.WithField("logger", "authentik.outpost.proxyv2.application").WithField("name", p.Name) mux.Use(web.NewLoggingHandler(muxLogger, func(l *log.Entry, r *http.Request) *log.Entry { s, err := a.sessions.Get(r, constants.SeesionName) diff --git a/internal/outpost/proxyv2/application/session.go b/internal/outpost/proxyv2/application/session.go index 816f3550e..e4358cab3 100644 --- a/internal/outpost/proxyv2/application/session.go +++ b/internal/outpost/proxyv2/application/session.go @@ -5,13 +5,12 @@ import ( "strconv" "github.com/gorilla/sessions" - log "github.com/sirupsen/logrus" "goauthentik.io/api" "goauthentik.io/internal/config" "gopkg.in/boj/redistore.v1" ) -func GetStore(p api.ProxyOutpostConfig) sessions.Store { +func (a *Application) getStore(p api.ProxyOutpostConfig) sessions.Store { var store sessions.Store if config.G.Redis.Host != "" { rs, err := redistore.NewRediStoreWithDB(10, "tcp", fmt.Sprintf("%s:%d", config.G.Redis.Host, config.G.Redis.Port), config.G.Redis.Password, strconv.Itoa(config.G.Redis.OutpostSessionDB), []byte(*p.CookieSecret)) @@ -24,7 +23,7 @@ func GetStore(p api.ProxyOutpostConfig) sessions.Store { rs.Options.MaxAge = int(*t) + 1 } rs.Options.Domain = *p.CookieDomain - log.Info("using redis session backend") + a.log.Info("using redis session backend") store = rs } else { cs := sessions.NewCookieStore([]byte(*p.CookieSecret)) @@ -34,7 +33,7 @@ func GetStore(p api.ProxyOutpostConfig) sessions.Store { // Add one to the validity to ensure we don't have a session with indefinite length cs.Options.MaxAge = int(*t) + 1 } - log.Info("using cookie session backend") + a.log.Info("using cookie session backend") store = cs } return store