diff options
Diffstat (limited to 'pkg/web')
| -rw-r--r-- | pkg/web/middleware/unpack_token.go | 3 | ||||
| -rw-r--r-- | pkg/web/middleware/unpack_token_test.go | 7 |
2 files changed, 6 insertions, 4 deletions
diff --git a/pkg/web/middleware/unpack_token.go b/pkg/web/middleware/unpack_token.go index 949934b..914f405 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/log" + "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/key" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/oidc" ) @@ -36,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(oidc.IDTokenKey.With(r.Context(), idToken)), + r.WithContext(key.IDTokenKey.With(r.Context(), idToken)), ) }) } diff --git a/pkg/web/middleware/unpack_token_test.go b/pkg/web/middleware/unpack_token_test.go index 814aa79..1405d6d 100644 --- a/pkg/web/middleware/unpack_token_test.go +++ b/pkg/web/middleware/unpack_token_test.go @@ -12,6 +12,7 @@ import ( "github.com/stretchr/testify/require" "github.com/xlgmokha/x/pkg/log" "github.com/xlgmokha/x/pkg/x" + "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/key" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/oidc" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/test" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/web" @@ -46,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 := oidc.IDTokenKey.From(r.Context()) + token := key.IDTokenKey.From(r.Context()) require.NotNil(t, token) assert.Equal(t, user.Subject, token.Subject) @@ -67,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, oidc.IDTokenKey.From(r.Context())) + require.Nil(t, key.IDTokenKey.From(r.Context())) w.WriteHeader(http.StatusTeapot) })) @@ -86,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, oidc.IDTokenKey.From(r.Context())) + require.Nil(t, key.IDTokenKey.From(r.Context())) w.WriteHeader(http.StatusTeapot) })) |
