Code Monkey home page Code Monkey logo

keycloak-rest-api-client-php's People

Contributors

daniellienert avatar dependabot[bot] avatar fschmtt avatar garry08 avatar jaapio avatar jprw10 avatar leon-manq avatar tpokorra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

keycloak-rest-api-client-php's Issues

Missing credentials in the User representation

According to the REST API documentation, GET /admin/realms/{realm}/users should include list of credentials users possess. But it is not in the response even for users with credentials. I am not sure if this is an intentional restriction from Keycloak or an oversight in the client, but unfortunately, there is no support for GET /admin/realms/{realm}/users/{user-id}/credentials endpoint at all to rely on as an alternative solution. Having an access to credentials data would particularly helpful to get information on password renewals, account activation time.

Create resource fails with error

We try to setup a new realm using this library. However this fails because the Resource representation api doesn't accept the id field when creating a resource. We get the error:

Client error: POST http://.../admin/realms/.../clients resulted in a 400 Bad Request response:\n
{"error":"Unrecognized field "id" (class org.keycloak.representations.idm.authorization.ResourceRepresentation), not m (truncated...).

Suggestion is to filter the id field when it's not set. So on fetch the object will contain an id, but when posting a new resource to create one it will not error. I saw that a feature exists to filter properties with a certain attribute. Would this be a useful approach for the resource id as well? So the code would look like this:

class Resource extends Representation
{
    public function __construct(
        #[OmmitNull]
        protected ?string $id,
//....

Implementing it this way would allow us to reuse the behavior on other fields of representations, in the same way.

This issue relates to #93

File PasswordPolicyType is missing

Hi! This file was not checked into the repository.

PHP Fatal error: Uncaught Error: Class 'Fschmtt\Keycloak\Representation\PasswordPolicyType' not found in /root/migration/vendor/fschmtt/keycloak-rest-api-client-php/src/Mapper/JsonToServerInfoMapper.php:86

Thanks, Sven

Authenticating Clients/Users of any Realm (not just `master`)

Hi there! Thanks for this awesome Keycloak PHP client.

I don't think it's currently possible, but I have to ask: is there a way to override the default master Realm and specify my own Realm when creating the Keycloak client? I have a use case where I'd like to authenticate Clients/Users on the Realm level. I believe this is possible in the official Keycloak Admin Client. Something like this should do it:

// Fschmtt\Keycloak\Http\Client.php

    public function __construct(
        private readonly Keycloak              $keycloak,
        private readonly ClientInterface       $httpClient,
        private readonly TokenStorageInterface $tokenStorage,
        private readonly ?string               $realmName = null
    ) {}
    ...
    
     /**
     * @return array{access_token: string, refresh_token: string}
     */
    private function fetchTokens(): array
    {
        try {
            $response = $this->httpClient->request(
                'POST',
                $this->keycloak->getBaseUrl() . sprintf('/realms/%s/protocol/openid-connect/token', $this->realmName ?? 'master'),
                [
                    'form_params' => [
                       ...
                    ],
                ],
            );
        } catch (ClientException $e) {
            $response = $this->httpClient->request(
                'POST',
                $this->keycloak->getBaseUrl() . sprintf('/realms/%s/protocol/openid-connect/token', $this->realmName ?? 'master'),
                [
                    'form_params' => [
                        ...
                    ],
                ]
            );
        }
        ...
    }
    ...

What do you think? πŸ™‚

Import realms from files/dirs

The official REST API expects the body of the POST /realms request to be a file, while the implemented client receives a representation. This approach makes sense, but can we modify the method to work with both a direct file path and a representation?

This can even be extended to accept a directory of dissected import data generated by Keycloak's export command:

bin/kc.sh export --dir data

This would likely be the primary use case for consumers. One could store a default realm configuration in a specific location within the project and import it programmatically, instead of manually building a representation of an entire realm from multiple files in the code.

Sending body to executeActionsEmail()

Hi,

Reading the code of executeActionsEmail() I don't see any options to send a body containing the list of actions.

Do I miss something?

For me we should be able to send a body parameter containing a JSON array of string + optionally a client_id, lifespan and redirect_uri.

If you are open to contributions we could maybe contribute to the project.

Jean

Support for client retrieval by client ID

I have noticed that retrieving clients by client ID is not possible. The confusion is compounded by naming the client UUID parameter as client ID, leading developers to mistakenly believe that the library expects a client ID for resource retrieval.

Adding a method at least like users()->search(['clientId' => 'client-id']) would simplify the process.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.