Skip to content

Commit 3f74921

Browse files
committed
[Security] Deprecate PassportInterface
1 parent 2b98291 commit 3f74921

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

Security/LdapAuthenticator.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
1717
use Symfony\Component\Security\Core\Exception\AuthenticationException;
1818
use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface;
19+
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
1920
use Symfony\Component\Security\Http\Authenticator\Passport\PassportInterface;
2021

2122
/**
@@ -53,17 +54,31 @@ public function supports(Request $request): ?bool
5354
return $this->authenticator->supports($request);
5455
}
5556

56-
public function authenticate(Request $request): PassportInterface
57+
public function authenticate(Request $request): Passport
5758
{
5859
$passport = $this->authenticator->authenticate($request);
5960
$passport->addBadge(new LdapBadge($this->ldapServiceId, $this->dnString, $this->searchDn, $this->searchPassword, $this->queryString));
6061

6162
return $passport;
6263
}
6364

65+
/**
66+
* @deprecated since Symfony 5.4, use {@link createToken()} instead
67+
*/
6468
public function createAuthenticatedToken(PassportInterface $passport, string $firewallName): TokenInterface
6569
{
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);
6782
}
6883

6984
public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $firewallName): ?Response

0 commit comments

Comments
 (0)