diff --git a/src/LightSaml/SpBundle/Controller/DefaultController.php b/src/LightSaml/SpBundle/Controller/DefaultController.php index 0b5fd8f..22b17f6 100644 --- a/src/LightSaml/SpBundle/Controller/DefaultController.php +++ b/src/LightSaml/SpBundle/Controller/DefaultController.php @@ -27,28 +27,45 @@ 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(); + + if (null !== $relayState) { + $context->setRelayState($relayState); + } + $action = $profile->buildAction(); $action->execute($context); 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 %} - + {% endif %} {% else %}There is no IDP configured