Use Spring Boot driven JPA in KeyCloak StorageProvider

Viewed 32

I have to create KeyCloak Custom User Provider. To do so I quickly create Spring Boot app, setup database, create UserRepository with UserService etc. Test succesfully read users table. Then I created UserStorageProvider and UserStorageProviderFactory classes required by KeyCloak. And deploy jar library to keycloak-18.0.0 instance. UserStorageProvider detected by keycloak and show up in drop box on User federation page. But I still can't login with external users because of error in the log KC-SERVICES0013: Failed authentication: java.lang.NullPointerException: Cannot invoke "com.abc.financetech.smt.services.UserService.getUserByUsername(String)" because "this.userService" is null. Obviously, the reason for this is that jar file wasn't started as Spring Boot application, thus no UserRepository and UserService wasn't instantiated and initialized at all. How can I do this?

0 Answers
Related