feat: adjust oauth2 implementation for TYPO3 backend login
This commit is contained in:
@@ -29,9 +29,15 @@ class UserinfoController extends AbstractController
|
||||
$scopes = ['email'];
|
||||
|
||||
// extend scopes depending on granted permissions
|
||||
if ($this->isGranted('ROLE_OAUTH2_ID')) {
|
||||
$scopes[] = 'id';
|
||||
}
|
||||
if ($this->isGranted('ROLE_OAUTH2_PROFILE')) {
|
||||
$scopes[] = 'profile';
|
||||
}
|
||||
if ($this->isGranted('ROLE_OAUTH2_ROLES')) {
|
||||
$scopes[] = 'roles';
|
||||
}
|
||||
|
||||
/** @var User $user */
|
||||
$user = $this->getUser();
|
||||
@@ -45,6 +51,9 @@ class UserinfoController extends AbstractController
|
||||
return new JsonResponse(['message' => $data->message, 'code' => $data->code], Response::HTTP_BAD_REQUEST);
|
||||
}
|
||||
|
||||
// Patch current user's roles
|
||||
$data->roles = $user->getRoles();
|
||||
|
||||
// extract userdata for resulting claims
|
||||
$userData = $this->getClaims($data, $scopes);
|
||||
|
||||
|
||||
@@ -43,9 +43,8 @@ class SecurityController extends AbstractController
|
||||
// authentication (see App\EventListener\AuthorizationCodeListener).
|
||||
$session = $request->getSession();
|
||||
$targetPath = $session->get('_security.main.target_path');
|
||||
if (null !== $targetPath && str_contains($targetPath, '/authorize')) {
|
||||
$session->set('_oauth2', true);
|
||||
}
|
||||
$isOauth2 = null !== $targetPath && str_contains($targetPath, '/authorize');
|
||||
$session->set('_oauth2', $isOauth2);
|
||||
|
||||
// For booking flow, set target path to Step 1 (after successful auth, redirect there)
|
||||
if (true === $isBookingFlow) {
|
||||
@@ -71,6 +70,7 @@ class SecurityController extends AbstractController
|
||||
'travel_date_from' => $bookingDto?->travel->dateFrom,
|
||||
'travel_date_to' => $bookingDto?->travel->dateTo,
|
||||
'cmsData' => $cmsData,
|
||||
'oauth2' => $isOauth2,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user