From 791f5bb4be42c78955c782778a296de82288fec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 24 Feb 2025 16:13:20 +0100 Subject: [PATCH] Remove custom Messenger authentication logic (WIP) Eliminated the `AuthenticationMiddleware`, `AuthenticatedMessengerToken`, and `AuthenticationStamp` classes, along with their service declarations. This cleanup removes unused or unnecessary code, simplifying the project and reducing maintenance overhead. --- .../AuthenticatedMessengerToken.php | 21 --------- .../Middleware/AuthenticationMiddleware.php | 47 ------------------- .../Messenger/Stamp/AuthenticationStamp.php | 33 ------------- .../ChillMainBundle/config/services.yaml | 5 -- 4 files changed, 106 deletions(-) delete mode 100644 src/Bundle/ChillMainBundle/Messenger/Authentication/AuthenticatedMessengerToken.php delete mode 100644 src/Bundle/ChillMainBundle/Messenger/Middleware/AuthenticationMiddleware.php delete mode 100644 src/Bundle/ChillMainBundle/Messenger/Stamp/AuthenticationStamp.php diff --git a/src/Bundle/ChillMainBundle/Messenger/Authentication/AuthenticatedMessengerToken.php b/src/Bundle/ChillMainBundle/Messenger/Authentication/AuthenticatedMessengerToken.php deleted file mode 100644 index 0cfb4d17f..000000000 --- a/src/Bundle/ChillMainBundle/Messenger/Authentication/AuthenticatedMessengerToken.php +++ /dev/null @@ -1,21 +0,0 @@ -setUser($user); - $this->setAuthenticated(true); - } - - public function getCredentials(): null - { - return null; - } -} diff --git a/src/Bundle/ChillMainBundle/Messenger/Middleware/AuthenticationMiddleware.php b/src/Bundle/ChillMainBundle/Messenger/Middleware/AuthenticationMiddleware.php deleted file mode 100644 index 411713f56..000000000 --- a/src/Bundle/ChillMainBundle/Messenger/Middleware/AuthenticationMiddleware.php +++ /dev/null @@ -1,47 +0,0 @@ -last(AuthenticationStamp::class)) { - return; - /** @var AuthenticationStamp $authenticationStamp */ - dump("authenticate user", $authenticationStamp->getUserId()); - if (null !== $this->tokenStorage->getToken()) { - dump("token already present"); - - } else { - $user = $this->userProvider->loadUserByUsername($authenticationStamp->getUserId()); - $this->tokenStorage->setToken(new AuthenticatedMessengerToken($user, [...$user->getRoles(), 'IS_AUTHENTICATED_FULLY'])); - } - } - - return $stack->next()->handle($envelope, $stack); - } -} diff --git a/src/Bundle/ChillMainBundle/Messenger/Stamp/AuthenticationStamp.php b/src/Bundle/ChillMainBundle/Messenger/Stamp/AuthenticationStamp.php deleted file mode 100644 index a290f3d36..000000000 --- a/src/Bundle/ChillMainBundle/Messenger/Stamp/AuthenticationStamp.php +++ /dev/null @@ -1,33 +0,0 @@ -userId = $user->getUserIdentifier(); - } - - public function getUserId(): string - { - return $this->userId; - } -} diff --git a/src/Bundle/ChillMainBundle/config/services.yaml b/src/Bundle/ChillMainBundle/config/services.yaml index 1db9d25ef..a9829f99d 100644 --- a/src/Bundle/ChillMainBundle/config/services.yaml +++ b/src/Bundle/ChillMainBundle/config/services.yaml @@ -101,11 +101,6 @@ services: autowire: true autoconfigure: true - Chill\MainBundle\Messenger\: - resource: '../Messenger/' - autowire: true - autoconfigure: true - Chill\MainBundle\Cron\: resource: '../Cron' autowire: true