From b7773bd06d24e217d5e9b1a5e7e5fa98e2af7a22 Mon Sep 17 00:00:00 2001 From: Giovanny BRUNET Date: Thu, 10 Apr 2025 17:27:50 +0200 Subject: [PATCH] Correction Authentification --- composer.json | 1 + composer.lock | 38 +++++++++---------- config/packages/security.yaml | 11 ++++++ ...10124208.php => Version20250410150126.php} | 2 +- src/Controller/AuthenticationController.php | 4 +- 5 files changed, 34 insertions(+), 22 deletions(-) rename migrations/{Version20250410124208.php => Version20250410150126.php} (98%) diff --git a/composer.json b/composer.json index f4ed66d..d56be13 100644 --- a/composer.json +++ b/composer.json @@ -35,6 +35,7 @@ "symfony/property-info": "7.1.*", "symfony/runtime": "7.1.*", "symfony/security-bundle": "7.1.*", + "symfony/security-csrf": "7.1.*", "symfony/serializer": "7.1.*", "symfony/stimulus-bundle": "^2.20", "symfony/string": "7.1.*", diff --git a/composer.lock b/composer.lock index b47ebfe..6123cc0 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e99a99b4ca2d6b58821cb711cb543c93", + "content-hash": "69565ad2398a468ae94c92c449ee3c20", "packages": [ { "name": "composer/semver", @@ -3466,16 +3466,16 @@ }, { "name": "symfony/form", - "version": "v7.1.5", + "version": "v7.1.6", "source": { "type": "git", "url": "https://github.com/symfony/form.git", - "reference": "6b8b53ad6d42f14b158c896163b96ff260d78222" + "reference": "7a48dda96fe16711fc042df38ca1a7dd4d9d6387" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/form/zipball/6b8b53ad6d42f14b158c896163b96ff260d78222", - "reference": "6b8b53ad6d42f14b158c896163b96ff260d78222", + "url": "https://api.github.com/repos/symfony/form/zipball/7a48dda96fe16711fc042df38ca1a7dd4d9d6387", + "reference": "7a48dda96fe16711fc042df38ca1a7dd4d9d6387", "shasum": "" }, "require": { @@ -3543,7 +3543,7 @@ "description": "Allows to easily create, process and reuse HTML forms", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/form/tree/v7.1.5" + "source": "https://github.com/symfony/form/tree/v7.1.6" }, "funding": [ { @@ -3559,7 +3559,7 @@ "type": "tidelift" } ], - "time": "2024-09-20T08:28:38+00:00" + "time": "2024-10-09T08:46:59+00:00" }, { "name": "symfony/framework-bundle", @@ -5648,16 +5648,16 @@ }, { "name": "symfony/security-bundle", - "version": "v7.1.4", + "version": "v7.1.11", "source": { "type": "git", "url": "https://github.com/symfony/security-bundle.git", - "reference": "5e10107856ff64d477c61fed7bcbb8a16125ea01" + "reference": "4012dbc0884fc7cbf555615a5aaa16f7c0d3f222" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/security-bundle/zipball/5e10107856ff64d477c61fed7bcbb8a16125ea01", - "reference": "5e10107856ff64d477c61fed7bcbb8a16125ea01", + "url": "https://api.github.com/repos/symfony/security-bundle/zipball/4012dbc0884fc7cbf555615a5aaa16f7c0d3f222", + "reference": "4012dbc0884fc7cbf555615a5aaa16f7c0d3f222", "shasum": "" }, "require": { @@ -5734,7 +5734,7 @@ "description": "Provides a tight integration of the Security component into the Symfony full-stack framework", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/security-bundle/tree/v7.1.4" + "source": "https://github.com/symfony/security-bundle/tree/v7.1.11" }, "funding": [ { @@ -5750,7 +5750,7 @@ "type": "tidelift" } ], - "time": "2024-08-20T11:38:55+00:00" + "time": "2024-12-31T17:57:35+00:00" }, { "name": "symfony/security-core", @@ -5840,16 +5840,16 @@ }, { "name": "symfony/security-csrf", - "version": "v7.1.1", + "version": "v7.1.6", "source": { "type": "git", "url": "https://github.com/symfony/security-csrf.git", - "reference": "27cd1bce9d7f3457a152a6ca9790712d6954dd21" + "reference": "23b460d3447fd61970e0ed5ec7a0301296a17f06" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/security-csrf/zipball/27cd1bce9d7f3457a152a6ca9790712d6954dd21", - "reference": "27cd1bce9d7f3457a152a6ca9790712d6954dd21", + "url": "https://api.github.com/repos/symfony/security-csrf/zipball/23b460d3447fd61970e0ed5ec7a0301296a17f06", + "reference": "23b460d3447fd61970e0ed5ec7a0301296a17f06", "shasum": "" }, "require": { @@ -5888,7 +5888,7 @@ "description": "Symfony Security Component - CSRF Library", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/security-csrf/tree/v7.1.1" + "source": "https://github.com/symfony/security-csrf/tree/v7.1.6" }, "funding": [ { @@ -5904,7 +5904,7 @@ "type": "tidelift" } ], - "time": "2024-05-31T14:57:53+00:00" + "time": "2024-09-25T14:20:29+00:00" }, { "name": "symfony/security-http", diff --git a/config/packages/security.yaml b/config/packages/security.yaml index 415ad31..039af47 100644 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -13,10 +13,21 @@ security: dev: pattern: ^/(_(profiler|wdt)|css|images|js)/ security: false + main: lazy: true provider: app_user_provider + form_login: + login_path: app_login + check_path: app_login + enable_csrf: true + csrf_token_id: authenticate + + logout: + path: app_logout + target: app_login + # activate different ways to authenticate # https://symfony.com/doc/current/security.html#the-firewall diff --git a/migrations/Version20250410124208.php b/migrations/Version20250410150126.php similarity index 98% rename from migrations/Version20250410124208.php rename to migrations/Version20250410150126.php index d1fe4fb..83c9099 100644 --- a/migrations/Version20250410124208.php +++ b/migrations/Version20250410150126.php @@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration; /** * Auto-generated Migration: Please modify to your needs! */ -final class Version20250410124208 extends AbstractMigration +final class Version20250410150126 extends AbstractMigration { public function getDescription(): string { diff --git a/src/Controller/AuthenticationController.php b/src/Controller/AuthenticationController.php index d8e6b43..94fec26 100644 --- a/src/Controller/AuthenticationController.php +++ b/src/Controller/AuthenticationController.php @@ -9,7 +9,7 @@ use Symfony\Component\Security\Http\Authentication\AuthenticationUtils; class AuthenticationController extends AbstractController { - #[Route(path: '/', name: '_login')] + #[Route(path: '/', name: 'app_login')] public function login(AuthenticationUtils $authenticationUtils): Response { // get the login error if there is one @@ -24,7 +24,7 @@ class AuthenticationController extends AbstractController ]); } - #[Route(path: '/logout', name: '_logout')] + #[Route(path: '/logout', name: 'app_logout')] public function logout(): void { throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');