简体   繁体   中英

Implement custom SPI in Keycloak

I have started working on KeyCloak with angular and I want to try out adding my own custom SPI. But I am failing to understand the initial process. Like do I need to make a new Java Project or Open some existing project I am unable to find. It is also not clear in the documentation. I would be grateful if someone could help me with the start up, import and set up. Thanks in advance.

Yes, you need the following steps:

  • be aware of what SPI you want to customize. There are several options like a SPI for User Storage, Theming, Authentication etc. see https://www.keycloak.org/docs/latest/server_development/#available-spis for more details.
  • for every SPI you need to build a Java Project. Here is an example for a custom UserStorage SPI via HTTP Client https://github.com/adviqo-GmbH/keycloak/compare/master...adviqo-GmbH:feature/http-storage - this is a diff. You need a pom.xml, some java-classes and at least a property under META-INF/services/org.keycloak.storage.UserStorageProviderFactory that contains the reference to a specific class
  • then you need to build the SPI module with maven/java.
  • the result (here in form of a JAR, but WAR and EAR is possible too) must be placed in <keycloak-home>/standalone/deployments .
  • Keycloak will identify the new custom SPI during startup.

Thats it. Of course - it's not easy and the documentation https://www.keycloak.org/docs/latest/server_development/#_providers is not very helpful for beginners.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM