-
Notifications
You must be signed in to change notification settings - Fork 81
Update "User authentication" customization example (4.6) #3086
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
16cb8ac
user_authentication.md: fixes, encoders → password_hashers
adriendupuis 922c4b6
user_authentication.md: Move code to files
adriendupuis d5f1d43
PHP & JS CS Fixes
adriendupuis 853d80e
InteractiveLoginSubscriber: typehint
adriendupuis 85245dd
Merge branch '4.6' into user_auth_4.6
adriendupuis 22ed98e
Apply suggestions from code review
adriendupuis 740cf28
code_samples.yaml: PHP 8.2 PKSA-fs5b-x5k4-1h39
adriendupuis 9744cce
No need to declare the service
adriendupuis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
code_samples/user_management/in_memory/config/packages/security.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
32 changes: 32 additions & 0 deletions
32
code_samples/user_management/in_memory/src/EventSubscriber/InteractiveLoginSubscriber.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| <?php declare(strict_types=1); | ||
|
|
||
| namespace App\EventSubscriber; | ||
|
|
||
| use Ibexa\Contracts\Core\Repository\UserService; | ||
| use Ibexa\Core\MVC\Symfony\Event\InteractiveLoginEvent; | ||
| use Ibexa\Core\MVC\Symfony\MVCEvents; | ||
| use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
|
|
||
| final class InteractiveLoginSubscriber implements EventSubscriberInterface | ||
| { | ||
| private UserService $userService; | ||
|
|
||
| public function __construct(UserService $userService) | ||
| { | ||
| $this->userService = $userService; | ||
| } | ||
|
|
||
| public static function getSubscribedEvents(): array | ||
| { | ||
| return [ | ||
| MVCEvents::INTERACTIVE_LOGIN => 'onInteractiveLogin', | ||
| ]; | ||
| } | ||
|
|
||
| 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('generic_user')); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.