diff --git a/pkg/auth/cookie_manager.go b/pkg/auth/cookie_manager.go index 5ae501c59..f490d6465 100644 --- a/pkg/auth/cookie_manager.go +++ b/pkg/auth/cookie_manager.go @@ -31,6 +31,7 @@ func NewCookieManager(ctx context.Context, hashKeyEncoded, blockKeyEncoded strin if err != nil { return CookieManager{}, errors.Wrapf(ErrB64Decoding, err, "Error decoding hash key bytes") } + blockKey, err := base64.RawStdEncoding.DecodeString(blockKeyEncoded) if err != nil { return CookieManager{}, errors.Wrapf(ErrB64Decoding, err, "Error decoding block key bytes") diff --git a/pkg/auth/handlers_test.go b/pkg/auth/handlers_test.go index 8681f8a12..fc3016a35 100644 --- a/pkg/auth/handlers_test.go +++ b/pkg/auth/handlers_test.go @@ -49,12 +49,19 @@ func TestGetHTTPRequestCookieToMetadataHandler(t *testing.T) { assert.NoError(t, err) mockAuthCtx := mocks.AuthenticationContext{} mockAuthCtx.On("CookieManager").Return(&cookieManager) + mockAuthCtx.OnOptions().Return(config.OAuthOptions{}) handler := GetHTTPRequestCookieToMetadataHandler(&mockAuthCtx) req, err := http.NewRequest("GET", "/api/v1/projects", nil) assert.NoError(t, err) - jwtCookie, err := NewSecureCookie(accessTokenCookieName, "a.b.c", cookieManager.hashKey, cookieManager.blockKey) + + accessTokenCookie, err := NewSecureCookie(accessTokenCookieName, "a.b.c", cookieManager.hashKey, cookieManager.blockKey) + assert.NoError(t, err) + req.AddCookie(&accessTokenCookie) + + idCookie, err := NewSecureCookie(idTokenCookieName, "a.b.c", cookieManager.hashKey, cookieManager.blockKey) assert.NoError(t, err) - req.AddCookie(&jwtCookie) + req.AddCookie(&idCookie) + assert.Equal(t, "Bearer a.b.c", handler(ctx, req)["authorization"][0]) }