Refactor JWTOnDavUrlAuthenticator to extend JWTAuthenticator and update dependencies

- Replaced `JWTTokenAuthenticator` with `JWTAuthenticator` for compatibility with updated security components.
- Updated constructor to use `UserProviderInterface` instead of `TokenStorageInterface`.
- Enhanced `getTokenExtractor` with correct return type declaration.
This commit is contained in:
2025-11-03 13:12:38 +01:00
parent f8571f22a6
commit 7fd219d517

View File

@@ -11,30 +11,30 @@ declare(strict_types=1);
namespace Chill\DocStoreBundle\Security\Guard; namespace Chill\DocStoreBundle\Security\Guard;
use Lexik\Bundle\JWTAuthenticationBundle\Security\Guard\JWTTokenAuthenticator; use Lexik\Bundle\JWTAuthenticationBundle\Security\Authenticator\JWTAuthenticator;
use Lexik\Bundle\JWTAuthenticationBundle\Services\JWTTokenManagerInterface; use Lexik\Bundle\JWTAuthenticationBundle\Services\JWTTokenManagerInterface;
use Lexik\Bundle\JWTAuthenticationBundle\TokenExtractor\TokenExtractorInterface; use Lexik\Bundle\JWTAuthenticationBundle\TokenExtractor\TokenExtractorInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\User\UserProviderInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use Symfony\Contracts\Translation\TranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface;
/** /**
* Alter the base JWTTokenAuthenticator to add the special extractor for dav url endpoints. * Alter the base JWTTokenAuthenticator to add the special extractor for dav url endpoints.
*/ */
class JWTOnDavUrlAuthenticator extends JWTTokenAuthenticator class JWTOnDavUrlAuthenticator extends JWTAuthenticator
{ {
public function __construct( public function __construct(
JWTTokenManagerInterface $jwtManager, JWTTokenManagerInterface $jwtManager,
EventDispatcherInterface $dispatcher, EventDispatcherInterface $dispatcher,
TokenExtractorInterface $tokenExtractor, TokenExtractorInterface $tokenExtractor,
private readonly DavOnUrlTokenExtractor $davOnUrlTokenExtractor, private readonly DavOnUrlTokenExtractor $davOnUrlTokenExtractor,
TokenStorageInterface $preAuthenticationTokenStorage, UserProviderInterface $userProvider,
?TranslatorInterface $translator = null, ?TranslatorInterface $translator = null,
) { ) {
parent::__construct($jwtManager, $dispatcher, $tokenExtractor, $preAuthenticationTokenStorage, $translator); parent::__construct($jwtManager, $dispatcher, $tokenExtractor, $userProvider, $translator);
} }
protected function getTokenExtractor() protected function getTokenExtractor(): TokenExtractorInterface
{ {
return $this->davOnUrlTokenExtractor; return $this->davOnUrlTokenExtractor;
} }