From 53755d03a1b4cf933ecadc3ba6b42129f4047477 Mon Sep 17 00:00:00 2001 From: Tugdual Saunier Date: Thu, 2 Aug 2018 20:01:33 +0200 Subject: [PATCH] Fix missing implements breaking JWT header alteration --- Encoder/LcobucciJWTEncoder.php | 2 +- Tests/Functional/GetTokenTest.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Encoder/LcobucciJWTEncoder.php b/Encoder/LcobucciJWTEncoder.php index fbad6549..d2a5fe54 100644 --- a/Encoder/LcobucciJWTEncoder.php +++ b/Encoder/LcobucciJWTEncoder.php @@ -11,7 +11,7 @@ * * @author Robin Chalas */ -class LcobucciJWTEncoder implements JWTEncoderInterface +class LcobucciJWTEncoder implements JWTEncoderInterface, HeaderAwareJWTEncoderInterface { /** * @var JWSProviderInterface diff --git a/Tests/Functional/GetTokenTest.php b/Tests/Functional/GetTokenTest.php index b7f4f75e..27350460 100644 --- a/Tests/Functional/GetTokenTest.php +++ b/Tests/Functional/GetTokenTest.php @@ -2,6 +2,7 @@ namespace Lexik\Bundle\JWTAuthenticationBundle\Tests\Functional; +use Lcobucci\JWT\Parser; use Lexik\Bundle\JWTAuthenticationBundle\Event\JWTCreatedEvent; use Lexik\Bundle\JWTAuthenticationBundle\Events; use Lexik\Bundle\JWTAuthenticationBundle\Response\JWTAuthenticationSuccessResponse; @@ -41,6 +42,9 @@ public function testGetTokenWithCustomClaim() $this->assertArrayHasKey('custom', $payload, 'The payload should contains a "custom" claim.'); $this->assertSame('dummy', $payload['custom'], 'The "custom" claim should be equal to "dummy".'); + + $jws = (new Parser())->parse((string) $body['token']); + $this->assertArrayHasKey('foo', $jws->getHeaders(), 'The payload should contains a custom "foo" header.'); } public function testGetTokenFromInvalidCredentials()