I am trying to create an EventListenerProvider
implementation in Keycloak 22.x for the purposes of listening to user account creation events. I've written the provider code itself and it is working without issue. Now I am trying to allow for the configuration to be externalized rather than hard-coded in the code and I am running into issues.
My EventListenerProviderFactory
implementation is rather simple and looks like this:
public class MyEventListenerProviderFactory implements EventListenerProviderFactory {
...snip...
public String getId() {
return "myAppEventListener";
}
public void init(Scope config) {
...snip...
}
public EventListenerProvider create(KeycloakSession session) {
return new MyEventListenerProvider();
}
...snip...
}
As I understand from the documentation, I should be able to provide my configuration parameters on the command line using the SPI ID. In my case, I should be able to specify a parameter that looks like:
spi-my-app-event-listener-myproperty=mypropertyvalue
That should result in me being able to do the following in the init(Scope config)
method:
public void init(Scope config) {
String myPropertyValue = config.get("myproperty");
System.out.println("myPropertyValue=" + myPropertyValue);
}
However, I always get a null
value for this property. I am using docker-compose
and the official Docker container to launch Keycloak, and am setting the property value in the command
stanza like this:
command: start-dev --spi-my-app-event-listener-myproperty=mypropvalue --import-realm
I thought that this would correctly set the property, but it looks like I may be wrong about that. Any idea where my issue lies and why I am unable to set a configuration value and read it in my event listener provider factory?