forked from sulu/sulu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a9c0ebd
commit b3c927d
Showing
9 changed files
with
167 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/Sulu/Bundle/SecurityBundle/Security/OpenIdLoginSubscriber.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sulu\Bundle\SecurityBundle\Security; | ||
|
||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
use Symfony\Component\HttpFoundation\JsonResponse; | ||
use Symfony\Component\HttpKernel\Event\RequestEvent; | ||
|
||
class OpenIdLoginSubscriber implements EventSubscriberInterface | ||
{ | ||
final public const OPEN_ID_ATTRIBUTES = '_app_open_id_attributes'; | ||
|
||
public static function getSubscribedEvents(): array | ||
{ | ||
return [ | ||
RequestEvent::class => [ | ||
['onKernelRequest', 9], | ||
], | ||
]; | ||
} | ||
|
||
public function onKernelRequest(RequestEvent $event): void | ||
{ | ||
if (!$event->isMainRequest()) { | ||
return; | ||
} | ||
|
||
$request = $event->getRequest(); | ||
|
||
if (!$request->isMethod('POST')) { | ||
return; | ||
} | ||
|
||
$route = $request->attributes->get('_route'); | ||
if ('sulu_admin.login_check' !== $route) { | ||
return; | ||
} | ||
|
||
$email = $request->request->get('username'); | ||
$password = $request->request->get('password'); | ||
|
||
if (!$email || !\is_string($email)) { | ||
return; | ||
} | ||
|
||
// Also return when email and password are set | ||
if ($password) { | ||
return; | ||
} | ||
|
||
// Todo: Implement single sign on. | ||
//$event->setResponse(new JsonResponse(['method' => 'redirect', 'url' => 'https://www.google.at'], 200)); | ||
$event->setResponse(new JsonResponse(['method' => 'json_login'], 200)); | ||
$event->stopPropagation(); | ||
} | ||
} |