|
16 | 16 | use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
17 | 17 | use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
18 | 18 | use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface;
|
| 19 | +use Symfony\Component\Security\Http\Authenticator\Passport\Passport; |
19 | 20 | use Symfony\Component\Security\Http\Authenticator\Passport\PassportInterface;
|
20 | 21 |
|
21 | 22 | /**
|
@@ -53,17 +54,31 @@ public function supports(Request $request): ?bool
|
53 | 54 | return $this->authenticator->supports($request);
|
54 | 55 | }
|
55 | 56 |
|
56 |
| - public function authenticate(Request $request): PassportInterface |
| 57 | + public function authenticate(Request $request): Passport |
57 | 58 | {
|
58 | 59 | $passport = $this->authenticator->authenticate($request);
|
59 | 60 | $passport->addBadge(new LdapBadge($this->ldapServiceId, $this->dnString, $this->searchDn, $this->searchPassword, $this->queryString));
|
60 | 61 |
|
61 | 62 | return $passport;
|
62 | 63 | }
|
63 | 64 |
|
| 65 | + /** |
| 66 | + * @deprecated since Symfony 5.4, use {@link createToken()} instead |
| 67 | + */ |
64 | 68 | public function createAuthenticatedToken(PassportInterface $passport, string $firewallName): TokenInterface
|
65 | 69 | {
|
66 |
| - return $this->authenticator->createAuthenticatedToken($passport, $firewallName); |
| 70 | + trigger_deprecation('symfony/ldap', '5.4', 'Method "%s()" is deprecated, use "%s::createToken()" instead.', __METHOD__, __CLASS__); |
| 71 | + |
| 72 | + return $this->createToken($passport, $firewallName); |
| 73 | + } |
| 74 | + |
| 75 | + public function createToken(PassportInterface $passport, string $firewallName): TokenInterface |
| 76 | + { |
| 77 | + // @deprecated since Symfony 5.4, in 6.0 change to: |
| 78 | + // return $this->authenticator->createToken($passport, $firewallName); |
| 79 | + return method_exists($this->authenticator, 'createToken') |
| 80 | + ? $this->authenticator->createToken($passport, $firewallName) |
| 81 | + : $this->authenticator->createAuthenticatedToken($passport, $firewallName); |
67 | 82 | }
|
68 | 83 |
|
69 | 84 | public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $firewallName): ?Response
|
|
0 commit comments