Skip to content

Commit ec7d86a

Browse files
committed
feature #50939 [SecurityBundle] Add $badges argument to Security::login (MatTheCat)
This PR was squashed before being merged into the 6.4 branch. Discussion ---------- [SecurityBundle] Add `$badges` argument to `Security::login` | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | Fix #50909 | License | MIT | Doc PR | N/A Commits ------- 26a3105 [SecurityBundle] Add `$badges` argument to `Security::login`
2 parents 0a9ef56 + 26a3105 commit ec7d86a

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/Symfony/Bundle/SecurityBundle/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CHANGELOG
66

77
* Deprecate `Security::ACCESS_DENIED_ERROR`, `AUTHENTICATION_ERROR` and `LAST_USERNAME` constants, use the ones on `SecurityRequestAttributes` instead
88
* Allow an array of `pattern` in firewall configuration
9+
* Add `$badges` argument to `Security::login`
910

1011
6.3
1112
---

src/Symfony/Bundle/SecurityBundle/Security.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use Symfony\Component\Security\Core\User\UserInterface;
2525
use Symfony\Component\Security\Csrf\CsrfToken;
2626
use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface;
27+
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\BadgeInterface;
2728
use Symfony\Component\Security\Http\Event\LogoutEvent;
2829
use Symfony\Component\Security\Http\ParameterBagUtils;
2930
use Symfony\Component\Security\Http\SecurityRequestAttributes;
@@ -101,13 +102,14 @@ public function getFirewallConfig(Request $request): ?FirewallConfig
101102
}
102103

103104
/**
104-
* @param UserInterface $user The user to authenticate
105-
* @param string|null $authenticatorName The authenticator name (e.g. "form_login") or service id (e.g. SomeApiKeyAuthenticator::class) - required only if multiple authenticators are configured
106-
* @param string|null $firewallName The firewall name - required only if multiple firewalls are configured
105+
* @param UserInterface $user The user to authenticate
106+
* @param string|null $authenticatorName The authenticator name (e.g. "form_login") or service id (e.g. SomeApiKeyAuthenticator::class) - required only if multiple authenticators are configured
107+
* @param string|null $firewallName The firewall name - required only if multiple firewalls are configured
108+
* @param BadgeInterface[] $badges Badges to add to the user's passport
107109
*
108110
* @return Response|null The authenticator success response if any
109111
*/
110-
public function login(UserInterface $user, string $authenticatorName = null, string $firewallName = null): ?Response
112+
public function login(UserInterface $user, string $authenticatorName = null, string $firewallName = null, array $badges = []): ?Response
111113
{
112114
$request = $this->container->get('request_stack')->getCurrentRequest();
113115
$firewallName ??= $this->getFirewallConfig($request)?->getName();
@@ -120,7 +122,7 @@ public function login(UserInterface $user, string $authenticatorName = null, str
120122

121123
$this->container->get('security.user_checker')->checkPreAuth($user);
122124

123-
return $this->container->get('security.authenticator.managers_locator')->get($firewallName)->authenticateUser($user, $authenticator, $request);
125+
return $this->container->get('security.authenticator.managers_locator')->get($firewallName)->authenticateUser($user, $authenticator, $request, $badges);
124126
}
125127

126128
/**

0 commit comments

Comments
 (0)