vendor/hslavich/oneloginsaml-bundle/Controller/SamlController.php line 44

Open in your IDE?
  1. <?php
  2. namespace Hslavich\OneloginSamlBundle\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Security\Core\Security;
  6. use Symfony\Component\HttpFoundation\Request;
  7. class SamlController extends AbstractController
  8. {
  9.     protected $samlAuth;
  10.     public function __construct(\OneLogin\Saml2\Auth $samlAuth)
  11.     {
  12.         $this->samlAuth $samlAuth;
  13.     }
  14.     public function loginAction(Request $request)
  15.     {
  16.         $authErrorKey Security::AUTHENTICATION_ERROR;
  17.         $session $targetPath $error null;
  18.         if ($request->hasSession()) {
  19.             $session $request->getSession();
  20.             $firewallName array_slice(explode('.'trim($request->attributes->get('_firewall_context'))), -1)[0];
  21.             $targetPath $session->get('_security.'.$firewallName.'.target_path');
  22.         }
  23.         if ($request->attributes->has($authErrorKey)) {
  24.             $error $request->attributes->get($authErrorKey);
  25.         } elseif (null !== $session && $session->has($authErrorKey)) {
  26.             $error $session->get($authErrorKey);
  27.             $session->remove($authErrorKey);
  28.         }
  29.         if ($error instanceof \Exception) {
  30.             throw new \RuntimeException($error->getMessage());
  31.         }
  32.         $this->samlAuth->login($targetPath);
  33.     }
  34.     public function metadataAction()
  35.     {
  36.         $metadata $this->samlAuth->getSettings()->getSPMetadata();
  37.         $response = new Response($metadata);
  38.         $response->headers->set('Content-Type''xml');
  39.         return $response;
  40.     }
  41.     public function assertionConsumerServiceAction()
  42.     {
  43.         throw new \RuntimeException('You must configure the check path to be handled by the firewall.');
  44.     }
  45.     public function singleLogoutServiceAction()
  46.     {
  47.         throw new \RuntimeException('You must activate the logout in your security firewall configuration.');
  48.     }
  49. }