Skip to content

Commit

Permalink
cr remarks
Browse files Browse the repository at this point in the history
  • Loading branch information
konradoboza committed May 20, 2024
1 parent edce935 commit ceceb3f
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 101 deletions.
5 changes: 0 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -46965,11 +46965,6 @@ parameters:
count: 1
path: tests/lib/MVC/Symfony/Routing/UrlAliasRouterTest.php

-
message: "#^Method Ibexa\\\\Tests\\\\Core\\\\MVC\\\\Symfony\\\\Security\\\\Authentication\\\\DefaultAuthenticationSuccessHandlerTest\\:\\:testSetConfigResolver\\(\\) has no return type specified\\.$#"
count: 1
path: tests/lib/MVC/Symfony/Security/Authentication/DefaultAuthenticationSuccessHandlerTest.php

-
message: "#^Call to an undefined method Symfony\\\\Component\\\\Security\\\\Core\\\\Authentication\\\\Token\\\\TokenInterface\\:\\:getProviderKey\\(\\)\\.$#"
count: 1
Expand Down
21 changes: 0 additions & 21 deletions src/bundle/Core/DependencyInjection/Compiler/SecurityPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
namespace Ibexa\Bundle\Core\DependencyInjection\Compiler;

use Ibexa\Contracts\Core\Repository\PermissionResolver;
use Ibexa\Core\MVC\Symfony\Security\Authentication\DefaultAuthenticationSuccessHandler;
use Ibexa\Core\MVC\Symfony\Security\Authentication\GuardRepositoryAuthenticationProvider;
use Ibexa\Core\MVC\Symfony\Security\Authentication\RememberMeRepositoryAuthenticationProvider;
use Ibexa\Core\MVC\Symfony\Security\HttpUtils;
Expand Down Expand Up @@ -36,7 +35,6 @@ public function process(ContainerBuilder $container): void
return;
}

$configResolverRef = new Reference('ibexa.config.resolver');
$permissionResolverRef = new Reference(PermissionResolver::class);

$rememberMeAuthenticationProviderDef = $container->findDefinition('security.authentication.provider.rememberme');
Expand All @@ -63,24 +61,5 @@ public function process(ContainerBuilder $container): void
'setSiteAccess',
[new Reference(SiteAccess::class)]
);

if (!$container->hasDefinition('security.authentication.success_handler')) {
return;
}

$successHandlerDef = $container->getDefinition('security.authentication.success_handler');
$successHandlerDef->setClass(DefaultAuthenticationSuccessHandler::class);
$successHandlerDef->addMethodCall(
'setConfigResolver',
[$configResolverRef]
);
$successHandlerDef->addMethodCall(
'setEventDispatcher',
[new Reference('event_dispatcher')]
);
$successHandlerDef->addMethodCall(
'setPermissionResolver',
[$permissionResolverRef]
);
}
}
8 changes: 8 additions & 0 deletions src/bundle/Core/Resources/config/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,11 @@ services:
Ibexa\Core\MVC\Symfony\Security\Authentication\EventSubscriber\AccessDeniedSubscriber:
autowire: true
autoconfigure: true

Ibexa\Core\MVC\Symfony\Security\Authentication\DefaultAuthenticationSuccessHandler:
autowire: true
autoconfigure: true
abstract: true
decorates: security.authentication.success_handler
arguments:
$innerHandler: '@.inner'
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@

final class DefaultAuthenticationSuccessHandler extends BaseSuccessHandler
{
private EventDispatcherInterface $eventDispatcher;

private ConfigResolverInterface $configResolver;

private PermissionResolver $permissionResolver;
public function __construct(
private readonly BaseSuccessHandler $innerHandler,
private EventDispatcherInterface $eventDispatcher,
private ConfigResolverInterface $configResolver,
private PermissionResolver $permissionResolver,
) {
}

/**
* Injects the ConfigResolver to potentially override default_target_path for redirections after authentication success.
Expand All @@ -50,7 +52,7 @@ public function onAuthenticationSuccess(Request $request, TokenInterface $token)
$this->permissionResolver->setCurrentUserReference($user->getAPIUser());
}

return parent::onAuthenticationSuccess($request, $token);
return $this->innerHandler->onAuthenticationSuccess($request, $token);
}

protected function determineTargetUrl(Request $request): string
Expand All @@ -74,6 +76,6 @@ protected function determineTargetUrl(Request $request): string
$this->options = $event->getOptions();
}

return parent::determineTargetUrl($request);
return $this->innerHandler->determineTargetUrl($request);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;

final class AccessDeniedSubscriber implements EventSubscriberInterface
final readonly class AccessDeniedSubscriber implements EventSubscriberInterface
{
public function __construct(private UrlGeneratorInterface $urlGenerator)
{
Expand Down

This file was deleted.

0 comments on commit ceceb3f

Please sign in to comment.