diff --git a/Services/JWSProvider/LcobucciJWSProvider.php b/Services/JWSProvider/LcobucciJWSProvider.php index 3507983b..b3394743 100644 --- a/Services/JWSProvider/LcobucciJWSProvider.php +++ b/Services/JWSProvider/LcobucciJWSProvider.php @@ -271,7 +271,7 @@ private function addStandardClaims(Builder $builder, array &$payload): Builder unset($payload[$claim]); if (\is_array($value)) { - \call_user_func_array([$builder, $mutator], $value); + $builder = \call_user_func_array([$builder, $mutator], $value); continue; } diff --git a/Tests/Functional/GetTokenTest.php b/Tests/Functional/GetTokenTest.php index bc438f3f..5c033a1d 100644 --- a/Tests/Functional/GetTokenTest.php +++ b/Tests/Functional/GetTokenTest.php @@ -58,7 +58,7 @@ public function testGetTokenWithCustomClaim() $subscriber = static::$kernel->getContainer()->get('lexik_jwt_authentication.test.jwt_event_subscriber'); $subscriber->setListener(Events::JWT_CREATED, function (JWTCreatedEvent $e) { - $e->setData($e->getData() + ['custom' => 'dummy']); + $e->setData($e->getData() + ['custom' => 'dummy', 'aud' => ['foo', 'bar']]); $e->setHeader($e->getHeader() + ['foo' => 'bar']); }); @@ -78,6 +78,7 @@ public function testGetTokenWithCustomClaim() $jws = $parser->parse($token); $this->assertArrayHasKey('foo', method_exists($jws, 'headers') ? $jws->headers()->all() : $jws->getHeaders(), 'The payload should contains a custom "foo" header.'); + $this->assertSame(['foo', 'bar'], $jws->claims()->get('aud')); } public function testGetTokenFromInvalidCredentials()