Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-8140: Enabled authenticator manager-based security #90

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
Loading