vendor/lightsaml2/sp-bundle/src/LightSaml/SpBundle/Controller/DefaultController.php line 44

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the LightSAML SP-Bundle package.
  4.  *
  5.  * (c) Milos Tomic <tmilos@lightsaml.com>
  6.  *
  7.  * This source file is subject to the MIT license that is bundled
  8.  * with this source code in the file LICENSE.
  9.  */
  10. namespace LightSaml\SpBundle\Controller;
  11. use LightSaml\Build\Container\BuildContainerInterface;
  12. use LightSaml\Builder\Profile\ProfileBuilderInterface;
  13. use LightSaml\Builder\Profile\WebBrowserSso\Sp\SsoSpSendAuthnRequestProfileBuilderFactory;
  14. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  15. use Symfony\Component\HttpFoundation\Request;
  16. class DefaultController extends AbstractController
  17. {
  18.     private $buildContainer;
  19.     private $metadataProfileBuilder;
  20.     private $requestProfileBuilderFactory;
  21.     public function __construct(BuildContainerInterface $buildContainerProfileBuilderInterface $metadataProfileBuilderSsoSpSendAuthnRequestProfileBuilderFactory $requestProfileBuilderFactory)
  22.     {
  23.         $this->buildContainer $buildContainer;
  24.         $this->metadataProfileBuilder $metadataProfileBuilder;
  25.         $this->requestProfileBuilderFactory $requestProfileBuilderFactory;
  26.     }
  27.     public function metadataAction()
  28.     {
  29.         $profile $this->metadataProfileBuilder;
  30.         $context $profile->buildContext();
  31.         $action $profile->buildAction();
  32.         $action->execute($context);
  33.         return $context->getHttpResponseContext()->getResponse();
  34.     }
  35.     public function discoveryAction()
  36.     {
  37.         $parties $this->buildContainer->getPartyContainer()->getIdpEntityDescriptorStore()->all();
  38.         if (== count($parties)) {
  39.             return $this->redirect($this->generateUrl('lightsaml_sp.login', ['idp' => $parties[0]->getEntityID()]));
  40.         }
  41.         return $this->render('@LightSamlSp/discovery.html.twig', [
  42.             'parties' => $parties,
  43.         ]);
  44.     }
  45.     public function loginAction(Request $request)
  46.     {
  47.         $idpEntityId $request->get('idp');
  48.         if (null === $idpEntityId) {
  49.             return $this->redirect($this->generateUrl($this->getParameter('lightsaml_sp.route.discovery')));
  50.         }
  51.         $profile $this->requestProfileBuilderFactory->get($idpEntityId);
  52.         $context $profile->buildContext();
  53.         $action $profile->buildAction();
  54.         $action->execute($context);
  55.         return $context->getHttpResponseContext()->getResponse();
  56.     }
  57.     public function sessionsAction()
  58.     {
  59.         $ssoState $this->buildContainer->getStoreContainer()->getSsoStateStore()->get();
  60.         return $this->render('@LightSamlSp/sessions.html.twig', [
  61.             'sessions' => $ssoState->getSsoSessions(),
  62.         ]);
  63.     }
  64. }