From 16cb8acb9130e1937d095a3c470d1de4fce3bf6c Mon Sep 17 00:00:00 2001 From: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com> Date: Thu, 12 Mar 2026 11:54:45 +0100 Subject: [PATCH 1/7] =?UTF-8?q?user=5Fauthentication.md:=20fixes,=20encode?= =?UTF-8?q?rs=20=E2=86=92=20password=5Fhashers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/users/user_authentication.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/users/user_authentication.md b/docs/users/user_authentication.md index d2b7280301..d61bdb1630 100644 --- a/docs/users/user_authentication.md +++ b/docs/users/user_authentication.md @@ -53,7 +53,7 @@ security: # You will then be able to login with username "user" and password "userpass" user: { password: userpass, roles: [ 'ROLE_USER' ] } # The "in memory" provider requires an encoder for Symfony\Component\Security\Core\User\User - encoders: + password_hashers: Symfony\Component\Security\Core\User\User: plaintext ``` @@ -66,7 +66,7 @@ services: App\EventListener\InteractiveLoginListener: arguments: ['@ibexa.api.service.user'] tags: - - { name: kernel.event_subscriber }  + - { name: kernel.event_subscriber } ``` Don't mix `MVCEvents::INTERACTIVE_LOGIN` event (specific to [[= product_name =]]) and `SecurityEvents::INTERACTIVE_LOGIN` event (fired by Symfony security component). @@ -77,7 +77,7 @@ Don't mix `MVCEvents::INTERACTIVE_LOGIN` event (specific to [[= product_name =]] namespace App\EventListener; use Ibexa\Contracts\Core\Repository\UserService; -use eIbexa\Core\MVC\Symfony\Event\InteractiveLoginEvent; +use Ibexa\Core\MVC\Symfony\Event\InteractiveLoginEvent; use Ibexa\Core\MVC\Symfony\MVCEvents; use Symfony\Component\EventDispatcher\EventSubscriberInterface; From 922c4b6c506c8b32c654990d5662e1cafa8f1db3 Mon Sep 17 00:00:00 2001 From: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com> Date: Fri, 13 Mar 2026 13:56:50 +0100 Subject: [PATCH 2/7] user_authentication.md: Move code to files --- .../in_memory/config/packages/security.yaml | 17 ++++++ .../in_memory/config/services.yaml | 5 ++ .../InteractiveLoginSubscriber.php | 35 +++++++++++ docs/users/user_authentication.md | 60 +------------------ 4 files changed, 60 insertions(+), 57 deletions(-) create mode 100644 code_samples/user_management/in_memory/config/packages/security.yaml create mode 100644 code_samples/user_management/in_memory/config/services.yaml create mode 100644 code_samples/user_management/in_memory/src/EventSubscriber/InteractiveLoginSubscriber.php diff --git a/code_samples/user_management/in_memory/config/packages/security.yaml b/code_samples/user_management/in_memory/config/packages/security.yaml new file mode 100644 index 0000000000..399be2b162 --- /dev/null +++ b/code_samples/user_management/in_memory/config/packages/security.yaml @@ -0,0 +1,17 @@ +# config/packages/security.yaml +security: + providers: + # Chaining in_memory and ibexa user providers + chain_provider: + chain: + providers: [in_memory, ibexa] + ibexa: + id: ibexa.security.user_provider + in_memory: + memory: + users: + # You will then be able to login with username "user" and password "userpass" + user: { password: userpass, roles: [ 'ROLE_USER' ] } + # The "in memory" provider requires an encoder for Symfony\Component\Security\Core\User\User + password_hashers: + Symfony\Component\Security\Core\User\User: plaintext diff --git a/code_samples/user_management/in_memory/config/services.yaml b/code_samples/user_management/in_memory/config/services.yaml new file mode 100644 index 0000000000..bcc55729a0 --- /dev/null +++ b/code_samples/user_management/in_memory/config/services.yaml @@ -0,0 +1,5 @@ +services: + App\EventListener\InteractiveLoginSubscriber: + arguments: ['@ibexa.api.service.user'] + tags: + - { name: kernel.event_subscriber } diff --git a/code_samples/user_management/in_memory/src/EventSubscriber/InteractiveLoginSubscriber.php b/code_samples/user_management/in_memory/src/EventSubscriber/InteractiveLoginSubscriber.php new file mode 100644 index 0000000000..96ca91a0dc --- /dev/null +++ b/code_samples/user_management/in_memory/src/EventSubscriber/InteractiveLoginSubscriber.php @@ -0,0 +1,35 @@ +userService = $userService; + } + + public static function getSubscribedEvents() + { + return [ + MVCEvents::INTERACTIVE_LOGIN => 'onInteractiveLogin' + ]; + } + + public function onInteractiveLogin(InteractiveLoginEvent $event) + { + // This loads a generic User and assigns it back to the event. + // You may want to create Users here, or even load predefined Users depending on your own rules. + $event->setApiUser($this->userService->loadUserByLogin( 'lolautruche' )); + } +} diff --git a/docs/users/user_authentication.md b/docs/users/user_authentication.md index d61bdb1630..867730b996 100644 --- a/docs/users/user_authentication.md +++ b/docs/users/user_authentication.md @@ -38,23 +38,7 @@ You can override `getUser()` to return whatever user class you want, as long a The following is an example of using the in-memory user provider: ``` yaml -# config/packages/security.yaml -security: - providers: - # Chaining in_memory and ibexa user providers - chain_provider: - chain: - providers: [in_memory, ibexa] - ibexa: - id: ibexa.security.user_provider - in_memory: - memory: - users: - # You will then be able to login with username "user" and password "userpass" - user: { password: userpass, roles: [ 'ROLE_USER' ] } - # The "in memory" provider requires an encoder for Symfony\Component\Security\Core\User\User - password_hashers: - Symfony\Component\Security\Core\User\User: plaintext +[[= include_file('code_samples/user_management/in_memory/config/packages/security.yaml') =]] ``` ### Implement the listener @@ -62,49 +46,11 @@ security: In the `config/services.yaml` file: ``` yaml -services: - App\EventListener\InteractiveLoginListener: - arguments: ['@ibexa.api.service.user'] - tags: - - { name: kernel.event_subscriber } +[[= include_file('code_samples/user_management/in_memory/config/services.yaml') =]] ``` Don't mix `MVCEvents::INTERACTIVE_LOGIN` event (specific to [[= product_name =]]) and `SecurityEvents::INTERACTIVE_LOGIN` event (fired by Symfony security component). ``` php -userService = $userService; - } - - public static function getSubscribedEvents() - { - return [ - MVCEvents::INTERACTIVE_LOGIN => 'onInteractiveLogin' - ]; - } - - public function onInteractiveLogin(InteractiveLoginEvent $event) - { - // This loads a generic User and assigns it back to the event. - // You may want to create Users here, or even load predefined Users depending on your own rules. - $event->setApiUser($this->userService->loadUserByLogin( 'lolautruche' )); - } -}  +[[= include_file('code_samples/user_management/in_memory/src/EventSubscriber/InteractiveLoginSubscriber.php') =]] ``` From d5f1d432c0f4e2353345b5aef3d81f756f6b4d3c Mon Sep 17 00:00:00 2001 From: adriendupuis Date: Fri, 13 Mar 2026 13:04:32 +0000 Subject: [PATCH 3/7] PHP & JS CS Fixes --- .../src/EventSubscriber/InteractiveLoginSubscriber.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code_samples/user_management/in_memory/src/EventSubscriber/InteractiveLoginSubscriber.php b/code_samples/user_management/in_memory/src/EventSubscriber/InteractiveLoginSubscriber.php index 96ca91a0dc..37d0cc70ca 100644 --- a/code_samples/user_management/in_memory/src/EventSubscriber/InteractiveLoginSubscriber.php +++ b/code_samples/user_management/in_memory/src/EventSubscriber/InteractiveLoginSubscriber.php @@ -1,4 +1,4 @@ - 'onInteractiveLogin' + MVCEvents::INTERACTIVE_LOGIN => 'onInteractiveLogin', ]; } @@ -30,6 +30,6 @@ public function onInteractiveLogin(InteractiveLoginEvent $event) { // This loads a generic User and assigns it back to the event. // You may want to create Users here, or even load predefined Users depending on your own rules. - $event->setApiUser($this->userService->loadUserByLogin( 'lolautruche' )); + $event->setApiUser($this->userService->loadUserByLogin('lolautruche')); } } From 853d80ef7be221659685cdac3b0c7e552744c104 Mon Sep 17 00:00:00 2001 From: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com> Date: Fri, 13 Mar 2026 15:58:56 +0100 Subject: [PATCH 4/7] InteractiveLoginSubscriber: typehint --- .../src/EventSubscriber/InteractiveLoginSubscriber.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code_samples/user_management/in_memory/src/EventSubscriber/InteractiveLoginSubscriber.php b/code_samples/user_management/in_memory/src/EventSubscriber/InteractiveLoginSubscriber.php index 37d0cc70ca..8027a393e9 100644 --- a/code_samples/user_management/in_memory/src/EventSubscriber/InteractiveLoginSubscriber.php +++ b/code_samples/user_management/in_memory/src/EventSubscriber/InteractiveLoginSubscriber.php @@ -26,10 +26,10 @@ public static function getSubscribedEvents() ]; } - public function onInteractiveLogin(InteractiveLoginEvent $event) + public function onInteractiveLogin(InteractiveLoginEvent $event): void { // This loads a generic User and assigns it back to the event. // You may want to create Users here, or even load predefined Users depending on your own rules. - $event->setApiUser($this->userService->loadUserByLogin('lolautruche')); + $event->setApiUser($this->userService->loadUserByLogin('generic_user')); } } From 22ed98e5c2550ab40276f37e81b4b4f84dff19e5 Mon Sep 17 00:00:00 2001 From: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com> Date: Tue, 9 Jun 2026 17:15:39 +0200 Subject: [PATCH 5/7] Apply suggestions from code review Co-authored-by: Konrad Oboza --- .../src/EventSubscriber/InteractiveLoginSubscriber.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/code_samples/user_management/in_memory/src/EventSubscriber/InteractiveLoginSubscriber.php b/code_samples/user_management/in_memory/src/EventSubscriber/InteractiveLoginSubscriber.php index 8027a393e9..f1649bb6a4 100644 --- a/code_samples/user_management/in_memory/src/EventSubscriber/InteractiveLoginSubscriber.php +++ b/code_samples/user_management/in_memory/src/EventSubscriber/InteractiveLoginSubscriber.php @@ -7,19 +7,16 @@ use Ibexa\Core\MVC\Symfony\MVCEvents; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -class InteractiveLoginSubscriber implements EventSubscriberInterface +final class InteractiveLoginSubscriber implements EventSubscriberInterface { - /** - * @var \Ibexa\Contracts\Core\Repository\UserService - */ - private $userService; + private UserService $userService; public function __construct(UserService $userService) { $this->userService = $userService; } - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ MVCEvents::INTERACTIVE_LOGIN => 'onInteractiveLogin', From 740cf281094d02f6f394392db55cb42188504fdd Mon Sep 17 00:00:00 2001 From: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com> Date: Tue, 9 Jun 2026 17:27:39 +0200 Subject: [PATCH 6/7] code_samples.yaml: PHP 8.2 PKSA-fs5b-x5k4-1h39 --- .github/workflows/code_samples.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/code_samples.yaml b/.github/workflows/code_samples.yaml index 4788ee2200..b0f1e22e2d 100644 --- a/.github/workflows/code_samples.yaml +++ b/.github/workflows/code_samples.yaml @@ -78,6 +78,13 @@ jobs: "PKSA-xx6c-6d96-db2w": "As this is for code quality tests and not to run a production DXP, this can be ignored." }' + - name: Ignore audit advisory for PHP 8.2 + if: matrix.php == '8.2' + run: | + composer config audit.ignore --json '{ + "PKSA-fs5b-x5k4-1h39": "As this is for code quality tests and not to run a production DXP, this can be ignored." + }' + - uses: ramsey/composer-install@v3 with: dependency-versions: highest From 9744ccea88e73ed7bb470f586c7f85ebcf896367 Mon Sep 17 00:00:00 2001 From: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com> Date: Wed, 10 Jun 2026 14:33:41 +0200 Subject: [PATCH 7/7] No need to declare the service --- .../user_management/in_memory/config/services.yaml | 5 ----- docs/users/user_authentication.md | 8 ++------ 2 files changed, 2 insertions(+), 11 deletions(-) delete mode 100644 code_samples/user_management/in_memory/config/services.yaml diff --git a/code_samples/user_management/in_memory/config/services.yaml b/code_samples/user_management/in_memory/config/services.yaml deleted file mode 100644 index bcc55729a0..0000000000 --- a/code_samples/user_management/in_memory/config/services.yaml +++ /dev/null @@ -1,5 +0,0 @@ -services: - App\EventListener\InteractiveLoginSubscriber: - arguments: ['@ibexa.api.service.user'] - tags: - - { name: kernel.event_subscriber } diff --git a/docs/users/user_authentication.md b/docs/users/user_authentication.md index 867730b996..34cc466740 100644 --- a/docs/users/user_authentication.md +++ b/docs/users/user_authentication.md @@ -43,14 +43,10 @@ The following is an example of using the in-memory user provider: ### Implement the listener -In the `config/services.yaml` file: - -``` yaml -[[= include_file('code_samples/user_management/in_memory/config/services.yaml') =]] -``` - Don't mix `MVCEvents::INTERACTIVE_LOGIN` event (specific to [[= product_name =]]) and `SecurityEvents::INTERACTIVE_LOGIN` event (fired by Symfony security component). ``` php [[= include_file('code_samples/user_management/in_memory/src/EventSubscriber/InteractiveLoginSubscriber.php') =]] ``` + +It's automatically tagged `kernel.event_subscriber` as implementing the `EventSubscriberInterface` and the user service injection is auto-wired.