PRayno / CasAuthBundle

Basic CAS (SSO) authenticator for Symfony (version 3,4 and 5)
MIT License
16 stars 19 forks source link

The "PRayno\CasAuthBundle\Event\CASAuthenticationFailureEvent" class extends "Symfony\Component\EventDispatcher\Event" that is deprecated since Symfony 4.3, use "Symfony\Contracts\EventDispatcher\Event" instead. #25

Open junowilderness opened 5 years ago

benjhoo commented 2 years ago

Hi, I dig up this issue cause the deprecation on the Event class is now an Internal Server Error on Symfony >= 5.4

Attempted to load class "Event" from namespace "Symfony\Component\EventDispatcher". Did you forget a "use" statement for "Symfony\Contracts\EventDispatcher\Event"?

To fix the issue, the following can be done :

// Event/CASAuthenticationFailureEvent.php
l.7: - use Symfony\Component\EventDispatcher\Event;
     + use Symfony\Contracts\EventDispatcher\Event;
// Security/CasAuthenticator.php
l.140: - $this->eventDispatcher->dispatch(CASAuthenticationFailureEvent::POST_MESSAGE, $event);
       + $this->eventDispatcher->dispatch($event, CASAuthenticationFailureEvent::POST_MESSAGE);

But after that, the bundle will not work with older Symfony versions I guess. Maybe testing the version before calling the function, or creating a new GIT tag for the 5.4+ versions could be a solution.

In the meanwhile, I created a custom Authenticator in my project that extends yours and overrides the onAuthenticationFailure() function.