GithubHelp home page GithubHelp logo

Comments (6)

FX-HAO avatar FX-HAO commented on August 15, 2024

Sorry for the delayed response.

adding the jar to standalone/deployments and deploying

I think you cannot just put your jars into standalone/deployments(hot deployment), since my SPIs make some changes to the database and something like that.
You need to use jboss-cli script to register your libraries. If you're not familiar with that, you could take a look at here.
Or you can just take a look at the example and the Dockerfile under the directory. if you know docker, it's more clear and easy to know the workflow of how to register your libraries into keycloak. And you just need to replace the name of my SMS implementation(keycloak-phone-authenticator-yuntongxun-sms) with yours. Then build the docker image and run it.

Please let me know if you have any questions.

from keycloak-phone-authenticator.

FX-HAO avatar FX-HAO commented on August 15, 2024

BTW, since you introduce the library aws-java-sdk, you also need to check if the libraries it depends on are imported in Keycloak. otherwise, you also need to register them into keycloak.
For instance, if aws-java-sdk depends on library B, then you also need to register B. if B depends on C, you need to register C as well, and so on.

from keycloak-phone-authenticator.

CalistaIo avatar CalistaIo commented on August 15, 2024

Hi, thank you for the response. To resolve the issue, I added a jboss-deployment-structure.xml file to META-INF and added the jar to standalone/deployments folder, and then registered the module (that is, the same jar with my SmsService implementation included) and edited the standalone.xml config file. However, when I run standalone.bat in cmd line, I get the following error:

Error during startup: java.util.ServiceConfigurationError: com.hfx.keycloak.spi.VerificationCodeServiceProviderFactory: com.hfx.keycloak.spi.impl.VerificationCodeServiceProviderFactoryImpl not a subtype

I have not made any changes to the service files/Java classes other than my own Sms Service class, so I am very puzzled about why I am getting this issue. I suspect that Keycloak is not detecting the providers properly. I was wondering if you have encountered this issue before?

Additionally, just an extra observation, but when I do not register the providers in the modules folder, I can deploy and see all the extra configurations, but the issue of the custom providers (like VerificationCodeService) not being detected pops up when I go through the entire authentication flow.

from keycloak-phone-authenticator.

FX-HAO avatar FX-HAO commented on August 15, 2024

and added the jar to standalone/deployments folder

As I mentioned before, you cannot put your jar into the standalone/deployments folder, it's called hot deployment. you need to take a look at https://access.redhat.com/documentation/en-us/red_hat_single_sign-on/7.3/html/server_developer_guide/providers#register_a_provider_using_modules

from keycloak-phone-authenticator.

FX-HAO avatar FX-HAO commented on August 15, 2024

My example Dockerfile:

# base image
FROM jboss/keycloak:9.0.2

# copy the jars into the current folder
COPY --from=builder /app/keycloak-phone-authenticator/target/keycloak-phone-authenticator-1.0.0-SNAPSHOT.jar .
COPY --from=builder /app/keycloak-phone-authenticator-yuntongxun-sms/target/keycloak-phone-authenticator-yuntongxun-sms-1.0.0-SNAPSHOT.jar .
COPY --from=builder /app/yuntongxun4j/target/yuntongxun4j-1.0-SNAPSHOT.jar .
COPY examples/cli/ cli/

# register the jars
RUN $JBOSS_HOME/bin/jboss-cli.sh --file=cli/keycloak-phone-authenticator-yuntongxun-sms-config.cli
RUN $JBOSS_HOME/bin/jboss-cli.sh --file=cli/module-add.cli

# copy the resource files into the current folder
COPY --from=builder /app/keycloak-phone-authenticator/target/classes/theme-resources/templates/ $JBOSS_HOME/themes/base/login/
COPY ./messages/ messages/

# fix a bug
RUN rm -rf /opt/jboss/keycloak/standalone/configuration/standalone_xml_history/current

# register the resource files
RUN cat messages/messages_en.properties >> $JBOSS_HOME/themes/base/login/messages/messages_en.properties && \
    cat messages/messages_zh_CN.properties >> $JBOSS_HOME/themes/base/login/messages/messages_zh_CN.properties && \
    cat messages/messages_en.properties >> $JBOSS_HOME/themes/base/account/messages/messages_en.properties && \
    cat messages/messages_zh_CN.properties >> $JBOSS_HOME/themes/base/account/messages/messages_zh_CN.properties

from keycloak-phone-authenticator.

CalistaIo avatar CalistaIo commented on August 15, 2024

Ok, I placed the jar in providers instead. As for the AWS dependency, I used Maven's shade plugin to create an uber jar so there are no more issues about the dependency not being found. It is now working and I can set up the additional configs. Thanks for the help.

from keycloak-phone-authenticator.

Related Issues (10)

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.