Skip to content

Commit

Permalink
bug #542 Fix missing implements breaking JWT header alteration (tucks…
Browse files Browse the repository at this point in the history
…aun)

This PR was merged into the 2.x-dev branch.

Discussion
----------

Fix missing implements breaking JWT header alteration

Otherwise headers are not get from the event, see  https://github.com/lexik/LexikJWTAuthenticationBundle/blob/85b05784fbad7d6435626915edeeb55ed0bcd6a7/Services/JWTManager.php#L61-L65

Commits
-------

53755d0 Fix missing implements breaking JWT header alteration
  • Loading branch information
chalasr committed Aug 2, 2018
2 parents 85b0578 + 53755d0 commit bc50055
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Encoder/LcobucciJWTEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*
* @author Robin Chalas <robin.chalas@gmail.com>
*/
class LcobucciJWTEncoder implements JWTEncoderInterface
class LcobucciJWTEncoder implements JWTEncoderInterface, HeaderAwareJWTEncoderInterface
{
/**
* @var JWSProviderInterface
Expand Down
4 changes: 4 additions & 0 deletions Tests/Functional/GetTokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit bc50055

Please sign in to comment.