diff --git a/.env b/.env
index 0f00f8c..9d208c7 100644
--- a/.env
+++ b/.env
@@ -74,4 +74,6 @@ AWS_ENDPOINT=https://s3.amazonaws.com
AWS_S3_PORTAL_URL=https://s3.amazonaws.com/portal
###< aws/aws-sdk-php-symfony ###
APP_URL='https://example.com'
-APP_DOMAIN='example.com'
\ No newline at end of file
+APP_DOMAIN='example.com'
+
+EASYCHECK_URL='https://check.solutions-easy.com'
\ No newline at end of file
diff --git a/config/services.yaml b/config/services.yaml
index 3ab0764..4744596 100644
--- a/config/services.yaml
+++ b/config/services.yaml
@@ -13,6 +13,7 @@ parameters:
logos_directory: '%kernel.project_dir%/public/uploads/logos'
oauth_sso_identifier: '%env(OAUTH_SSO_IDENTIFIER)%'
oauth_sso_identifier_login: '%env(OAUTH_SSO_IDENTIFIER_LOGIN)%'
+ easycheck_url: '%env(EASYCHECK_URL)%'
services:
# default configuration for services in *this* file
@@ -59,3 +60,9 @@ services:
# add more service definitions when explicit configuration is needed
# please note that last definitions always *replace* previous ones
+
+ App\EventListener\LogoutSubscriber:
+ arguments:
+ $easycheckUrl: '%env(EASYCHECK_URL)%'
+ tags:
+ - { name: kernel.event_subscriber }
diff --git a/src/Controller/SecurityController.php b/src/Controller/SecurityController.php
index 4cc1dbb..b54bb3d 100644
--- a/src/Controller/SecurityController.php
+++ b/src/Controller/SecurityController.php
@@ -55,9 +55,16 @@ class SecurityController extends AbstractController
}
#[Route(path: '/sso_logout', name: 'sso_logout')]
- public function ssoLogout(AccessTokenService $accessTokenService): Response
+ public function ssoLogout(AccessTokenService $accessTokenService, Request $request): Response
{
- $this->logger->info('SSO Logout called from EasyCheck');
+ $fromEasycheck = $request->query->get('from_easycheck');
+
+ if ($fromEasycheck) {
+ $this->logger->info('SSO Logout called from EasyCheck - completing logout');
+ return $this->redirectToRoute('app_logout');
+ }
+
+ $this->logger->info('SSO Logout initiated from Portal');
try {
$user = $this->getUser();
@@ -73,7 +80,7 @@ class SecurityController extends AbstractController
$this->logger->log(LogLevel::ERROR, 'Error during SSO logout: ' . $e->getMessage());
}
- $this->logger->info('Redirecting to app_logout');
+ $this->logger->info('Redirecting to app_logout (will trigger LogoutSubscriber)');
return $this->redirectToRoute('app_logout');
}
diff --git a/src/EventListener/LogoutSubscriber.php b/src/EventListener/LogoutSubscriber.php
new file mode 100644
index 0000000..be38ffa
--- /dev/null
+++ b/src/EventListener/LogoutSubscriber.php
@@ -0,0 +1,36 @@
+ 'onLogout',
+ ];
+ }
+
+ public function onLogout(LogoutEvent $event): void
+ {
+ $easycheckLogoutUrl = $this->easycheckUrl . '/logout';
+
+ $this->logger->info('LogoutSubscriber triggered - redirecting to EasyCheck logout', [
+ 'easycheck_logout_url' => $easycheckLogoutUrl,
+ 'user' => $event->getToken()?->getUserIdentifier()
+ ]);
+
+ $event->setResponse(new RedirectResponse($easycheckLogoutUrl));
+ }
+}
diff --git a/templates/elements/navbar.html.twig b/templates/elements/navbar.html.twig
index b92e280..e15708f 100644
--- a/templates/elements/navbar.html.twig
+++ b/templates/elements/navbar.html.twig
@@ -123,7 +123,7 @@
{{ ux_icon('bi:gear', {height: '20px', width: '20px'}) }}
Profil
-
+
{{ ux_icon('material-symbols:logout', {height: '20px', width: '20px'}) }}
Deconnexion