feat: adjust oauth2 implementation for TYPO3 backend login

This commit is contained in:
Björn Fromme
2025-12-12 16:31:32 +01:00
parent e9c1dd8b9d
commit 79e5a3c12d
7 changed files with 24 additions and 9 deletions
@@ -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);