$request->attributes->
set('_pre_authenticated_username',
$username);
return true;
} public function authenticate(Request
$request): Passport
{ $userBadge =
new UserBadge($request->attributes->
get('_pre_authenticated_username'
),
$this->userProvider->
loadUserByIdentifier(...
));
return new SelfValidatingPassport($userBadge,
[new PreAuthenticatedUserBadge()]);
} public function createToken(Passport
$passport, string
$firewallName): TokenInterface
{ return new PreAuthenticatedToken($passport->
getUser(),
$firewallName,
$passport->
getUser()->
getRoles());
} public function onAuthenticationSuccess(Request
$request, TokenInterface
$token, string
$firewallName): ?Response
{ return null; // let the original request continue
}