Skip to content

Commit 42b6c2c

Browse files
mccarMakar Sichevoi
andauthored
feat: Update Symfony for Scoring and Reports applications (#72)
* feat: Update Symfony for Scoring and Reports applications --------- Co-authored-by: Makar Sichevoi <[email protected]>
1 parent b0833c0 commit 42b6c2c

File tree

40 files changed

+576
-676
lines changed

40 files changed

+576
-676
lines changed

.github/workflows/build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
php: [ 8.0, 8.1, 8.2, 8.3 ]
16+
php: [ 8.1, 8.2, 8.3 ]
1717
extra-composer-params: [ "" ]
1818
include:
1919
- php: 8.3

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
CHANGELOG
22
=========
33

4+
8.0.0
5+
-----
6+
* Upgrade symfony to v6.4
7+
48
6.1.2
59
-----
610

DependencyInjection/Security/Factory/Message/LtiPlatformMessageSecurityFactory.php

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,52 +22,57 @@
2222

2323
namespace OAT\Bundle\Lti1p3Bundle\DependencyInjection\Security\Factory\Message;
2424

25-
use OAT\Bundle\Lti1p3Bundle\Security\Authentication\Provider\Message\LtiPlatformMessageAuthenticationProvider;
26-
use OAT\Bundle\Lti1p3Bundle\Security\Firewall\Message\LtiPlatformMessageAuthenticationListener;
25+
use OAT\Bundle\Lti1p3Bundle\Security\Firewall\Message\LtiPlatformMessageAuthenticator;
2726
use OAT\Library\Lti1p3Core\Message\Launch\Validator\Platform\PlatformLaunchValidatorInterface;
28-
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SecurityFactoryInterface;
27+
use Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface;
28+
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AuthenticatorFactoryInterface;
2929
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
30-
use Symfony\Component\DependencyInjection\ChildDefinition;
3130
use Symfony\Component\DependencyInjection\ContainerBuilder;
3231
use Symfony\Component\DependencyInjection\Definition;
3332
use Symfony\Component\DependencyInjection\Reference;
3433

35-
class LtiPlatformMessageSecurityFactory implements SecurityFactoryInterface
34+
class LtiPlatformMessageSecurityFactory implements AuthenticatorFactoryInterface
3635
{
37-
public function getPosition(): string
36+
public const PRIORITY = -10;
37+
38+
public function getPriority(): int
3839
{
39-
return 'pre_auth';
40+
return self::PRIORITY;
4041
}
4142

4243
public function getKey(): string
4344
{
4445
return 'lti1p3_message_platform';
4546
}
46-
47-
public function create(
47+
/**
48+
* Creates the authenticator service(s) for the provided configuration.
49+
*
50+
* @param array<string, mixed> $config
51+
*
52+
* @return string|string[] The authenticator service ID(s) to be used by the firewall
53+
*/
54+
public function createAuthenticator(
4855
ContainerBuilder $container,
49-
$id,
50-
$config,
51-
$userProvider,
52-
$defaultEntryPoint = null
53-
) {
54-
$providerId = sprintf('security.authentication.provider.%s.%s', $this->getKey(), $id);
55-
$providerDefinition = new Definition(LtiPlatformMessageAuthenticationProvider::class);
56-
$providerDefinition
56+
string $firewallName,
57+
array $config,
58+
string $userProviderId
59+
): array|string {
60+
$authenticatorId = sprintf('security.authenticator.%s.%s', $this->getKey(), $firewallName);
61+
$authenticatorDefinition = new Definition(LtiPlatformMessageAuthenticator::class);
62+
$authenticatorDefinition
5763
->setShared(false)
5864
->setArguments(
5965
[
66+
new Reference('security.firewall.map'),
67+
new Reference(HttpMessageFactoryInterface::class),
6068
new Reference(PlatformLaunchValidatorInterface::class),
61-
$id,
69+
$firewallName,
6270
$config['types'] ?? []
6371
]
6472
);
65-
$container->setDefinition($providerId, $providerDefinition);
66-
67-
$listenerId = sprintf('security.authentication.listener.%s.%s', $this->getKey(), $id);
68-
$container->setDefinition($listenerId, new ChildDefinition(LtiPlatformMessageAuthenticationListener::class));
73+
$container->setDefinition($authenticatorId, $authenticatorDefinition);
6974

70-
return [$providerId, $listenerId, $defaultEntryPoint];
75+
return $authenticatorId;
7176
}
7277

7378
public function addConfiguration(NodeDefinition $node): void

DependencyInjection/Security/Factory/Message/LtiToolMessageSecurityFactory.php

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,52 +22,53 @@
2222

2323
namespace OAT\Bundle\Lti1p3Bundle\DependencyInjection\Security\Factory\Message;
2424

25-
use OAT\Bundle\Lti1p3Bundle\Security\Authentication\Provider\Message\LtiToolMessageAuthenticationProvider;
26-
use OAT\Bundle\Lti1p3Bundle\Security\Firewall\Message\LtiToolMessageAuthenticationListener;
25+
use OAT\Bundle\Lti1p3Bundle\Security\Exception\LtiToolMessageExceptionHandlerInterface;
26+
use OAT\Bundle\Lti1p3Bundle\Security\Firewall\Message\LtiToolMessageAuthenticator;
2727
use OAT\Library\Lti1p3Core\Message\Launch\Validator\Tool\ToolLaunchValidatorInterface;
28-
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SecurityFactoryInterface;
28+
use Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface;
29+
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AuthenticatorFactoryInterface;
2930
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
30-
use Symfony\Component\DependencyInjection\ChildDefinition;
3131
use Symfony\Component\DependencyInjection\ContainerBuilder;
3232
use Symfony\Component\DependencyInjection\Definition;
3333
use Symfony\Component\DependencyInjection\Reference;
3434

35-
class LtiToolMessageSecurityFactory implements SecurityFactoryInterface
35+
class LtiToolMessageSecurityFactory implements AuthenticatorFactoryInterface
3636
{
37-
public function getPosition(): string
37+
public const PRIORITY = -10;
38+
39+
public function getPriority(): int
3840
{
39-
return 'pre_auth';
41+
return self::PRIORITY;
4042
}
4143

4244
public function getKey(): string
4345
{
4446
return 'lti1p3_message_tool';
4547
}
4648

47-
public function create(
49+
public function createAuthenticator(
4850
ContainerBuilder $container,
49-
$id,
50-
$config,
51-
$userProvider,
52-
$defaultEntryPoint = null
53-
) {
54-
$providerId = sprintf('security.authentication.provider.%s.%s', $this->getKey(), $id);
55-
$providerDefinition = new Definition(LtiToolMessageAuthenticationProvider::class);
56-
$providerDefinition
51+
string $firewallName,
52+
array $config,
53+
string $userProviderId
54+
): array|string {
55+
$authenticatorId = sprintf('security.authenticator.%s.%s', $this->getKey(), $firewallName);
56+
$authenticatorDefinition = new Definition(LtiToolMessageAuthenticator::class);
57+
$authenticatorDefinition
5758
->setShared(false)
5859
->setArguments(
5960
[
61+
new Reference('security.firewall.map'),
62+
new Reference(HttpMessageFactoryInterface::class),
63+
new Reference(LtiToolMessageExceptionHandlerInterface::class),
6064
new Reference(ToolLaunchValidatorInterface::class),
61-
$id,
65+
$firewallName,
6266
$config['types'] ?? []
6367
]
6468
);
65-
$container->setDefinition($providerId, $providerDefinition);
66-
67-
$listenerId = sprintf('security.authentication.listener.%s.%s', $this->getKey(), $id);
68-
$container->setDefinition($listenerId, new ChildDefinition(LtiToolMessageAuthenticationListener::class));
69+
$container->setDefinition($authenticatorId, $authenticatorDefinition);
6970

70-
return [$providerId, $listenerId, $defaultEntryPoint];
71+
return $authenticatorId;
7172
}
7273

7374
public function addConfiguration(NodeDefinition $node): void

DependencyInjection/Security/Factory/Service/LtiServiceSecurityFactory.php

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,52 +22,51 @@
2222

2323
namespace OAT\Bundle\Lti1p3Bundle\DependencyInjection\Security\Factory\Service;
2424

25-
use OAT\Bundle\Lti1p3Bundle\Security\Authentication\Provider\Service\LtiServiceAuthenticationProvider;
26-
use OAT\Bundle\Lti1p3Bundle\Security\Firewall\Service\LtiServiceAuthenticationListener;
25+
use OAT\Bundle\Lti1p3Bundle\Security\Firewall\Service\LtiServiceAuthenticator;
2726
use OAT\Library\Lti1p3Core\Security\OAuth2\Validator\RequestAccessTokenValidatorInterface;
28-
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SecurityFactoryInterface;
27+
use Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface;
28+
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AuthenticatorFactoryInterface;
2929
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
30-
use Symfony\Component\DependencyInjection\ChildDefinition;
3130
use Symfony\Component\DependencyInjection\ContainerBuilder;
3231
use Symfony\Component\DependencyInjection\Definition;
3332
use Symfony\Component\DependencyInjection\Reference;
3433

35-
class LtiServiceSecurityFactory implements SecurityFactoryInterface
34+
class LtiServiceSecurityFactory implements AuthenticatorFactoryInterface
3635
{
37-
public function getPosition(): string
36+
public const PRIORITY = -10;
37+
38+
public function getPriority(): int
3839
{
39-
return 'pre_auth';
40+
return self::PRIORITY;
4041
}
4142

4243
public function getKey(): string
4344
{
4445
return 'lti1p3_service';
4546
}
4647

47-
public function create(
48+
public function createAuthenticator(
4849
ContainerBuilder $container,
49-
$id,
50-
$config,
51-
$userProvider,
52-
$defaultEntryPoint = null
53-
) {
54-
$providerId = sprintf('security.authentication.provider.%s.%s', $this->getKey(), $id);
55-
$providerDefinition = new Definition(LtiServiceAuthenticationProvider::class);
56-
$providerDefinition
50+
string $firewallName,
51+
array $config,
52+
string $userProviderId
53+
): array|string {
54+
$authenticatorId = sprintf('security.authenticator.%s.%s', $this->getKey(), $firewallName);
55+
$authenticatorDefinition = new Definition(LtiServiceAuthenticator::class);
56+
$authenticatorDefinition
5757
->setShared(false)
5858
->setArguments(
5959
[
60+
new Reference('security.firewall.map'),
61+
new Reference(HttpMessageFactoryInterface::class),
6062
new Reference(RequestAccessTokenValidatorInterface::class),
61-
$id,
63+
$firewallName,
6264
$config['scopes'] ?? []
6365
]
6466
);
65-
$container->setDefinition($providerId, $providerDefinition);
66-
67-
$listenerId = sprintf('security.authentication.listener.%s.%s', $this->getKey(), $id);
68-
$container->setDefinition($listenerId, new ChildDefinition(LtiServiceAuthenticationListener::class));
67+
$container->setDefinition($authenticatorId, $authenticatorDefinition);
6968

70-
return [$providerId, $listenerId, $defaultEntryPoint];
69+
return $authenticatorId;
7170
}
7271

7372
public function addConfiguration(NodeDefinition $node): void

Lti1p3Bundle.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
use OAT\Bundle\Lti1p3Bundle\DependencyInjection\Security\Factory\Message\LtiToolMessageSecurityFactory;
2929
use OAT\Bundle\Lti1p3Bundle\DependencyInjection\Security\Factory\Service\LtiServiceSecurityFactory;
3030
use Symfony\Component\DependencyInjection\ContainerBuilder;
31-
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
3231
use Symfony\Component\HttpKernel\Bundle\Bundle;
32+
use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension;
3333

3434
class Lti1p3Bundle extends Bundle
3535
{
@@ -47,15 +47,15 @@ public function build(ContainerBuilder $container): void
4747
$this->configureSecurityExtension($container->getExtension('security'));
4848
}
4949

50-
private function configureSecurityExtension(ExtensionInterface $securityExtension): void
50+
private function configureSecurityExtension(SecurityExtension $securityExtension): void
5151
{
5252
// LTI platform messages security registration
53-
$securityExtension->addSecurityListenerFactory(new LtiPlatformMessageSecurityFactory());
53+
$securityExtension->addAuthenticatorFactory(new LtiPlatformMessageSecurityFactory());
5454

5555
// LTI tool messages security registration
56-
$securityExtension->addSecurityListenerFactory(new LtiToolMessageSecurityFactory());
56+
$securityExtension->addAuthenticatorFactory(new LtiToolMessageSecurityFactory());
5757

5858
// LTI services security registration
59-
$securityExtension->addSecurityListenerFactory(new LtiServiceSecurityFactory());
59+
$securityExtension->addAuthenticatorFactory(new LtiServiceSecurityFactory());
6060
}
6161
}

Resources/config/services.yaml

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -181,28 +181,6 @@ services:
181181
OAT\Bundle\Lti1p3Bundle\Security\Exception\LtiToolMessageExceptionHandlerInterface:
182182
alias: OAT\Bundle\Lti1p3Bundle\Security\Exception\LtiToolMessageExceptionHandler
183183

184-
OAT\Bundle\Lti1p3Bundle\Security\Firewall\Message\LtiPlatformMessageAuthenticationListener:
185-
arguments:
186-
- '@security.token_storage'
187-
- '@security.authentication.manager'
188-
- '@Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface'
189-
- '@security.firewall.map'
190-
191-
OAT\Bundle\Lti1p3Bundle\Security\Firewall\Message\LtiToolMessageAuthenticationListener:
192-
arguments:
193-
- '@security.token_storage'
194-
- '@security.authentication.manager'
195-
- '@Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface'
196-
- '@OAT\Bundle\Lti1p3Bundle\Security\Exception\LtiToolMessageExceptionHandlerInterface'
197-
- '@security.firewall.map'
198-
199-
OAT\Bundle\Lti1p3Bundle\Security\Firewall\Service\LtiServiceAuthenticationListener:
200-
arguments:
201-
- '@security.token_storage'
202-
- '@security.authentication.manager'
203-
- '@Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface'
204-
- '@security.firewall.map'
205-
206184
OAT\Library\Lti1p3Core\Security\User\UserAuthenticatorInterface: ~
207185

208186
OAT\Library\Lti1p3Core\Message\Launch\Builder\PlatformOriginatingLaunchBuilder:

Security/Authentication/Provider/Message/LtiPlatformMessageAuthenticationProvider.php

Lines changed: 0 additions & 85 deletions
This file was deleted.

0 commit comments

Comments
 (0)