简体   繁体   English

在 Keycloak 中实现自定义 SPI

[英]Implement custom SPI in Keycloak

I have started working on KeyCloak with angular and I want to try out adding my own custom SPI.我已经开始使用 angular 开发 KeyCloak,我想尝试添加我自己的自定义 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.就像我需要创建一个新的 Java 项目还是打开一些我找不到的现有项目。 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.请注意您要自定义的 SPI。 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.有几个选项,例如用于用户存储、主题、身份验证等的 SPI。有关更多详细信息,请参阅https://www.keycloak.org/docs/latest/server_development/#available-spis
  • for every SPI you need to build a Java Project.对于每个 SPI,您需要构建一个 Java 项目。 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.这是通过 HTTP 客户端https://github.com/adviqo-GmbH/keycloak/compare/master...adviqo-GmbH:feature/http-storage的自定义 UserStorage SPI 的示例 - 这是一个差异。 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您需要一个 pom.xml、一些 java 类和至少一个META-INF/services/org.keycloak.storage.UserStorageProviderFactory下的属性,其中包含对特定 class 的引用
  • then you need to build the SPI module with maven/java.那么你需要用 maven/java 构建 SPI 模块。
  • the result (here in form of a JAR, but WAR and EAR is possible too) must be placed in <keycloak-home>/standalone/deployments .结果(此处以 JAR 的形式,但 WAR 和 EAR 也是可能的)必须放在<keycloak-home>/standalone/deployments中。
  • Keycloak will identify the new custom SPI during startup. Keycloak 将在启动期间识别新的自定义 SPI。

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.当然 - 这并不容易,文档https://www.keycloak.org/docs/latest/server_development/#_providers对初学者来说不是很有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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