Skip to content

Update "User authentication" customization example (4.6)#3086

Merged
adriendupuis merged 8 commits into
4.6from
user_auth_4.6
Jun 11, 2026
Merged

Update "User authentication" customization example (4.6)#3086
adriendupuis merged 8 commits into
4.6from
user_auth_4.6

Conversation

@adriendupuis

@adriendupuis adriendupuis commented Mar 12, 2026

Copy link
Copy Markdown
Contributor
Question Answer
JIRA Ticket IBX-11465
Versions 4.6
Edition All

TODO:

  • check it really works on 4.6

Related RP: #3087

Checklist

  • Text renders correctly
  • Text has been checked with vale
  • Description metadata is up to date
  • Redirects cover removed/moved pages
  • Code samples are working
  • PHP code samples have been fixed with PHP CS fixer
  • Added link to this PR in relevant JIRA ticket or code PR

@adriendupuis adriendupuis changed the base branch from 5.0 to 4.6 March 12, 2026 11:00
@github-actions

Copy link
Copy Markdown

Preview of modified files

Preview of modified Markdown:

Comment thread docs/users/user_authentication.md
@sonarqubecloud

Copy link
Copy Markdown

adriendupuis and others added 2 commits June 9, 2026 16:43
Co-authored-by: Konrad Oboza <konrad.oboza@ibexa.co>
@adriendupuis adriendupuis marked this pull request as ready for review June 9, 2026 15:21
@adriendupuis adriendupuis requested a review from konradoboza June 9, 2026 15:21
@@ -0,0 +1,5 @@
services:
App\EventListener\InteractiveLoginSubscriber:
arguments: ['@ibexa.api.service.user']

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably this config can be simplified with setting autowire: true and autoconfigure: true.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole block might be removed as Subscribers are supposed to be automatically tagged as kernel.event_subscriber services…

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

…confirmed, no need to declare this service, it's tagged and wired automatically.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in 9744cce

@github-actions

Copy link
Copy Markdown

code_samples/ change report

Before (on target branch)After (in current PR)

code_samples/user_management/in_memory/config/packages/security.yaml


code_samples/user_management/in_memory/config/packages/security.yaml

docs/users/user_authentication.md@40:``` yaml
docs/users/user_authentication.md@41:[[= include_file('code_samples/user_management/in_memory/config/packages/security.yaml') =]]
docs/users/user_authentication.md@42:```

001⫶# config/packages/security.yaml
002⫶security:
003⫶ providers:
004⫶ # Chaining in_memory and ibexa user providers
005⫶ chain_provider:
006⫶ chain:
007⫶ providers: [in_memory, ibexa]
008⫶ ibexa:
009⫶ id: ibexa.security.user_provider
010⫶ in_memory:
011⫶ memory:
012⫶ users:
013⫶ # You will then be able to login with username "user" and password "userpass"
014⫶ user: { password: userpass, roles: [ 'ROLE_USER' ] }
015⫶ # The "in memory" provider requires an encoder for Symfony\Component\Security\Core\User\User
016⫶ password_hashers:
017⫶ Symfony\Component\Security\Core\User\User: plaintext


code_samples/user_management/in_memory/src/EventSubscriber/InteractiveLoginSubscriber.php


code_samples/user_management/in_memory/src/EventSubscriber/InteractiveLoginSubscriber.php

docs/users/user_authentication.md@48:``` php
docs/users/user_authentication.md@49:[[= include_file('code_samples/user_management/in_memory/src/EventSubscriber/InteractiveLoginSubscriber.php') =]]
docs/users/user_authentication.md@50:```

001⫶<?php declare(strict_types=1);
002⫶
003⫶namespace App\EventSubscriber;
004⫶
005⫶use Ibexa\Contracts\Core\Repository\UserService;
006⫶use Ibexa\Core\MVC\Symfony\Event\InteractiveLoginEvent;
007⫶use Ibexa\Core\MVC\Symfony\MVCEvents;
008⫶use Symfony\Component\EventDispatcher\EventSubscriberInterface;
009⫶
010⫶final class InteractiveLoginSubscriber implements EventSubscriberInterface
011⫶{
012⫶ private UserService $userService;
013⫶
014⫶ public function __construct(UserService $userService)
015⫶ {
016⫶ $this->userService = $userService;
017⫶ }
018⫶
019⫶ public static function getSubscribedEvents(): array
020⫶ {
021⫶ return [
022⫶ MVCEvents::INTERACTIVE_LOGIN => 'onInteractiveLogin',
023⫶ ];
024⫶ }
025⫶
026⫶ public function onInteractiveLogin(InteractiveLoginEvent $event): void
027⫶ {
028⫶ // This loads a generic User and assigns it back to the event.
029⫶ // You may want to create Users here, or even load predefined Users depending on your own rules.
030⫶ $event->setApiUser($this->userService->loadUserByLogin('generic_user'));
031⫶ }
032⫶}

Download colorized diff

@adriendupuis adriendupuis merged commit dc09c2f into 4.6 Jun 11, 2026
11 checks passed
@adriendupuis adriendupuis deleted the user_auth_4.6 branch June 11, 2026 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants