Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
12 changes: 6 additions & 6 deletions src/DTO/UserRepresentationDTO.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/Interface/IamClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 5 additions & 1 deletion src/Provider/KeycloakClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/Service/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down