Skip to content

Commit

Permalink
SUPPORT-91253: code review fix
Browse files Browse the repository at this point in the history
  • Loading branch information
maruf-paysera committed Mar 6, 2024
1 parent da565ea commit 0bb3524
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
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
{
public function createAuthenticator(ContainerBuilder $container, string $firewallName, array $config, string $userProviderId): string
{
$authenticatorId = 'security.authentication.provider.bearer.' . $firewallName;

$authenticator = (new ChildDefinition('paysera_bearer_authentication.authenticator.bearer_passport'));
$authenticator = (new ChildDefinition(BearerPassportAuthenticator::class));

$container->setDefinition($authenticatorId, $authenticator);

Expand Down
3 changes: 1 addition & 2 deletions src/Resources/config/services/security.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
<tag name="security.voter"/>
</service>

<service id="paysera_bearer_authentication.authenticator.bearer_passport"
class="Paysera\BearerAuthenticationBundle\Security\BearerPassportAuthenticator">
<service id="Paysera\BearerAuthenticationBundle\Security\BearerPassportAuthenticator">
<argument type="service" id="security.authentication.manager"/>
<argument type="service" id="security.token_storage"/>
<argument type="service" id="logger"/>
Expand Down
3 changes: 0 additions & 3 deletions src/Security/Provider/BearerProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Security/Voter/BearerVoter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 0bb3524

Please sign in to comment.