当(用户 - >更新,删除)从Keycloak时如何将事件发送到我的服务器?
How to get event to my server when (user -> Update, Delete) from Keycloak?
我使用 keycloak 服务器进行授权。我在我的数据库和 keycloak 中创建我的用户。
现在我需要在 keycloak 中删除用户时从我的数据库中删除用户。
我的服务器是Java写的。
当在 keycloak 中删除或更新用户时,如何从 keycloak 获取事件到我的服务器?
我认为你最好使用 Keycloak User Storage SPI feature:
You can use the User Storage SPI to write extensions to Keycloak to
connect to external user databases and credential stores. The built-in
LDAP and ActiveDirectory support is an implementation of this SPI in
action. Out of the box, Keycloak uses its local database to create,
update, and look up users and validate credentials. Often though,
organizations have existing external proprietary user databases that
they cannot migrate to Keycloak’s data model. For those situations,
application developers can write implementations of the User Storage
SPI to bridge the external user store and the internal user object
model that Keycloak uses to log in users and manage them.
这样一来,您就不需要在用户被删除、更新或其他任何情况时触发某种回调机制。您只需将您的数据库配置为外部用户数据库以供 Keycloak 使用。此外,您可以对其进行配置,以便无论何时添加、删除或更新用户,它都会立即反映在您的数据库中。这种方法更易于实施、更清洁、更易于维护,并且在性能和内存方面更好。
请检查这个例子KecyloakEventExample
希望有用
我使用 keycloak 服务器进行授权。我在我的数据库和 keycloak 中创建我的用户。 现在我需要在 keycloak 中删除用户时从我的数据库中删除用户。 我的服务器是Java写的。 当在 keycloak 中删除或更新用户时,如何从 keycloak 获取事件到我的服务器?
我认为你最好使用 Keycloak User Storage SPI feature:
You can use the User Storage SPI to write extensions to Keycloak to connect to external user databases and credential stores. The built-in LDAP and ActiveDirectory support is an implementation of this SPI in action. Out of the box, Keycloak uses its local database to create, update, and look up users and validate credentials. Often though, organizations have existing external proprietary user databases that they cannot migrate to Keycloak’s data model. For those situations, application developers can write implementations of the User Storage SPI to bridge the external user store and the internal user object model that Keycloak uses to log in users and manage them.
这样一来,您就不需要在用户被删除、更新或其他任何情况时触发某种回调机制。您只需将您的数据库配置为外部用户数据库以供 Keycloak 使用。此外,您可以对其进行配置,以便无论何时添加、删除或更新用户,它都会立即反映在您的数据库中。这种方法更易于实施、更清洁、更易于维护,并且在性能和内存方面更好。
请检查这个例子KecyloakEventExample 希望有用