From 5883fb1e9f0d512990252462aeabbe4e46430ff4 Mon Sep 17 00:00:00 2001 From: Takieddine Messaoudi Date: Tue, 14 Jun 2022 15:17:13 +0100 Subject: [PATCH 1/2] feature: Upgrade symfony req & upgrade lightsaml symfony-bridge (@todo create this version) --- composer.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index a6cc9c4..a9cf1b6 100644 --- a/composer.json +++ b/composer.json @@ -20,15 +20,15 @@ }, "require": { "php": ">=5.6", - "symfony/framework-bundle": "~2.7|~3.0|~4.0", - "symfony/security-bundle": "~2.7|~3.0|~4.0", - "lightsaml/symfony-bridge": "~1.3" + "symfony/framework-bundle": "~2.7|~3.0|~4.0|~5.0", + "symfony/security-bundle": "~2.7|~3.0|~4.0|~5.0", + "lightsaml/symfony-bridge": "^1.3|^2.0" }, "require-dev": { "phpunit/phpunit": "^5.7", "sebastian/comparator": "^1.2.4|~2.0|~3.0", - "symfony/symfony": "~2.7|~3.0|~4.0", - "symfony/monolog-bundle": "~2.7|~3.0|~4.0" + "symfony/symfony": "~2.7|~3.0|~4.0|~5.0", + "symfony/monolog-bundle": "~2.7|~3.0|~4.0|~5.0" }, "config": { "bin-dir": "bin" From 60a95058908d157e918b340249eae3a8c1f21e8c Mon Sep 17 00:00:00 2001 From: Takieddine Messaoudi Date: Tue, 21 Jun 2022 14:22:17 +0100 Subject: [PATCH 2/2] feature: Upgraded lightsaml to litesaml and sf to 5/6 --- CHANGELOG.md | 18 ++++++++ composer.json | 22 ++++++---- .../SpBundle/Controller/DefaultController.php | 41 +++++++++++++++---- .../DependencyInjection/Configuration.php | 4 +- .../SpBundle/Resources/config/services.yml | 10 +++++ 5 files changed, 78 insertions(+), 17 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..ffde916 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,18 @@ +# Changelog + +[unreleased] +## [2.0.0] - 2022-06-21 +### Added +- Symfony 5.0/6.0 support + +### Changed +- src/LightSaml/SpBundle/DependencyInjection/Configuration.php (fixed node declaration fo sf5+) +- src/LightSaml/SpBundle/Controller/DefaultController.php & src/LightSaml/SpBundle/Resources/config/services.yml (inject services instead of using container) +- Php minimum version to 7.2.5 +- lightsaml/lightsaml to litesaml/lightsaml + +### Removed +- Support for symfony <= 4.x + +### @todo before merge +release lightsaml/symfony-bridge version 2.x \ No newline at end of file diff --git a/composer.json b/composer.json index a9cf1b6..09d0d58 100644 --- a/composer.json +++ b/composer.json @@ -10,6 +10,12 @@ "email": "tmilos@gmail.com", "homepage": "http://github.com/tmilos", "role": "Developer" + }, + { + "name": "Takieddine Messaoudi", + "email": "tmessaoudi@smart-team.tn", + "homepage": "https://www.smart-team.tn", + "role": "Developer" } ], "autoload": { @@ -19,16 +25,16 @@ } }, "require": { - "php": ">=5.6", - "symfony/framework-bundle": "~2.7|~3.0|~4.0|~5.0", - "symfony/security-bundle": "~2.7|~3.0|~4.0|~5.0", - "lightsaml/symfony-bridge": "^1.3|^2.0" + "php": ">=7.2.5", + "symfony/framework-bundle": "~5.0|~6.0", + "symfony/security-bundle": "~5.0|~6.0", + "lightsaml/symfony-bridge": "^2.0" }, "require-dev": { - "phpunit/phpunit": "^5.7", - "sebastian/comparator": "^1.2.4|~2.0|~3.0", - "symfony/symfony": "~2.7|~3.0|~4.0|~5.0", - "symfony/monolog-bundle": "~2.7|~3.0|~4.0|~5.0" + "phpunit/phpunit": "~8.4|~9.5", + "sebastian/comparator": "^4.0", + "symfony/symfony": "~5.0|~6.0", + "symfony/monolog-bundle": "~3.0" }, "config": { "bin-dir": "bin" diff --git a/src/LightSaml/SpBundle/Controller/DefaultController.php b/src/LightSaml/SpBundle/Controller/DefaultController.php index b6d69a0..a3e4c23 100644 --- a/src/LightSaml/SpBundle/Controller/DefaultController.php +++ b/src/LightSaml/SpBundle/Controller/DefaultController.php @@ -11,14 +11,41 @@ namespace LightSaml\SpBundle\Controller; -use Symfony\Bundle\FrameworkBundle\Controller\Controller; +use LightSaml\SymfonyBridgeBundle\Bridge\Container\BuildContainer; +use LightSaml\Builder\Profile\WebBrowserSso\Sp\SsoSpSendAuthnRequestProfileBuilderFactory; +use LightSaml\Builder\Profile\Metadata\MetadataProfileBuilder; +use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; -class DefaultController extends Controller +class DefaultController extends AbstractController { + /** + * @var BuildContainer $buildContainer + */ + protected BuildContainer $buildContainer; + /** + * @var SsoSpSendAuthnRequestProfileBuilderFactory $ssoSpSendAuthnRequestProfileBuilderFactory + */ + protected SsoSpSendAuthnRequestProfileBuilderFactory $ssoSpSendAuthnRequestProfileBuilderFactory; + /** + * @var MetadataProfileBuilder $metadataProfileBuilder + */ + protected MetadataProfileBuilder $metadataProfileBuilder; + /** + * @var string $samlSpDiscoveryRoute + */ + protected string $samlSpDiscoveryRoute; + + public function __construct(BuildContainer $buildContainer, SsoSpSendAuthnRequestProfileBuilderFactory $ssoSpSendAuthnRequestProfileBuilderFactory, MetadataProfileBuilder $metadataProfileBuilder, string $samlSpDiscoveryRoute) + { + $this->buildContainer = $buildContainer; + $this->ssoSpSendAuthnRequestProfileBuilderFactory = $ssoSpSendAuthnRequestProfileBuilderFactory; + $this->metadataProfileBuilder = $metadataProfileBuilder; + $this->samlSpDiscoveryRoute = $samlSpDiscoveryRoute; + } public function metadataAction() { - $profile = $this->get('ligthsaml.profile.metadata'); + $profile = $this->metadataProfileBuilder; $context = $profile->buildContext(); $action = $profile->buildAction(); @@ -29,7 +56,7 @@ public function metadataAction() public function discoveryAction() { - $parties = $this->get('lightsaml.container.build')->getPartyContainer()->getIdpEntityDescriptorStore()->all(); + $parties = $this->buildContainer->getPartyContainer()->getIdpEntityDescriptorStore()->all(); if (1 == count($parties)) { return $this->redirect($this->generateUrl('lightsaml_sp.login', ['idp' => $parties[0]->getEntityID()])); @@ -44,10 +71,10 @@ public function loginAction(Request $request) { $idpEntityId = $request->get('idp'); if (null === $idpEntityId) { - return $this->redirect($this->generateUrl($this->container->getParameter('lightsaml_sp.route.discovery'))); + return $this->redirect($this->generateUrl($this->samlSpDiscoveryRoute)); } - $profile = $this->get('ligthsaml.profile.login_factory')->get($idpEntityId); + $profile = $this->ssoSpSendAuthnRequestProfileBuilderFactory->get($idpEntityId); $context = $profile->buildContext(); $action = $profile->buildAction(); @@ -58,7 +85,7 @@ public function loginAction(Request $request) public function sessionsAction() { - $ssoState = $this->get('lightsaml.container.build')->getStoreContainer()->getSsoStateStore()->get(); + $ssoState = $this->buildContainer->getStoreContainer()->getSsoStateStore()->get(); return $this->render('@LightSamlSp/sessions.html.twig', [ 'sessions' => $ssoState->getSsoSessions(), diff --git a/src/LightSaml/SpBundle/DependencyInjection/Configuration.php b/src/LightSaml/SpBundle/DependencyInjection/Configuration.php index 192625b..d1a0f54 100644 --- a/src/LightSaml/SpBundle/DependencyInjection/Configuration.php +++ b/src/LightSaml/SpBundle/DependencyInjection/Configuration.php @@ -25,8 +25,8 @@ class Configuration implements ConfigurationInterface */ public function getConfigTreeBuilder() { - $treeBuilder = new TreeBuilder(); - $root = $treeBuilder->root('light_saml_sp'); + $treeBuilder = new TreeBuilder('light_saml_sp'); + $root = $treeBuilder->getRootNode(); $root ->children() diff --git a/src/LightSaml/SpBundle/Resources/config/services.yml b/src/LightSaml/SpBundle/Resources/config/services.yml index bd9ed5f..603ed22 100644 --- a/src/LightSaml/SpBundle/Resources/config/services.yml +++ b/src/LightSaml/SpBundle/Resources/config/services.yml @@ -3,6 +3,16 @@ parameters: lightsaml.route.login_check: lightsaml_sp.login_check services: + LightSaml\SpBundle\Controller\DefaultController: + public: true + tags: ['controller.service_arguments'] + calls: + - [ setContainer, [ "@service_container" ] ] + arguments: + - "@lightsaml.container.build" + - "@ligthsaml.profile.login_factory" + - "@ligthsaml.profile.metadata" + - "%lightsaml_sp.route.discovery%" lightsaml_sp.username_mapper.simple: class: LightSaml\SpBundle\Security\User\SimpleUsernameMapper arguments: