2021-02-05 14:47:54 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace RetailCrm\ServiceBundle\Security;
|
|
|
|
|
|
|
|
use Symfony\Component\HttpFoundation\Request;
|
2022-07-19 16:27:00 +03:00
|
|
|
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
|
2021-02-05 14:47:54 +03:00
|
|
|
|
|
|
|
class CallbackClientAuthenticator extends AbstractClientAuthenticator
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* {@inheritdoc }
|
|
|
|
*/
|
|
|
|
public function supports(Request $request): bool
|
|
|
|
{
|
|
|
|
return $request->request->has(static::AUTH_FIELD) || $request->query->has(static::AUTH_FIELD);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc }
|
|
|
|
*/
|
|
|
|
public function supportsRememberMe(): bool
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2022-07-19 16:27:00 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc }
|
|
|
|
*/
|
|
|
|
public function authenticate(Request $request): Passport
|
|
|
|
{
|
|
|
|
$identifier = $request->request->get(static::AUTH_FIELD);
|
|
|
|
|
|
|
|
return new SelfValidatingPassport(
|
|
|
|
new UserBadge($identifier, function ($userIdentifier) {
|
|
|
|
return $this->repository->findByIdentifier($userIdentifier);
|
|
|
|
}),
|
|
|
|
[]
|
|
|
|
);
|
|
|
|
}
|
2021-02-05 14:47:54 +03:00
|
|
|
}
|