Skip to content

Commit

Permalink
IBX-8140: Enabled authenticator manager-based security
Browse files Browse the repository at this point in the history
  • Loading branch information
konradoboza committed May 20, 2024
1 parent 680a96a commit af652e4
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 69 deletions.
55 changes: 0 additions & 55 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -85,56 +85,6 @@ parameters:
count: 1
path: src/bundle/DependencyInjection/IbexaRestExtension.php

-
message: "#^Method Ibexa\\\\Bundle\\\\Rest\\\\DependencyInjection\\\\Security\\\\RestSessionBasedFactory\\:\\:createEntryPoint\\(\\) has parameter \\$config with no type specified\\.$#"
count: 1
path: src/bundle/DependencyInjection/Security/RestSessionBasedFactory.php

-
message: "#^Method Ibexa\\\\Bundle\\\\Rest\\\\DependencyInjection\\\\Security\\\\RestSessionBasedFactory\\:\\:createEntryPoint\\(\\) has parameter \\$container with no type specified\\.$#"
count: 1
path: src/bundle/DependencyInjection/Security/RestSessionBasedFactory.php

-
message: "#^Method Ibexa\\\\Bundle\\\\Rest\\\\DependencyInjection\\\\Security\\\\RestSessionBasedFactory\\:\\:createEntryPoint\\(\\) has parameter \\$defaultEntryPoint with no type specified\\.$#"
count: 1
path: src/bundle/DependencyInjection/Security/RestSessionBasedFactory.php

-
message: "#^Method Ibexa\\\\Bundle\\\\Rest\\\\DependencyInjection\\\\Security\\\\RestSessionBasedFactory\\:\\:createEntryPoint\\(\\) has parameter \\$id with no type specified\\.$#"
count: 1
path: src/bundle/DependencyInjection/Security/RestSessionBasedFactory.php

-
message: "#^Method Ibexa\\\\Bundle\\\\Rest\\\\DependencyInjection\\\\Security\\\\RestSessionBasedFactory\\:\\:createListener\\(\\) has no return type specified\\.$#"
count: 1
path: src/bundle/DependencyInjection/Security/RestSessionBasedFactory.php

-
message: "#^Method Ibexa\\\\Bundle\\\\Rest\\\\DependencyInjection\\\\Security\\\\RestSessionBasedFactory\\:\\:createListener\\(\\) has parameter \\$config with no type specified\\.$#"
count: 1
path: src/bundle/DependencyInjection/Security/RestSessionBasedFactory.php

-
message: "#^Method Ibexa\\\\Bundle\\\\Rest\\\\DependencyInjection\\\\Security\\\\RestSessionBasedFactory\\:\\:createListener\\(\\) has parameter \\$container with no type specified\\.$#"
count: 1
path: src/bundle/DependencyInjection/Security/RestSessionBasedFactory.php

-
message: "#^Method Ibexa\\\\Bundle\\\\Rest\\\\DependencyInjection\\\\Security\\\\RestSessionBasedFactory\\:\\:createListener\\(\\) has parameter \\$id with no type specified\\.$#"
count: 1
path: src/bundle/DependencyInjection/Security/RestSessionBasedFactory.php

-
message: "#^Method Ibexa\\\\Bundle\\\\Rest\\\\DependencyInjection\\\\Security\\\\RestSessionBasedFactory\\:\\:createListener\\(\\) has parameter \\$userProvider with no type specified\\.$#"
count: 1
path: src/bundle/DependencyInjection/Security/RestSessionBasedFactory.php

-
message: "#^Method Ibexa\\\\Bundle\\\\Rest\\\\DependencyInjection\\\\Security\\\\RestSessionBasedFactory\\:\\:isRememberMeAware\\(\\) has parameter \\$config with no type specified\\.$#"
count: 1
path: src/bundle/DependencyInjection/Security/RestSessionBasedFactory.php

-
message: "#^Cannot call method isTokenValid\\(\\) on Symfony\\\\Component\\\\Security\\\\Csrf\\\\CsrfTokenManagerInterface\\|null\\.$#"
count: 1
Expand Down Expand Up @@ -190,11 +140,6 @@ parameters:
count: 1
path: src/bundle/EventListener/UserCheckRequestListener.php

-
message: "#^Method Ibexa\\\\Bundle\\\\Rest\\\\IbexaRestBundle\\:\\:build\\(\\) has no return type specified\\.$#"
count: 1
path: src/bundle/IbexaRestBundle.php

-
message: "#^Method Ibexa\\\\Bundle\\\\Rest\\\\RequestParser\\\\Router\\:\\:generate\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#"
count: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,44 @@
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\Bundle\Rest\DependencyInjection\Security;

use Ibexa\Rest\Server\Security\RestLogoutHandler;
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\FormLoginFactory;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;

class RestSessionBasedFactory extends FormLoginFactory
final class RestSessionBasedFactory extends FormLoginFactory
{
public function __construct()
{
parent::__construct();
unset($this->options['check_path']);

$this->defaultSuccessHandlerOptions = [];
$this->defaultFailureHandlerOptions = [];
}

protected function isRememberMeAware($config)
/**
* @param array<mixed> $config
*/
protected function isRememberMeAware(array $config): bool
{
return false;
}

protected function createListener($container, $id, $config, $userProvider)
{
/**
* @param array<mixed> $config
*/
protected function createListener(
ContainerBuilder $container,
string $id,
array $config,
?string $userProvider
): string {
$listenerId = $this->getListenerId();
$listener = new ChildDefinition($listenerId);
$listener->replaceArgument(2, $id);
Expand Down Expand Up @@ -73,10 +86,24 @@ public function getKey(): string
return 'ibexa_rest_session';
}

protected function createEntryPoint($container, $id, $config, $defaultEntryPoint): ?string
{
return $defaultEntryPoint;
/**
* @param array<mixed> $config
*/
protected function createEntryPoint(
ContainerBuilder $container,
string $id,
array $config,
?string $defaultEntryPointId
): ?string {
return $defaultEntryPointId;
}
}

class_alias(RestSessionBasedFactory::class, 'EzSystems\EzPlatformRestBundle\DependencyInjection\Security\RestSessionBasedFactory');
public function createAuthenticator(
ContainerBuilder $container,
string $firewallName,
array $config,
string $userProviderId
): string {
return parent::createAuthenticator($container, $firewallName . '__rest', $config, $userProviderId);
}
}
10 changes: 5 additions & 5 deletions src/bundle/IbexaRestBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\Bundle\Rest;

Expand All @@ -12,11 +13,12 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class IbexaRestBundle extends Bundle
final class IbexaRestBundle extends Bundle
{
public function build(ContainerBuilder $container)
public function build(ContainerBuilder $container): void
{
parent::build($container);

$container->addCompilerPass(new Compiler\FieldTypeProcessorPass());
$container->addCompilerPass(new Compiler\InputHandlerPass());
$container->addCompilerPass(new Compiler\InputParserPass());
Expand All @@ -25,12 +27,10 @@ public function build(ContainerBuilder $container)

/** @var \Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension $securityExtension */
$securityExtension = $container->getExtension('security');
$securityExtension->addSecurityListenerFactory(new RestSessionBasedFactory());
$securityExtension->addAuthenticatorFactory(new RestSessionBasedFactory());

if ($container->hasExtension('lexik_jwt_authentication')) {
$container->addCompilerPass(new Compiler\LexikAuthorizationHeaderBridgePass());
}
}
}

class_alias(IbexaRestBundle::class, 'EzSystems\EzPlatformRestBundle\EzPlatformRestBundle');

0 comments on commit af652e4

Please sign in to comment.