From 28759024605b6a168fc9a9e9e9bbce25d022462d Mon Sep 17 00:00:00 2001 From: Felix Pfister <16688055+tecbird@users.noreply.github.com> Date: Fri, 27 Jun 2025 11:37:09 +0200 Subject: [PATCH 1/6] allow symfony 6.x --- composer.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index aa86447..fff4458 100644 --- a/composer.json +++ b/composer.json @@ -11,10 +11,10 @@ "require": { "php": ">=8.2", "stevenmaguire/oauth2-keycloak": "^5.1", - "symfony/routing": "^7.2", - "symfony/security-bundle": "^7.2", - "symfony/http-kernel": "^7.2", - "symfony/framework-bundle": "^7.2", + "symfony/routing": "^6.4|^7.2", + "symfony/security-bundle": "^6.4|^7.2", + "symfony/http-kernel": "^^6.4|7.2", + "symfony/framework-bundle": "^6.4|^7.2", "symfony/serializer-pack": "^1.3" }, "require-dev": { From 23a2daf214c9e98b56f8cd3c3deda6b3aac910da Mon Sep 17 00:00:00 2001 From: Felix Pfister <16688055+tecbird@users.noreply.github.com> Date: Fri, 27 Jun 2025 11:51:11 +0200 Subject: [PATCH 2/6] allow symfony 6.4 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index fff4458..90468a2 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "stevenmaguire/oauth2-keycloak": "^5.1", "symfony/routing": "^6.4|^7.2", "symfony/security-bundle": "^6.4|^7.2", - "symfony/http-kernel": "^^6.4|7.2", + "symfony/http-kernel": "^6.4|7.2", "symfony/framework-bundle": "^6.4|^7.2", "symfony/serializer-pack": "^1.3" }, From d1a0404a69bcebfc867c91bfa41a13a36851e822 Mon Sep 17 00:00:00 2001 From: Felix Pfister <16688055+tecbird@users.noreply.github.com> Date: Fri, 27 Jun 2025 12:23:06 +0200 Subject: [PATCH 3/6] fix problem with user count = 0 throw exception only response is empty or null, in case of "0" it mest returned. example: $iamAdminClient->users()->count('test', $criteria) => no user found it will return 0 (valid case) --- src/Service/Service.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Service/Service.php b/src/Service/Service.php index d47d1c7..6156a83 100644 --- a/src/Service/Service.php +++ b/src/Service/Service.php @@ -51,7 +51,7 @@ protected function executeQuery(string $path, string $returnType, ?Criteria $cri 'response' => $content, ]); - if (empty($content)) { + if ($content === '' || $content === null) { throw new \UnexpectedValueException('Empty response'); } From 3e098924cdc5414c3d16dca38fd039dcd6331d6d Mon Sep 17 00:00:00 2001 From: Felix Pfister Date: Thu, 24 Jul 2025 16:23:18 +0200 Subject: [PATCH 4/6] fix: allow nullable fields --- src/DTO/UserRepresentationDTO.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/DTO/UserRepresentationDTO.php b/src/DTO/UserRepresentationDTO.php index 9e45d15..43cc971 100644 --- a/src/DTO/UserRepresentationDTO.php +++ b/src/DTO/UserRepresentationDTO.php @@ -18,9 +18,9 @@ public function __construct( public string $id, public string $username, public bool $emailVerified, - public string $name, - public string $firstName, - public string $lastName, + public ?string $name, + public ?string $firstName, + public ?string $lastName, public string $email, public ?bool $enabled, public ?int $createdTimestamp, @@ -85,9 +85,9 @@ public static function fromArray(array $data, ?string $client_id = null): self id: $data['sub'], username: $data['preferred_username'], emailVerified: $data['email_verified'], - name: $data['name'], - firstName: $data['given_name'], - lastName: $data['family_name'], + name: $data['name'] ?? null, + firstName: $data['given_name'] ?? null, + lastName: $data['family_name'] ?? null, email: $data['email'], enabled: $data['enabled'] ?? null, createdTimestamp: $data['createdTimestamp'] ?? null, From 4b44bba0a9ebf817369fa4ae565cda9b9279f7c5 Mon Sep 17 00:00:00 2001 From: Felix Pfister Date: Fri, 25 Jul 2025 16:57:13 +0200 Subject: [PATCH 5/6] fix: add param to disable dto mapping --- src/Interface/IamClientInterface.php | 2 +- src/Provider/KeycloakClient.php | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Interface/IamClientInterface.php b/src/Interface/IamClientInterface.php index 5675df8..abdb8a5 100644 --- a/src/Interface/IamClientInterface.php +++ b/src/Interface/IamClientInterface.php @@ -13,7 +13,7 @@ public function refreshToken(AccessTokenInterface $token): ?AccessTokenInterface public function verifyToken(AccessTokenInterface $token): ?UserRepresentationDTO; - public function userInfo(AccessTokenInterface $token): ?UserRepresentationDTO; + public function userInfo(AccessTokenInterface $token, bool $mapToDto = true): null|array|UserRepresentationDTO; public function fetchUserFromToken(AccessTokenInterface $token): ?KeycloakResourceOwner; diff --git a/src/Provider/KeycloakClient.php b/src/Provider/KeycloakClient.php index 4d066ab..9dc9223 100644 --- a/src/Provider/KeycloakClient.php +++ b/src/Provider/KeycloakClient.php @@ -124,7 +124,7 @@ public function verifyToken(AccessTokenInterface $token): ?UserRepresentationDTO } } - public function userInfo(AccessTokenInterface $token): ?UserRepresentationDTO + public function userInfo(AccessTokenInterface $token, bool $mapToDto = true): null|array|UserRepresentationDTO { try { $this->verifyToken($token); @@ -140,6 +140,10 @@ public function userInfo(AccessTokenInterface $token): ?UserRepresentationDTO 'user' => $user->toArray(), ]); + if (!$mapToDto) { + return $user->toArray(); + } + return UserRepresentationDTO::fromArray($user->toArray(), $this->client_id); } catch (\Exception $e) { From 5c43939ad51d1f8852e7f7ddfc4a934ca470ed6e Mon Sep 17 00:00:00 2001 From: Ben Date: Thu, 31 Jul 2025 13:41:58 +0200 Subject: [PATCH 6/6] fix: symfony/http-kernel version --- composer.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 90468a2..650ad6d 100644 --- a/composer.json +++ b/composer.json @@ -11,10 +11,10 @@ "require": { "php": ">=8.2", "stevenmaguire/oauth2-keycloak": "^5.1", - "symfony/routing": "^6.4|^7.2", - "symfony/security-bundle": "^6.4|^7.2", - "symfony/http-kernel": "^6.4|7.2", - "symfony/framework-bundle": "^6.4|^7.2", + "symfony/routing": "^6.4 || ^7.2", + "symfony/security-bundle": "^6.4 || ^7.2", + "symfony/http-kernel": "^6.4 || ^7.2", + "symfony/framework-bundle": "^6.4 || ^7.2", "symfony/serializer-pack": "^1.3" }, "require-dev": {