ConcreteAuthenticator example

use Symfony\Component\Security\Core\User\InMemoryUser;
use Symfony\Component\Security\Http\Authenticator\AbstractAuthenticator;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
use Symfony\Component\Security\Http\Authenticator\Passport\SelfValidatingPassport;
use Symfony\Component\Security\Http\Authenticator\Token\PostAuthenticationToken;

class AbstractAuthenticatorTest extends TestCase
{
    public function testCreateToken()
    {
        $authenticator = new ConcreteAuthenticator();
        $this->assertInstanceOf(
            PostAuthenticationToken::class,
            $authenticator->createToken(new SelfValidatingPassport(new UserBadge('dummy', fn () => new InMemoryUser('robin', 'hood'))), 'dummy')
        );
    }
}

class ConcreteAuthenticator extends AbstractAuthenticator
{
    public function createToken(Passport $passport, string $firewallName): TokenInterface
    {
        
Home | Imprint | This part of the site doesn't use cookies.