Skip to content

Conversation

@tecbird
Copy link

@tecbird tecbird commented Jun 27, 2025

  1. i found a bug for count api calls
    $iamAdminClient->users()->count('test', $criteria) => no user found it will return 0 (valid case)

  2. symfony 6.4 should also work, we have some projects that are not currently at symfony 7.x

tecbird and others added 6 commits June 27, 2025 11:37
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)
@mainick mainick self-requested a review November 23, 2025 10:00
@mainick
Copy link
Owner

mainick commented Nov 23, 2025

Thanks @tecbird and @Fahl-Design for the excellent work!
I'm sorry, but I don't feel like applying the changes to the userInfo method, so could you please remove the comma 4b44bba? Then, I'll proceed with the merge to main.

Copy link
Owner

@mainick mainick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a new explicit method that returns the "raw" (array) representation instead of changing the userInfo signature.

I have suggested a change example.

  1. Interface — Add the new method (compatible with the rest of the interface):
// src/Interface/IamClientInterface.php
public function userInfoRaw(AccessTokenInterface $token): ?array;
  1. Implementation — keep userInfo, which always returns the DTO, and implement userInfoRaw, which returns the raw array:
// src/Provider/KeycloakClient.php

/**
 * @return array<string,mixed>|null
 */
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;
    }
}

Here is a proposed change. Please feel free to adjust and improve it based on your expertise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants