Skip to content
Merged
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
2 changes: 2 additions & 0 deletions src/Interface/IamClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public function verifyToken(AccessTokenInterface $token): ?UserRepresentationDTO

public function userInfo(AccessTokenInterface $token): ?UserRepresentationDTO;

public function userInfoRaw(AccessTokenInterface $token): ?array;

public function fetchUserFromToken(AccessTokenInterface $token): ?KeycloakResourceOwner;

/**
Expand Down
27 changes: 27 additions & 0 deletions src/Provider/KeycloakClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,33 @@ public function userInfo(AccessTokenInterface $token): ?UserRepresentationDTO
}
}

public function userInfoRaw(AccessTokenInterface $token): ?array
{
try {
$this->verifyToken($token);
$accessToken = new AccessTokenLib([
'access_token' => $token->getToken(),
'refresh_token' => $token->getRefreshToken(),
'expires' => $token->getExpires(),
'values' => $token->getValues(),
]);
$resourceOwner = $this->keycloakProvider->getResourceOwner($accessToken);
$user = new KeycloakResourceOwner($resourceOwner->toArray(), $token);
$this->keycloakClientLogger->info('KeycloakClient::userInfoRaw', [
'user' => $user->toArray(),
]);

return $user->toArray();
}
catch (\Exception $e) {
$this->keycloakClientLogger->error('KeycloakClient::userInfoRaw', [
'error' => $e->getMessage(),
]);

return null;
}
}

public function fetchUserFromToken(AccessTokenInterface $token): ?KeycloakResourceOwner
{
try {
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 === '' || trim($content) === '') {
throw new \UnexpectedValueException('Empty response');
}

Expand Down