Repository navigation
Replies: 2 comments 3 replies
|
Hi @cesdperez My solution might appear to be "hacky" in the first place, but, it's the only way to deal with it if you have to call something like an external API through HTTP/REST or similar. IMPORTANT: If you implement everything properly, it works seamlessly as expected. The User Storage SPI was initially designed for use with JPA, so that Keycloak has a direct connection to a database where the users data is being stored. That way, and you can see this also in this quickstart, the storage provider just makes use of the database transaction management and no separate "create" or "update" phase is necessary. Side note: My example is not yet completely finished, as I'm expecting some runtime trouble when creating new users. Currently, I'm only sending the create/update request of users data in the Solution would be to create the user in the |
|
Hi @cesdperez , I still don't have a clean solution for this problem but rather a half-baked one. It's about implementing own Once that's registered by Keycloak, it will call the overridden The problem is - even though my user gets created in backend, from Keycloak's perspective, the user creation process was unsuccessful and therefore, if the new user was, for example, created by filling the "New user" form in Keycloak, the created user won't be shown and error message will be displayed that user creation failed. That is expected since indeed, Keycloak itself didn't create any user. So, I'm currently looking for at least a workaround which would allow me to handle gracefully the errors I'm getting after my user got created externally - I'd like to somehow let Keycloak know that my user was created externally and provide it with the new user's id so Keycloak can show it after creation is done. |
Uh oh!
There was an error while loading. Please reload this page.
Hi everyone,
I'm working on implementing a custom user storage provider in Keycloak to store users' PII in a separate service and database, while keeping all non-PII data in Keycloak. I've referred to the official documentation and am using AbstractUserAdapterFederatedStorage along with implementing UserStorageProvider, UserRegistrationProvider, UserLookupProvider, and UserQueryProvider.
However, I'm facing a couple of challenges:
I've reviewed several custom user storage provider examples, but they either:
a. Don't implement UserRegistrationProvider, so users aren't created in external storage.
b. Handle inserts and updates with separate operations without proper error handling and rollbacks.
c. Delaying user creation until
close()in the provider (e.g., this example by @dasniko). This seems like a hack, would need manual transactions and rollbacks, and wouldn't handle updates either. (@dasniko 's examples were great to get me started tho! kudos 🙏🏼)I've also found several open questions on this, with no answer:
Am I missing something? Is there a better way to handle this? It seems like a common use case when integrating with external storage in a production environment. Any help or suggestions would be greatly appreciated!
If I can make this work properly, I'd be happy to contribute an example implementation.
Thank you!
All reactions