Skip to content
This repository was archived by the owner on May 31, 2024. It is now read-only.

Commit 0d3da2a

Browse files
committed
feature #14721 [Security] Configuring a user checker per firewall (iltar)
This PR was squashed before being merged into the 2.8 branch (closes #14721). Discussion ---------- [Security] Configuring a user checker per firewall _Changed my base branch to avoid issues, closed old PR_ | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed ticket | #11090 and helps #14673 | License | MIT | Doc PR | symfony/symfony-docs/pull/5530 This pull request adds support for a configurable user checker per firewall. An example could be: ```yml services: app.user_checker: class: App\Security\UserChecker arguments: - "@request_stack" security: firewalls: secured_area: pattern: ^/ anonymous: ~ basic_auth: ~ user_checker: app.user_checker ``` The above example will use the `UserChecker` defined as `app.user_checker`. If the `user_checker` option is left empty, `security.user_checker` will be used. If the `user_checkers` option is not defined, it will fall back to the original behavior to not break backwards compatibility and will validate using the existing `UserChecker`: `security.user_checker`. I left the default argument in the service definitions to be `security.user_checker` to include backwards compatibility for people who for some reason don't have the extension executed. You can obtain the checker for a specific firewall by appending the firewall name to it. For the firewall `secured_area`, this would be `security.user_checker.secured_area`. Commits ------- 76bc662 [Security] Configuring a user checker per firewall
2 parents c2d213d + b8517a6 commit 0d3da2a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Core/User/UserCheckerInterface.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@
1111

1212
namespace Symfony\Component\Security\Core\User;
1313

14+
use Symfony\Component\Security\Core\Exception\AccountStatusException;
15+
1416
/**
15-
* UserCheckerInterface checks user account when authentication occurs.
17+
* Implement to throw AccountStatusException during the authentication process.
1618
*
17-
* This should not be used to make authentication decisions.
19+
* Can be used when you want to check the account status, e.g when the account is
20+
* disabled or blocked. This should not be used to make authentication decisions.
1821
*
1922
* @author Fabien Potencier <fabien@symfony.com>
2023
*/
@@ -24,13 +27,17 @@ interface UserCheckerInterface
2427
* Checks the user account before authentication.
2528
*
2629
* @param UserInterface $user a UserInterface instance
30+
*
31+
* @throws AccountStatusException
2732
*/
2833
public function checkPreAuth(UserInterface $user);
2934

3035
/**
3136
* Checks the user account after authentication.
3237
*
3338
* @param UserInterface $user a UserInterface instance
39+
*
40+
* @throws AccountStatusException
3441
*/
3542
public function checkPostAuth(UserInterface $user);
3643
}

0 commit comments

Comments
 (0)