Thank you for watching this video. Please feel free to buy me a coffee www.buymeacoffee.com/Code215
@bartomiej68243 ай бұрын
Very good and very helpful video, thank you so much, you doing good work! Have a nice day!
@Kitty-w6q7p4 ай бұрын
Hi! Thank for tutorial, and i have a question: lets assume i want to separate user and member entities so that user is keycloak user, stored in kc database, and member is an entity, which is managed by 'members' microservice of my backend project for example. User is used for authentication, and member is used for complex authorization at microservice side. Also, User has attribute 'member_id' to associate with a specific member. When user registers himself with registration form, keycloak should invoke 'members' microservice to create a member with name and surname specified in registration form. The obtained id of created member should be stored in 'member_id' attribute of keycloak user. This attribute will be put into access tokens so that microservice can implement any authorization process. I think it is possible to implement such logic with EventListenerProvider, but what if 'members' endpoint invokation fail? For example, it returned code 400 or 500. Obviously, in this case the whole registration process should fail and no user in KC should be stored, otherwise we have data inconsistency. How to solve this problem?
@K4dryl Жыл бұрын
Could you add a github link?
@treynight Жыл бұрын
I can get this to work when creating a user manually while logged in, however, I'm having difficulty in getting this to occur when doing a self-registration. Any suggestions on this?
@code-215 Жыл бұрын
Not quite following. What difficulty are you having?
@treynight Жыл бұрын
@@code-215 This only seems to work when someone is logged in and creating a new user. Keycloak allows for self-registration, which this doesn't appear to work for. Do you know if there's a way to add an event listener to the creation of a user from there vs someone like an admin manually adding a user?
@code-215 Жыл бұрын
@@treynight You'd put that code in the onEvent(Event event) method. That's where non-admin events go. Event has an EventType enum which has "REGISTER" defined so you'd check for that to determine if the event is a user registration event.
@treynight Жыл бұрын
@@code-215 Awesome, got it. Thanks!
@francisoladosu96436 ай бұрын
Hi, thanks for the video. Please is it possible to have access to those events in the java code and then maybe perform some operation based on the event type. In my case, when a User is registered, i want to call a createUserWallet method in my project. How do i go about it? Currently the logs only print in Docker, i need a way to access those values in the Java code. Thanks in anticipation.
@code-2156 ай бұрын
Yes. When the event happens send a HTTP request to an endpoint in your project. That endpoint then calls createUserWallet
@francisoladosu96436 ай бұрын
@@code-215 Thanks for your response. But I have tried this and it didn’t work. The issue I’m having is the the onEvent method isn’t getting triggered so all codes within it isn’t working. I tried printing the eventType to the console, nothing shows up, but for some reasons When I use docker logs I see all the events in real-time. But it’s not being picked up in my onEvent method.
@code-2156 ай бұрын
If you followed the steps in this tutorial it should work. I think you missed a step. Verify that you've added the SPI to Keycloak and saved it(as shown at 10:35). Make sure you've implemented the right classes and methods. The onEvent() you override should be the one with the AdminEvent parameter not Event parameter. Make sure your folder structure is correct. Verify that you have followed all the steps in this tutorial.
@Kitty-w6q7p4 ай бұрын
@@code-215 bro, but what about if createUserWaller fails? There is an uncosistency of data, when user is created within keycloak db, but wallet doesn't exist.
@GautamKumar-xq8ve Жыл бұрын
@code215 couple of Questions: 1) Will the logic change say if i am using Keycloak 16 or keycloak 21.1.1 2) I have a requirement where on keycloak register screen i need to add some additional fields and then send all the data to an external API thorough SPI. Can you suggest how to build jar file through scratch Also, Do you have the github link for above SPI shown in video
@code-215 Жыл бұрын
1)No, both versions have event listeners in their libraries. 2) Yes, this is possible. The additional fields you add will be in the "attributes" field of the User. You can find those details here: www.keycloak.org/docs/latest/server_development/#registration-page I'll add Github link later