keycloak-customization / mongodb-user-federation

Keycloak SPI for Mongodb users federation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Installation instruction is not suitable for keycloak v.24

AlexanderRyzhov opened this issue · comments

I am trying to follow installation instructions to deploy this module to latest Keycloak server (keycloak-24.0.3), but it seems, that server has changed seriously from the time of this tool was created:

  • there are no modules and standalone/deployments folders any more.

I'v found, that if I put generated jar file to keycloak-installation-folder/providers folder - I can select it in "User federation" providers list.
But creating new user fails, and I am not sure where to put mongo-java-driver-3.12.14.jar. I tried to put it into keycloak-installation-folderlib/lib/main folder, but this seems to not be working...

Here is the console log with error:

2024-04-18 23:34:05,376 ERROR [org.keycloak.services.error.KeycloakErrorHandler] (executor-thread-3) Uncaught server error: java.lang.NoClassDefFoundError: org/bson/conversions/Bson
        at keycloak.mongodb.users.federation.providers.CustomUserStorageProvider.<init>(CustomUserStorageProvider.java:31)
        at keycloak.mongodb.users.federation.factories.CustomUserStorageProviderFactory.create(CustomUserStorageProviderFactory.java:16)
        at keycloak.mongodb.users.federation.factories.CustomUserStorageProviderFactory.create(CustomUserStorageProviderFactory.java:12)
        at org.keycloak.storage.AbstractStorageManager.getStorageProviderInstance(AbstractStorageManager.java:229)
        at org.keycloak.storage.AbstractStorageManager.lambda$getEnabledStorageProviders$0(AbstractStorageManager.java:98)

After generating the JAR file. I wrote the Dockerfile to use it as below, but encountered the same problem as yours

FROM quay.io/keycloak/keycloak:24.0.3 as builder

ENV KC_HEALTH_ENABLED=true
ENV KC_METRICS_ENABLED=true

ENV KC_HOSTNAME=localhost
ENV KC_HOSTNAME_PORT=8080
ENV KC_HOSTNAME_STRICT=false
ENV KC_HOSTNAME_STRICT_HTTPS=false

ENV KEYCLOAK_ADMIN=admin
ENV KEYCLOAK_ADMIN_PASSWORD=admin

ADD --chown=keycloak:keycloak app/build/libs/app.jar /opt/keycloak/providers/myprovider.jar
ADD --chown=keycloak:keycloak mongodb /opt/keycloak/modules/system/layers/keycloak/org

RUN /opt/keycloak/bin/kc.sh build
CMD ["start-dev"]

If you figure it out, please share it, and I'll do the same

@AlexanderRyzhov @MohammedEsafi Thanks for the Issue, I'll push the fix for v24 ASAP