[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /* 4 * This file is part of the Symfony package. 5 * 6 * (c) Fabien Potencier <[email protected]> 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12 namespace Symfony\Component\Ldap\Security; 13 14 use Symfony\Component\HttpFoundation\Request; 15 use Symfony\Component\HttpFoundation\Response; 16 use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; 17 use Symfony\Component\Security\Core\Exception\AuthenticationException; 18 use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface; 19 use Symfony\Component\Security\Http\Authenticator\InteractiveAuthenticatorInterface; 20 use Symfony\Component\Security\Http\Authenticator\Passport\Passport; 21 use Symfony\Component\Security\Http\Authenticator\Passport\PassportInterface; 22 use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface; 23 use Symfony\Component\Security\Http\EntryPoint\Exception\NotAnEntryPointException; 24 25 /** 26 * This class decorates internal authenticators to add the LDAP integration. 27 * 28 * In your own authenticators, it is recommended to directly use the 29 * LdapBadge in the authenticate() method. This class should only be 30 * used for Symfony or third party authenticators. 31 * 32 * @author Wouter de Jong <[email protected]> 33 * 34 * @final 35 */ 36 class LdapAuthenticator implements AuthenticationEntryPointInterface, InteractiveAuthenticatorInterface 37 { 38 private $authenticator; 39 private $ldapServiceId; 40 private $dnString; 41 private $searchDn; 42 private $searchPassword; 43 private $queryString; 44 45 public function __construct(AuthenticatorInterface $authenticator, string $ldapServiceId, string $dnString = '{username}', string $searchDn = '', string $searchPassword = '', string $queryString = '') 46 { 47 $this->authenticator = $authenticator; 48 $this->ldapServiceId = $ldapServiceId; 49 $this->dnString = $dnString; 50 $this->searchDn = $searchDn; 51 $this->searchPassword = $searchPassword; 52 $this->queryString = $queryString; 53 } 54 55 public function supports(Request $request): ?bool 56 { 57 return $this->authenticator->supports($request); 58 } 59 60 public function authenticate(Request $request): Passport 61 { 62 $passport = $this->authenticator->authenticate($request); 63 $passport->addBadge(new LdapBadge($this->ldapServiceId, $this->dnString, $this->searchDn, $this->searchPassword, $this->queryString)); 64 65 return $passport; 66 } 67 68 /** 69 * @deprecated since Symfony 5.4, use {@link createToken()} instead 70 */ 71 public function createAuthenticatedToken(PassportInterface $passport, string $firewallName): TokenInterface 72 { 73 trigger_deprecation('symfony/ldap', '5.4', 'Method "%s()" is deprecated, use "%s::createToken()" instead.', __METHOD__, __CLASS__); 74 75 return $this->createToken($passport, $firewallName); 76 } 77 78 public function createToken(Passport $passport, string $firewallName): TokenInterface 79 { 80 // @deprecated since Symfony 5.4, in 6.0 change to: 81 // return $this->authenticator->createToken($passport, $firewallName); 82 return method_exists($this->authenticator, 'createToken') 83 ? $this->authenticator->createToken($passport, $firewallName) 84 : $this->authenticator->createAuthenticatedToken($passport, $firewallName); 85 } 86 87 public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $firewallName): ?Response 88 { 89 return $this->authenticator->onAuthenticationSuccess($request, $token, $firewallName); 90 } 91 92 public function onAuthenticationFailure(Request $request, AuthenticationException $exception): ?Response 93 { 94 return $this->authenticator->onAuthenticationFailure($request, $exception); 95 } 96 97 public function start(Request $request, AuthenticationException $authException = null): Response 98 { 99 if (!$this->authenticator instanceof AuthenticationEntryPointInterface) { 100 throw new NotAnEntryPointException(sprintf('Decorated authenticator "%s" does not implement interface "%s".', get_debug_type($this->authenticator), AuthenticationEntryPointInterface::class)); 101 } 102 103 return $this->authenticator->start($request, $authException); 104 } 105 106 public function isInteractive(): bool 107 { 108 if ($this->authenticator instanceof InteractiveAuthenticatorInterface) { 109 return $this->authenticator->isInteractive(); 110 } 111 112 return false; 113 } 114 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |