keycloakjboss-cli

Configure Keycloak eventsListener via CLI


I have implemented a custom events listener for Keycloak and was able to provide its configuration using standalone-ha.xml

<!-- This works -->
<subsystem xmlns="urn:jboss:domain:keycloak-server:1.1">
    ...
    <spi name="eventsListener">
        <provider name="custom-listener" enabled="true">
            <properties>
                <property name="host" value="http://host.docker.internal:9999"/>
            </properties>
        </provider>
    </spi>
    ...

Now I am trying to implement the same configuration using CLI.

I call jboss-cli.sh

[disconnected /] connect
[standalone@localhost:9990 /] /subsystem=keycloak-server/spi=eventsListener/provider=custom-listener/:map-put(name=properties,key=host,value=http://host.docker.internal:9999)

and get error:

{
    "outcome" => "failed",
    "failure-description" => "WFLYCTL0216: Management resource '[
    (\"subsystem\" => \"keycloak-server\"),
    (\"spi\" => \"eventsListener\")
]' not found",
    "rolled-back" => true
}

When I browse via CLI to appropriate folder I do not see all the SPIs that are available for the Keycloak:

[standalone@localhost:9990 /] cd subsystem=keycloak-server/spi
[standalone@localhost:9990 spi] ls
connectionsHttpClient  connectionsJpa         hostname               publicKeyStorage       timer                  userSessionPersister
connectionsInfinispan  eventsStore            jta-lookup             realmCache             userCache              x509cert-lookup

Keycloak SPIs

The question is: where are the rest SPIs? Or more specifically, how do I configure eventsListener SPI via CLI?


Solution

  • Finally, I figured this out.

    The contents of subsystem=keycloak-server/spi exactly matches the standalone-ha.xml file. Thus, eventsListener is not available until you explicitly create it.

    This sequence of CLI instructions work:

    /subsystem=keycloak-server/spi=eventsListener/:add
    /subsystem=keycloak-server/spi=eventsListener/provider=custom-listener:add(enabled=true)
    /subsystem=keycloak-server/spi=eventsListener/provider=custom-listener/:map-put(name=properties,key=host,value=http://host.docker.internal:9999)