From e7204aa8d0e5ff4bd001b99c6f238a571fde043c Mon Sep 17 00:00:00 2001 From: Mael LE GUEN Date: Mon, 16 Sep 2019 17:46:07 +0200 Subject: [PATCH 1/2] Use RelayState in loginAction --- src/LightSaml/SpBundle/Controller/DefaultController.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/LightSaml/SpBundle/Controller/DefaultController.php b/src/LightSaml/SpBundle/Controller/DefaultController.php index 0b5fd8f..bbdc27f 100644 --- a/src/LightSaml/SpBundle/Controller/DefaultController.php +++ b/src/LightSaml/SpBundle/Controller/DefaultController.php @@ -49,6 +49,12 @@ public function loginAction(Request $request) $profile = $this->get('ligthsaml.profile.login_factory')->get($idpEntityId); $context = $profile->buildContext(); + + $relayState = $request->get('RelayState'); + if (null !== $relayState) { + $context->setRelayState($relayState); + } + $action = $profile->buildAction(); $action->execute($context); From 6c6ca2f5bcd138f457563600444405dd29a292e5 Mon Sep 17 00:00:00 2001 From: Mael LE GUEN Date: Tue, 17 Sep 2019 00:03:05 +0200 Subject: [PATCH 2/2] Use RelayState in discoveryAction --- .../SpBundle/Controller/DefaultController.php | 19 +++++++++++++++---- .../Resources/views/discovery.html.twig | 2 +- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/LightSaml/SpBundle/Controller/DefaultController.php b/src/LightSaml/SpBundle/Controller/DefaultController.php index bbdc27f..22b17f6 100644 --- a/src/LightSaml/SpBundle/Controller/DefaultController.php +++ b/src/LightSaml/SpBundle/Controller/DefaultController.php @@ -27,30 +27,41 @@ public function metadataAction() return $context->getHttpResponseContext()->getResponse(); } - public function discoveryAction() + public function discoveryAction(Request $request) { + $params = array(); + $relayState = $request->get('RelayState'); + if (null !== $relayState) { + $params['RelayState'] = $relayState; + } + $parties = $this->get('lightsaml.container.build')->getPartyContainer()->getIdpEntityDescriptorStore()->all(); if (1 == count($parties)) { - return $this->redirect($this->generateUrl('lightsaml_sp.login', ['idp' => $parties[0]->getEntityID()])); + return $this->redirect($this->generateUrl('lightsaml_sp.login', array_merge($params, ['idp' => $parties[0]->getEntityID()]))); } return $this->render('LightSamlSpBundle::discovery.html.twig', [ 'parties' => $parties, + 'params' => $params ]); } public function loginAction(Request $request) { + $relayState = $request->get('RelayState'); $idpEntityId = $request->get('idp'); if (null === $idpEntityId) { - return $this->redirect($this->generateUrl($this->container->getParameter('lightsaml_sp.route.discovery'))); + $params = array(); + if (null !== $relayState) { + $params['RelayState'] = $relayState; + } + return $this->redirect($this->generateUrl($this->container->getParameter('lightsaml_sp.route.discovery'), $params)); } $profile = $this->get('ligthsaml.profile.login_factory')->get($idpEntityId); $context = $profile->buildContext(); - $relayState = $request->get('RelayState'); if (null !== $relayState) { $context->setRelayState($relayState); } diff --git a/src/LightSaml/SpBundle/Resources/views/discovery.html.twig b/src/LightSaml/SpBundle/Resources/views/discovery.html.twig index f05bf54..6ce5201 100644 --- a/src/LightSaml/SpBundle/Resources/views/discovery.html.twig +++ b/src/LightSaml/SpBundle/Resources/views/discovery.html.twig @@ -10,7 +10,7 @@

Choose one

{% for idp in parties %} {% if idp.allIdpSsoDescriptors %} -

{{ idp.entityID }}

+

{{ idp.entityID }}

{% endif %} {% else %}

There is no IDP configured