Skip to content

Added support to symfony 5/6 #97

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
22 changes: 14 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
"email": "[email protected]",
"homepage": "http://github.com/tmilos",
"role": "Developer"
},
{
"name": "Takieddine Messaoudi",
"email": "[email protected]",
"homepage": "https://www.smart-team.tn",
"role": "Developer"
}
],
"autoload": {
Expand All @@ -19,16 +25,16 @@
}
},
"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"
"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",
"symfony/monolog-bundle": "~2.7|~3.0|~4.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"
Expand Down
41 changes: 34 additions & 7 deletions src/LightSaml/SpBundle/Controller/DefaultController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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()]));
Expand All @@ -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();

Expand All @@ -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(),
Expand Down
4 changes: 2 additions & 2 deletions src/LightSaml/SpBundle/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 10 additions & 0 deletions src/LightSaml/SpBundle/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down