LdapBadge example

$listener = $this->createListener();
        $listener->onCheckPassport(new CheckPassportEvent($authenticator$passport));
    }

    public static function provideShouldNotCheckPassport()
    {
        // no LdapBadge         yield [new TestAuthenticator()new Passport(new UserBadge('test')new PasswordCredentials('s3cret'))];

        // ldap already resolved         $badge = new LdapBadge('app.ldap');
        $badge->markResolved();
        yield [new TestAuthenticator()new Passport(new UserBadge('test')new PasswordCredentials('s3cret')[$badge])];
    }

    public function testPasswordCredentialsAlreadyResolvedThrowsException()
    {
        $this->expectException(\LogicException::class);
        $this->expectExceptionMessage('LDAP authentication password verification cannot be completed because something else has already resolved the PasswordCredentials.');

        $badge = new PasswordCredentials('s3cret');
        $badge->markResolved();
        
$this->queryString = $queryString;
    }

    public function supports(Request $request): ?bool
    {
        return $this->authenticator->supports($request);
    }

    public function authenticate(Request $request): Passport
    {
        $passport = $this->authenticator->authenticate($request);
        $passport->addBadge(new LdapBadge($this->ldapServiceId, $this->dnString, $this->searchDn, $this->searchPassword, $this->queryString));

        return $passport;
    }

    /** * @internal */
    public function createAuthenticatedToken(PassportInterface $passport, string $firewallName): TokenInterface
    {
        throw new \BadMethodCallException(sprintf('The "%s()" method cannot be called.', __METHOD__));
    }

    
Home | Imprint | This part of the site doesn't use cookies.