lexik/LexikJWTAuthenticationBundle

aud property is missing in 2.19

ostrolucky opened this issue · 2 comments

We add aud to payload via lexik_jwt_authentication.on_jwt_created event. After upgrade to 2.19, this property is missing in encoded token

Our listener

<?php

use Lexik\Bundle\JWTAuthenticationBundle\Event\JWTCreatedEvent;
use Lexik\Bundle\JWTAuthenticationBundle\Events;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

final class AttachPayloadToJwtSubscriber implements EventSubscriberInterface
{
    public function __construct(private PlatformDetector $platformDetector)
    {
    }

    public function onJwtCreated(JWTCreatedEvent $event): void
    {
        /** @var User $user */
        $user = $event->getUser();
        $payload = ['aud' => [],];

        foreach ($user->getLicense()->getApplications() as $licenseApplication) {
            $payload['aud'][] = $licenseApplication->getApplication()->getId();
        }

        $event->setData(array_merge($event->getData(), $payload));
    }

    public static function getSubscribedEvents(): array
    {
        return [Events::JWT_CREATED => 'onJwtCreated'];
    }
}

Same problem here. It's like the class never gets called when an event is fired.

Fix at #1144