From 9e83b4b2e95254ba51c66ed15f400d3bec5712f1 Mon Sep 17 00:00:00 2001 From: mo khan Date: Wed, 16 Apr 2025 16:15:21 -0600 Subject: feat: attach middleware to unpack session cookie --- app/app.go | 3 ++- pkg/web/middleware/unpack_token.go | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/app.go b/app/app.go index 4ab44a4..f76f4a7 100644 --- a/app/app.go +++ b/app/app.go @@ -11,6 +11,7 @@ import ( "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/app/controllers/sessions" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/app/controllers/sparkles" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/web" + "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/web/middleware" ) func New() http.Handler { @@ -29,5 +30,5 @@ func New() http.Handler { mux.Handle("GET /", http.FileServer(http.Dir("public"))) logger := ioc.MustResolve[*zerolog.Logger](ioc.Default) - return log.HTTP(logger)(mux) + return log.HTTP(logger)(middleware.UnpackToken()(mux)) } diff --git a/pkg/web/middleware/unpack_token.go b/pkg/web/middleware/unpack_token.go index 8993df1..b53d5d3 100644 --- a/pkg/web/middleware/unpack_token.go +++ b/pkg/web/middleware/unpack_token.go @@ -4,6 +4,7 @@ import ( "net/http" "github.com/xlgmokha/x/pkg/context" + "github.com/xlgmokha/x/pkg/log" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/oidc" ) @@ -26,6 +27,7 @@ func UnpackToken() func(http.Handler) http.Handler { return } + log.WithFields(r.Context(), log.Fields{"id_token": idToken}) next.ServeHTTP( w, r.WithContext(IDTokenContextKey.With(r.Context(), idToken)), -- cgit v1.2.3