Skip to content

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

Draft
adriendupuis wants to merge 3 commits into4.6from
user_auth_4.6
Draft

Update "User authentication" customization example (4.6)#3086
adriendupuis wants to merge 3 commits into4.6from
user_auth_4.6

Conversation

@adriendupuis
Copy link
Contributor

@adriendupuis adriendupuis commented Mar 12, 2026

Question Answer
JIRA Ticket IBX-11465
Versions 4.6
Edition All

TODO:

  • check it really works on 4.6

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

Preview of modified files

Preview of modified Markdown:

@github-actions
Copy link

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/config/services.yaml


code_samples/user_management/in_memory/config/services.yaml

docs/users/user_authentication.md@48:``` yaml
docs/users/user_authentication.md@49:[[= include_file('code_samples/user_management/in_memory/config/services.yaml') =]]
docs/users/user_authentication.md@50:```

001⫶services:
002⫶ App\EventListener\InteractiveLoginSubscriber:
003⫶ arguments: ['@ibexa.api.service.user']
004⫶ tags:
005⫶ - { name: kernel.event_subscriber }


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@54:``` php
docs/users/user_authentication.md@55:[[= include_file('code_samples/user_management/in_memory/src/EventSubscriber/InteractiveLoginSubscriber.php') =]]
docs/users/user_authentication.md@56:```

001⫶<?php
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⫶class InteractiveLoginSubscriber implements EventSubscriberInterface
011⫶{
012⫶ /**
013⫶ * @var \Ibexa\Contracts\Core\Repository\UserService
014⫶ */
015⫶ private $userService;
016⫶
017⫶ public function __construct(UserService $userService)
018⫶ {
019⫶ $this->userService = $userService;
020⫶ }
021⫶
022⫶ public static function getSubscribedEvents()
023⫶ {
024⫶ return [
025⫶ MVCEvents::INTERACTIVE_LOGIN => 'onInteractiveLogin'
026⫶ ];
027⫶ }
028⫶
029⫶ public function onInteractiveLogin(InteractiveLoginEvent $event)
030⫶ {
031⫶ // This loads a generic User and assigns it back to the event.
032⫶ // You may want to create Users here, or even load predefined Users depending on your own rules.
033⫶ $event->setApiUser($this->userService->loadUserByLogin( 'lolautruche' ));
034⫶ }
035⫶}

Download colorized diff

@sonarqubecloud
Copy link

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.

1 participant