Skip to content

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

Open
adriendupuis wants to merge 7 commits into
4.6from
user_auth_4.6
Open

Update "User authentication" customization example (4.6)#3086
adriendupuis wants to merge 7 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:

{
// 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' ));

@adriendupuis adriendupuis Mar 13, 2026

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.

Big up to @lolautruche!
But I'll move to generic_user here 😉

@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
@github-actions

github-actions Bot commented Jun 9, 2026

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/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 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

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