diff --git a/config/packages/security.yaml b/config/packages/security.yaml index 0936e9ef..2394d207 100644 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -19,16 +19,20 @@ security: security: false main: form_login: - # "app_login" is the name of the route created previously login_path: app_login check_path: app_login - # access_token: - # token_handler: App\Security\AccessTokenHandler + enable_csrf: true + logout: + path: app_logout + # where to redirect after logout + # target: app_any_route # Contrôle d'accès access_control: - { path: ^/admin, roles: ROLE_ADMIN } - { path: ^/logged, roles: ROLE_USER } + - { path: ^/docs, roles: PUBLIC_ACCESS } # Allows accessing the Swagger UI + - { path: ^/authentication_token, roles: PUBLIC_ACCESS } # - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY } # Autoriser l'accès à la page de connexion # - { path: ^/, roles: IS_AUTHENTICATED_ANONYMOUSLY } # Autoriser l'accès anonyme à toutes les autres pages diff --git a/src/Controller/SecurityController.php b/src/Controller/SecurityController.php index 7dd6e53d..76bf5c4f 100644 --- a/src/Controller/SecurityController.php +++ b/src/Controller/SecurityController.php @@ -4,7 +4,7 @@ namespace App\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Routing\Annotation\Route; +use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Authentication\AuthenticationUtils; class SecurityController extends AbstractController @@ -25,9 +25,8 @@ class SecurityController extends AbstractController } #[Route(path: '/logout', name: 'app_logout')] - public function logout(): Response + public function logout(): void { - return $this->redirectToRoute('app_default'); - + throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.'); } } diff --git a/templates/default/login-choices.html.twig b/templates/default/login-choices.html.twig index 06c22dde..83941cf3 100755 --- a/templates/default/login-choices.html.twig +++ b/templates/default/login-choices.html.twig @@ -25,91 +25,91 @@