summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-04-16 16:15:21 -0600
committermo khan <mo@mokhan.ca>2025-04-16 16:15:21 -0600
commit9e83b4b2e95254ba51c66ed15f400d3bec5712f1 (patch)
treeed652b37c614d63b4dada2e580cf8ab5ef7c5864
parent3e70d67683e369d0b86db2bf3ff19df84e990710 (diff)
feat: attach middleware to unpack session cookie
-rw-r--r--app/app.go3
-rw-r--r--pkg/web/middleware/unpack_token.go2
2 files changed, 4 insertions, 1 deletions
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)),