app/Plugin/Auth0/Controller/Auth0Controller.php line 42

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of Auth0 for EC-CUBE
  4.  *
  5.  * Copyright(c) Akira Kurozumi <info@a-zumi.net>
  6.  *
  7.  * https://a-zumi.net
  8.  *
  9.  * For the full copyright and license information, please view the LICENSE
  10.  * file that was distributed with this source code.
  11.  */
  12. namespace Plugin\Auth0\Controller;
  13. use Eccube\Controller\AbstractController;
  14. use KnpU\OAuth2ClientBundle\Client\ClientRegistry;
  15. use Plugin\Auth0\Repository\ConfigRepository;
  16. use Symfony\Component\HttpFoundation\RedirectResponse;
  17. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  18. use Symfony\Component\Routing\Annotation\Route;
  19. /**
  20.  * @Route("/auth0")
  21.  */
  22. class Auth0Controller extends AbstractController
  23. {
  24.     /**
  25.      * @param ClientRegistry $clientRegistry
  26.      * @param ConfigRepository $configRepository
  27.      *
  28.      * @return RedirectResponse
  29.      *
  30.      * @throws \Exception
  31.      *
  32.      * @Route("/connect", name="auth0_connect")
  33.      */
  34.     public function connect(ClientRegistry $clientRegistryConfigRepository $configRepository): RedirectResponse
  35.     {
  36.         $Config $configRepository->get();
  37.         if (!$Config->getClientId() || !$Config->getClientSecret() || !$Config->getCustomDomain()) {
  38.             throw new NotFoundHttpException();
  39.         }
  40.         return $clientRegistry
  41.             ->getClient('auth0')
  42.             ->redirect(['openid email email_verified profile']);
  43.     }
  44.     /**
  45.      * @return void
  46.      *
  47.      * @Route("/connect/callback", name="auth0_connect_callback")
  48.      */
  49.     public function callback()
  50.     {
  51.     }
  52. }