SSO #1

Merged
Charles-Edouard merged 23 commits from SSO into main 2025-07-29 16:46:46 +02:00
1 changed files with 27 additions and 3 deletions
Showing only changes of commit cc5bb633ec - Show all commits

View File

@ -14,6 +14,8 @@ use League\Bundle\OAuth2ServerBundle\Manager\AccessTokenManagerInterface;
class OAuth2Controller extends AbstractController
{
#[Route('/oauth2/userinfo', name: 'userinfo', methods: ['GET'])]
public function userinfo(Request $request): JsonResponse
{
@ -24,10 +26,32 @@ class OAuth2Controller extends AbstractController
}
return new JsonResponse([
'sub' => $user->getId(),
'username' => $user->getName(),
'id' => $user->getId(),
'name' => $user->getName(),
'email' => $user->getEmail(),
'roles' => $user->getRoles(),
'surname' => $user->getSurname(),
]);
}
#[Route('.well-known/jwks.json', name: 'app_jwks', methods: ['GET'])]
public function jwks(): Response
{
// Load the public key from the filesystem and use OpenSSL to parse it.
$kernelDirectory = $this->getParameter('kernel.project_dir');
$publicKey = openssl_pkey_get_public(file_get_contents($kernelDirectory . '/config/jwt/public.key'));
$details = openssl_pkey_get_details($publicKey);
$orgs =
$jwks = [
'keys' => [
[
'kty' => 'RSA',
'alg' => 'RS256',
'use' => 'sig',
'n' => strtr(rtrim(base64_encode($details['rsa']['n']), '='), '+/', '-_'),
'e' => strtr(rtrim(base64_encode($details['rsa']['e']), '='), '+/', '-_'),
],
],
];
return $this->json($jwks);
}
}