summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
Diffstat (limited to 'pkg')
-rw-r--r--pkg/key/init.go4
-rw-r--r--pkg/web/middleware/unpack_token.go2
-rw-r--r--pkg/web/middleware/unpack_token_test.go6
3 files changed, 6 insertions, 6 deletions
diff --git a/pkg/key/init.go b/pkg/key/init.go
index 01d8a3d..f2d7b7f 100644
--- a/pkg/key/init.go
+++ b/pkg/key/init.go
@@ -6,5 +6,5 @@ import (
"gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/oidc"
)
-var CurrentUserKey context.Key[*domain.User] = context.Key[*domain.User]("current_user")
-var IDTokenKey context.Key[*oidc.IDToken] = context.Key[*oidc.IDToken]("id_token")
+var CurrentUser context.Key[*domain.User] = context.Key[*domain.User]("current_user")
+var IDToken context.Key[*oidc.IDToken] = context.Key[*oidc.IDToken]("id_token")
diff --git a/pkg/web/middleware/unpack_token.go b/pkg/web/middleware/unpack_token.go
index 914f405..db04e0e 100644
--- a/pkg/web/middleware/unpack_token.go
+++ b/pkg/web/middleware/unpack_token.go
@@ -37,7 +37,7 @@ func UnpackToken(cfg *oidc.OpenID) func(http.Handler) http.Handler {
log.WithFields(r.Context(), log.Fields{"id_token": idToken})
next.ServeHTTP(
w,
- r.WithContext(key.IDTokenKey.With(r.Context(), idToken)),
+ r.WithContext(key.IDToken.With(r.Context(), idToken)),
)
})
}
diff --git a/pkg/web/middleware/unpack_token_test.go b/pkg/web/middleware/unpack_token_test.go
index 1405d6d..f2250bc 100644
--- a/pkg/web/middleware/unpack_token_test.go
+++ b/pkg/web/middleware/unpack_token_test.go
@@ -47,7 +47,7 @@ func TestUnpackToken(t *testing.T) {
encoded := x.Must(tokens.ToBase64String())
server := middleware(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- token := key.IDTokenKey.From(r.Context())
+ token := key.IDToken.From(r.Context())
require.NotNil(t, token)
assert.Equal(t, user.Subject, token.Subject)
@@ -68,7 +68,7 @@ func TestUnpackToken(t *testing.T) {
t.Run("when an invalid session cookie is provided", func(t *testing.T) {
t.Run("forwards the request", func(t *testing.T) {
server := middleware(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- require.Nil(t, key.IDTokenKey.From(r.Context()))
+ require.Nil(t, key.IDToken.From(r.Context()))
w.WriteHeader(http.StatusTeapot)
}))
@@ -87,7 +87,7 @@ func TestUnpackToken(t *testing.T) {
t.Run("when no cookies are provided", func(t *testing.T) {
t.Run("forwards the request", func(t *testing.T) {
server := middleware(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- require.Nil(t, key.IDTokenKey.From(r.Context()))
+ require.Nil(t, key.IDToken.From(r.Context()))
w.WriteHeader(http.StatusTeapot)
}))