From 0bb352422a28fd6ab64ba2d82265126c660d6e01 Mon Sep 17 00:00:00 2001 From: Maruf Alom Date: Wed, 6 Mar 2024 16:08:00 +0600 Subject: [PATCH] SUPPORT-91253: code review fix --- CHANGELOG.md | 1 + .../Security/Factory/BearerAuthenticatorFactory.php | 3 ++- src/Resources/config/services/security.xml | 3 +-- src/Security/Provider/BearerProvider.php | 3 --- src/Security/Voter/BearerVoter.php | 2 +- 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 46aac9d..0b48f5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Dropped support for PHP 5.5 and Symfony 2.x and 3.x - Renamed Paysera\BearerAuthenticationBundle\DependencyInjection\Security\Factory\BearerFactory to Paysera\BearerAuthenticationBundle\DependencyInjection\Security\Factory\BearerSecurityFactory - Added Paysera\BearerAuthenticationBundle\DependencyInjection\Security\Factory\BearerAuthenticatorFactory for Symfony 5 +- Changed src/Security/Authentication/Token/BearerTokenInterface::getToken(), added return type ## 1.0.2 ### Added diff --git a/src/DependencyInjection/Security/Factory/BearerAuthenticatorFactory.php b/src/DependencyInjection/Security/Factory/BearerAuthenticatorFactory.php index d2ca690..803f05d 100644 --- a/src/DependencyInjection/Security/Factory/BearerAuthenticatorFactory.php +++ b/src/DependencyInjection/Security/Factory/BearerAuthenticatorFactory.php @@ -8,6 +8,7 @@ use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\Config\Definition\Builder\NodeDefinition; +use Paysera\BearerAuthenticationBundle\Security\BearerPassportAuthenticator; class BearerAuthenticatorFactory implements AuthenticatorFactoryInterface { @@ -15,7 +16,7 @@ public function createAuthenticator(ContainerBuilder $container, string $firewal { $authenticatorId = 'security.authentication.provider.bearer.' . $firewallName; - $authenticator = (new ChildDefinition('paysera_bearer_authentication.authenticator.bearer_passport')); + $authenticator = (new ChildDefinition(BearerPassportAuthenticator::class)); $container->setDefinition($authenticatorId, $authenticator); diff --git a/src/Resources/config/services/security.xml b/src/Resources/config/services/security.xml index 035893a..25b2a67 100644 --- a/src/Resources/config/services/security.xml +++ b/src/Resources/config/services/security.xml @@ -20,8 +20,7 @@ - + diff --git a/src/Security/Provider/BearerProvider.php b/src/Security/Provider/BearerProvider.php index 6c975ea..1a06325 100644 --- a/src/Security/Provider/BearerProvider.php +++ b/src/Security/Provider/BearerProvider.php @@ -12,9 +12,6 @@ use Symfony\Component\Security\Core\Exception\AuthenticationException; use Symfony\Component\Security\Core\User\UserProviderInterface; -/** - * @deprecated since symfony 5.3.x - */ class BearerProvider implements AuthenticationProviderInterface { private UserProviderInterface $userProvider; diff --git a/src/Security/Voter/BearerVoter.php b/src/Security/Voter/BearerVoter.php index 2392a4e..948164c 100644 --- a/src/Security/Voter/BearerVoter.php +++ b/src/Security/Voter/BearerVoter.php @@ -32,7 +32,7 @@ public function vote(TokenInterface $token, $subject, array $attributes): int /** @var UserInterface $user */ $user = $token->getUser(); - if ($user instanceof BearerUserInterface && $token->getUser() !== null) { + if ($user instanceof BearerUserInterface && $token->isAuthenticated() !== null) { return VoterInterface::ACCESS_GRANTED; }