Keycloak provider and user storage

丶灬走出姿态 提交于 2019-12-04 15:24:20

I have had the same problem and I have resolved it using a filter. I just check if the principal exist and if not I insert it into my application DB:

KeycloakSecurityContext ctx = (KeycloakSecurityContext)request.getAttribute(KeycloakSecurityContext.class.getName()); User userEntity = em.find(User.class, ctx.getToken().getSubject()); if (userEntity == null) { ....create user... } You can also use an event listener (keycloak events listener) as shown in Example Event Listener that prints events to System.out, but for this exact use case that solution was easier and faster.

You have to implement a custom Authentication SPI (inside success() method you create user on your app), deployed it , and add it to the registration flow

Keycloak documentation : Link

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!