Skip to content

Commit

Permalink
feat: Update Symfony for Scoring and Reports applications (#72)
Browse files Browse the repository at this point in the history
* feat: Update Symfony for Scoring and Reports applications

---------

Co-authored-by: Makar Sichevoi <makar.sichevoy@taotesting.com>
  • Loading branch information
mccar and Makar Sichevoi authored Sep 4, 2024
1 parent b0833c0 commit 42b6c2c
Show file tree
Hide file tree
Showing 40 changed files with 576 additions and 676 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ 8.0, 8.1, 8.2, 8.3 ]
php: [ 8.1, 8.2, 8.3 ]
extra-composer-params: [ "" ]
include:
- php: 8.3
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
CHANGELOG
=========

8.0.0
-----
* Upgrade symfony to v6.4

6.1.2
-----

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,52 +22,57 @@

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

use OAT\Bundle\Lti1p3Bundle\Security\Authentication\Provider\Message\LtiPlatformMessageAuthenticationProvider;
use OAT\Bundle\Lti1p3Bundle\Security\Firewall\Message\LtiPlatformMessageAuthenticationListener;
use OAT\Bundle\Lti1p3Bundle\Security\Firewall\Message\LtiPlatformMessageAuthenticator;
use OAT\Library\Lti1p3Core\Message\Launch\Validator\Platform\PlatformLaunchValidatorInterface;
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SecurityFactoryInterface;
use Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface;
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AuthenticatorFactoryInterface;
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;

class LtiPlatformMessageSecurityFactory implements SecurityFactoryInterface
class LtiPlatformMessageSecurityFactory implements AuthenticatorFactoryInterface
{
public function getPosition(): string
public const PRIORITY = -10;

public function getPriority(): int
{
return 'pre_auth';
return self::PRIORITY;
}

public function getKey(): string
{
return 'lti1p3_message_platform';
}

public function create(
/**
* Creates the authenticator service(s) for the provided configuration.
*
* @param array<string, mixed> $config
*
* @return string|string[] The authenticator service ID(s) to be used by the firewall
*/
public function createAuthenticator(
ContainerBuilder $container,
$id,
$config,
$userProvider,
$defaultEntryPoint = null
) {
$providerId = sprintf('security.authentication.provider.%s.%s', $this->getKey(), $id);
$providerDefinition = new Definition(LtiPlatformMessageAuthenticationProvider::class);
$providerDefinition
string $firewallName,
array $config,
string $userProviderId
): array|string {
$authenticatorId = sprintf('security.authenticator.%s.%s', $this->getKey(), $firewallName);
$authenticatorDefinition = new Definition(LtiPlatformMessageAuthenticator::class);
$authenticatorDefinition
->setShared(false)
->setArguments(
[
new Reference('security.firewall.map'),
new Reference(HttpMessageFactoryInterface::class),
new Reference(PlatformLaunchValidatorInterface::class),
$id,
$firewallName,
$config['types'] ?? []
]
);
$container->setDefinition($providerId, $providerDefinition);

$listenerId = sprintf('security.authentication.listener.%s.%s', $this->getKey(), $id);
$container->setDefinition($listenerId, new ChildDefinition(LtiPlatformMessageAuthenticationListener::class));
$container->setDefinition($authenticatorId, $authenticatorDefinition);

return [$providerId, $listenerId, $defaultEntryPoint];
return $authenticatorId;
}

public function addConfiguration(NodeDefinition $node): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,52 +22,53 @@

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

use OAT\Bundle\Lti1p3Bundle\Security\Authentication\Provider\Message\LtiToolMessageAuthenticationProvider;
use OAT\Bundle\Lti1p3Bundle\Security\Firewall\Message\LtiToolMessageAuthenticationListener;
use OAT\Bundle\Lti1p3Bundle\Security\Exception\LtiToolMessageExceptionHandlerInterface;
use OAT\Bundle\Lti1p3Bundle\Security\Firewall\Message\LtiToolMessageAuthenticator;
use OAT\Library\Lti1p3Core\Message\Launch\Validator\Tool\ToolLaunchValidatorInterface;
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SecurityFactoryInterface;
use Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface;
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AuthenticatorFactoryInterface;
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;

class LtiToolMessageSecurityFactory implements SecurityFactoryInterface
class LtiToolMessageSecurityFactory implements AuthenticatorFactoryInterface
{
public function getPosition(): string
public const PRIORITY = -10;

public function getPriority(): int
{
return 'pre_auth';
return self::PRIORITY;
}

public function getKey(): string
{
return 'lti1p3_message_tool';
}

public function create(
public function createAuthenticator(
ContainerBuilder $container,
$id,
$config,
$userProvider,
$defaultEntryPoint = null
) {
$providerId = sprintf('security.authentication.provider.%s.%s', $this->getKey(), $id);
$providerDefinition = new Definition(LtiToolMessageAuthenticationProvider::class);
$providerDefinition
string $firewallName,
array $config,
string $userProviderId
): array|string {
$authenticatorId = sprintf('security.authenticator.%s.%s', $this->getKey(), $firewallName);
$authenticatorDefinition = new Definition(LtiToolMessageAuthenticator::class);
$authenticatorDefinition
->setShared(false)
->setArguments(
[
new Reference('security.firewall.map'),
new Reference(HttpMessageFactoryInterface::class),
new Reference(LtiToolMessageExceptionHandlerInterface::class),
new Reference(ToolLaunchValidatorInterface::class),
$id,
$firewallName,
$config['types'] ?? []
]
);
$container->setDefinition($providerId, $providerDefinition);

$listenerId = sprintf('security.authentication.listener.%s.%s', $this->getKey(), $id);
$container->setDefinition($listenerId, new ChildDefinition(LtiToolMessageAuthenticationListener::class));
$container->setDefinition($authenticatorId, $authenticatorDefinition);

return [$providerId, $listenerId, $defaultEntryPoint];
return $authenticatorId;
}

public function addConfiguration(NodeDefinition $node): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,52 +22,51 @@

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

use OAT\Bundle\Lti1p3Bundle\Security\Authentication\Provider\Service\LtiServiceAuthenticationProvider;
use OAT\Bundle\Lti1p3Bundle\Security\Firewall\Service\LtiServiceAuthenticationListener;
use OAT\Bundle\Lti1p3Bundle\Security\Firewall\Service\LtiServiceAuthenticator;
use OAT\Library\Lti1p3Core\Security\OAuth2\Validator\RequestAccessTokenValidatorInterface;
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SecurityFactoryInterface;
use Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface;
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AuthenticatorFactoryInterface;
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;

class LtiServiceSecurityFactory implements SecurityFactoryInterface
class LtiServiceSecurityFactory implements AuthenticatorFactoryInterface
{
public function getPosition(): string
public const PRIORITY = -10;

public function getPriority(): int
{
return 'pre_auth';
return self::PRIORITY;
}

public function getKey(): string
{
return 'lti1p3_service';
}

public function create(
public function createAuthenticator(
ContainerBuilder $container,
$id,
$config,
$userProvider,
$defaultEntryPoint = null
) {
$providerId = sprintf('security.authentication.provider.%s.%s', $this->getKey(), $id);
$providerDefinition = new Definition(LtiServiceAuthenticationProvider::class);
$providerDefinition
string $firewallName,
array $config,
string $userProviderId
): array|string {
$authenticatorId = sprintf('security.authenticator.%s.%s', $this->getKey(), $firewallName);
$authenticatorDefinition = new Definition(LtiServiceAuthenticator::class);
$authenticatorDefinition
->setShared(false)
->setArguments(
[
new Reference('security.firewall.map'),
new Reference(HttpMessageFactoryInterface::class),
new Reference(RequestAccessTokenValidatorInterface::class),
$id,
$firewallName,
$config['scopes'] ?? []
]
);
$container->setDefinition($providerId, $providerDefinition);

$listenerId = sprintf('security.authentication.listener.%s.%s', $this->getKey(), $id);
$container->setDefinition($listenerId, new ChildDefinition(LtiServiceAuthenticationListener::class));
$container->setDefinition($authenticatorId, $authenticatorDefinition);

return [$providerId, $listenerId, $defaultEntryPoint];
return $authenticatorId;
}

public function addConfiguration(NodeDefinition $node): void
Expand Down
10 changes: 5 additions & 5 deletions Lti1p3Bundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
use OAT\Bundle\Lti1p3Bundle\DependencyInjection\Security\Factory\Message\LtiToolMessageSecurityFactory;
use OAT\Bundle\Lti1p3Bundle\DependencyInjection\Security\Factory\Service\LtiServiceSecurityFactory;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension;

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

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

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

// LTI services security registration
$securityExtension->addSecurityListenerFactory(new LtiServiceSecurityFactory());
$securityExtension->addAuthenticatorFactory(new LtiServiceSecurityFactory());
}
}
22 changes: 0 additions & 22 deletions Resources/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -181,28 +181,6 @@ services:
OAT\Bundle\Lti1p3Bundle\Security\Exception\LtiToolMessageExceptionHandlerInterface:
alias: OAT\Bundle\Lti1p3Bundle\Security\Exception\LtiToolMessageExceptionHandler

OAT\Bundle\Lti1p3Bundle\Security\Firewall\Message\LtiPlatformMessageAuthenticationListener:
arguments:
- '@security.token_storage'
- '@security.authentication.manager'
- '@Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface'
- '@security.firewall.map'

OAT\Bundle\Lti1p3Bundle\Security\Firewall\Message\LtiToolMessageAuthenticationListener:
arguments:
- '@security.token_storage'
- '@security.authentication.manager'
- '@Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface'
- '@OAT\Bundle\Lti1p3Bundle\Security\Exception\LtiToolMessageExceptionHandlerInterface'
- '@security.firewall.map'

OAT\Bundle\Lti1p3Bundle\Security\Firewall\Service\LtiServiceAuthenticationListener:
arguments:
- '@security.token_storage'
- '@security.authentication.manager'
- '@Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface'
- '@security.firewall.map'

OAT\Library\Lti1p3Core\Security\User\UserAuthenticatorInterface: ~

OAT\Library\Lti1p3Core\Message\Launch\Builder\PlatformOriginatingLaunchBuilder:
Expand Down

This file was deleted.

Loading

0 comments on commit 42b6c2c

Please sign in to comment.