Skip to content

Commit af652e4

Browse files
committed
IBX-8140: Enabled authenticator manager-based security
1 parent 680a96a commit af652e4

File tree

3 files changed

+41
-69
lines changed

3 files changed

+41
-69
lines changed

phpstan-baseline.neon

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -85,56 +85,6 @@ parameters:
8585
count: 1
8686
path: src/bundle/DependencyInjection/IbexaRestExtension.php
8787

88-
-
89-
message: "#^Method Ibexa\\\\Bundle\\\\Rest\\\\DependencyInjection\\\\Security\\\\RestSessionBasedFactory\\:\\:createEntryPoint\\(\\) has parameter \\$config with no type specified\\.$#"
90-
count: 1
91-
path: src/bundle/DependencyInjection/Security/RestSessionBasedFactory.php
92-
93-
-
94-
message: "#^Method Ibexa\\\\Bundle\\\\Rest\\\\DependencyInjection\\\\Security\\\\RestSessionBasedFactory\\:\\:createEntryPoint\\(\\) has parameter \\$container with no type specified\\.$#"
95-
count: 1
96-
path: src/bundle/DependencyInjection/Security/RestSessionBasedFactory.php
97-
98-
-
99-
message: "#^Method Ibexa\\\\Bundle\\\\Rest\\\\DependencyInjection\\\\Security\\\\RestSessionBasedFactory\\:\\:createEntryPoint\\(\\) has parameter \\$defaultEntryPoint with no type specified\\.$#"
100-
count: 1
101-
path: src/bundle/DependencyInjection/Security/RestSessionBasedFactory.php
102-
103-
-
104-
message: "#^Method Ibexa\\\\Bundle\\\\Rest\\\\DependencyInjection\\\\Security\\\\RestSessionBasedFactory\\:\\:createEntryPoint\\(\\) has parameter \\$id with no type specified\\.$#"
105-
count: 1
106-
path: src/bundle/DependencyInjection/Security/RestSessionBasedFactory.php
107-
108-
-
109-
message: "#^Method Ibexa\\\\Bundle\\\\Rest\\\\DependencyInjection\\\\Security\\\\RestSessionBasedFactory\\:\\:createListener\\(\\) has no return type specified\\.$#"
110-
count: 1
111-
path: src/bundle/DependencyInjection/Security/RestSessionBasedFactory.php
112-
113-
-
114-
message: "#^Method Ibexa\\\\Bundle\\\\Rest\\\\DependencyInjection\\\\Security\\\\RestSessionBasedFactory\\:\\:createListener\\(\\) has parameter \\$config with no type specified\\.$#"
115-
count: 1
116-
path: src/bundle/DependencyInjection/Security/RestSessionBasedFactory.php
117-
118-
-
119-
message: "#^Method Ibexa\\\\Bundle\\\\Rest\\\\DependencyInjection\\\\Security\\\\RestSessionBasedFactory\\:\\:createListener\\(\\) has parameter \\$container with no type specified\\.$#"
120-
count: 1
121-
path: src/bundle/DependencyInjection/Security/RestSessionBasedFactory.php
122-
123-
-
124-
message: "#^Method Ibexa\\\\Bundle\\\\Rest\\\\DependencyInjection\\\\Security\\\\RestSessionBasedFactory\\:\\:createListener\\(\\) has parameter \\$id with no type specified\\.$#"
125-
count: 1
126-
path: src/bundle/DependencyInjection/Security/RestSessionBasedFactory.php
127-
128-
-
129-
message: "#^Method Ibexa\\\\Bundle\\\\Rest\\\\DependencyInjection\\\\Security\\\\RestSessionBasedFactory\\:\\:createListener\\(\\) has parameter \\$userProvider with no type specified\\.$#"
130-
count: 1
131-
path: src/bundle/DependencyInjection/Security/RestSessionBasedFactory.php
132-
133-
-
134-
message: "#^Method Ibexa\\\\Bundle\\\\Rest\\\\DependencyInjection\\\\Security\\\\RestSessionBasedFactory\\:\\:isRememberMeAware\\(\\) has parameter \\$config with no type specified\\.$#"
135-
count: 1
136-
path: src/bundle/DependencyInjection/Security/RestSessionBasedFactory.php
137-
13888
-
13989
message: "#^Cannot call method isTokenValid\\(\\) on Symfony\\\\Component\\\\Security\\\\Csrf\\\\CsrfTokenManagerInterface\\|null\\.$#"
14090
count: 1
@@ -190,11 +140,6 @@ parameters:
190140
count: 1
191141
path: src/bundle/EventListener/UserCheckRequestListener.php
192142

193-
-
194-
message: "#^Method Ibexa\\\\Bundle\\\\Rest\\\\IbexaRestBundle\\:\\:build\\(\\) has no return type specified\\.$#"
195-
count: 1
196-
path: src/bundle/IbexaRestBundle.php
197-
198143
-
199144
message: "#^Method Ibexa\\\\Bundle\\\\Rest\\\\RequestParser\\\\Router\\:\\:generate\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#"
200145
count: 1

src/bundle/DependencyInjection/Security/RestSessionBasedFactory.php

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,44 @@
44
* @copyright Copyright (C) Ibexa AS. All rights reserved.
55
* @license For full copyright and license information view LICENSE file distributed with this source code.
66
*/
7+
declare(strict_types=1);
78

89
namespace Ibexa\Bundle\Rest\DependencyInjection\Security;
910

1011
use Ibexa\Rest\Server\Security\RestLogoutHandler;
1112
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\FormLoginFactory;
1213
use Symfony\Component\DependencyInjection\ChildDefinition;
14+
use Symfony\Component\DependencyInjection\ContainerBuilder;
1315
use Symfony\Component\DependencyInjection\Reference;
1416

15-
class RestSessionBasedFactory extends FormLoginFactory
17+
final class RestSessionBasedFactory extends FormLoginFactory
1618
{
1719
public function __construct()
1820
{
1921
parent::__construct();
2022
unset($this->options['check_path']);
23+
2124
$this->defaultSuccessHandlerOptions = [];
2225
$this->defaultFailureHandlerOptions = [];
2326
}
2427

25-
protected function isRememberMeAware($config)
28+
/**
29+
* @param array<mixed> $config
30+
*/
31+
protected function isRememberMeAware(array $config): bool
2632
{
2733
return false;
2834
}
2935

30-
protected function createListener($container, $id, $config, $userProvider)
31-
{
36+
/**
37+
* @param array<mixed> $config
38+
*/
39+
protected function createListener(
40+
ContainerBuilder $container,
41+
string $id,
42+
array $config,
43+
?string $userProvider
44+
): string {
3245
$listenerId = $this->getListenerId();
3346
$listener = new ChildDefinition($listenerId);
3447
$listener->replaceArgument(2, $id);
@@ -73,10 +86,24 @@ public function getKey(): string
7386
return 'ibexa_rest_session';
7487
}
7588

76-
protected function createEntryPoint($container, $id, $config, $defaultEntryPoint): ?string
77-
{
78-
return $defaultEntryPoint;
89+
/**
90+
* @param array<mixed> $config
91+
*/
92+
protected function createEntryPoint(
93+
ContainerBuilder $container,
94+
string $id,
95+
array $config,
96+
?string $defaultEntryPointId
97+
): ?string {
98+
return $defaultEntryPointId;
7999
}
80-
}
81100

82-
class_alias(RestSessionBasedFactory::class, 'EzSystems\EzPlatformRestBundle\DependencyInjection\Security\RestSessionBasedFactory');
101+
public function createAuthenticator(
102+
ContainerBuilder $container,
103+
string $firewallName,
104+
array $config,
105+
string $userProviderId
106+
): string {
107+
return parent::createAuthenticator($container, $firewallName . '__rest', $config, $userProviderId);
108+
}
109+
}

src/bundle/IbexaRestBundle.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* @copyright Copyright (C) Ibexa AS. All rights reserved.
55
* @license For full copyright and license information view LICENSE file distributed with this source code.
66
*/
7+
declare(strict_types=1);
78

89
namespace Ibexa\Bundle\Rest;
910

@@ -12,11 +13,12 @@
1213
use Symfony\Component\DependencyInjection\ContainerBuilder;
1314
use Symfony\Component\HttpKernel\Bundle\Bundle;
1415

15-
class IbexaRestBundle extends Bundle
16+
final class IbexaRestBundle extends Bundle
1617
{
17-
public function build(ContainerBuilder $container)
18+
public function build(ContainerBuilder $container): void
1819
{
1920
parent::build($container);
21+
2022
$container->addCompilerPass(new Compiler\FieldTypeProcessorPass());
2123
$container->addCompilerPass(new Compiler\InputHandlerPass());
2224
$container->addCompilerPass(new Compiler\InputParserPass());
@@ -25,12 +27,10 @@ public function build(ContainerBuilder $container)
2527

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

3032
if ($container->hasExtension('lexik_jwt_authentication')) {
3133
$container->addCompilerPass(new Compiler\LexikAuthorizationHeaderBridgePass());
3234
}
3335
}
3436
}
35-
36-
class_alias(IbexaRestBundle::class, 'EzSystems\EzPlatformRestBundle\EzPlatformRestBundle');

0 commit comments

Comments
 (0)