Closed cato447 closed 1 year ago
@cato447 Thanks for the detailed bug report. I think we may have a bug in how we handle UserModel.UserRemovedEvent
here: https://github.com/p2-inc/keycloak-orgs/blob/main/src/main/java/io/phasetwo/service/resource/OrganizationResourceProviderFactory.java#L157
The logic looks right, but we need to add a test to verify it's working as expected.
@cato447 I wrote a test for the issue you described, and it wouldn't reproduce the issue. Can you take a look and make sure it is doing the same thing? https://github.com/p2-inc/keycloak-orgs/blob/issue-65/src/test/java/io/phasetwo/service/resource/OrganizationResourceTest.java#L263
Are you somehow removing the user in a way that doesn't trigger a UserModel.UserRemovedEvent
provider event?
Seems good just two things:
Line 273 checks against a member count of 11 which is probably a typo https://github.com/p2-inc/keycloak-orgs/blob/issue-65/src/test/java/io/phasetwo/service/resource/OrganizationResourceTest.java#L273
I would not even revoke the role of the user explicitly. Deleting the user should automatically trigger the deletion of the role mapping in the database either programmatically on event (UserModel.UserRemovedEvent) or even better in my opinion through the schema defenition of user_organization_role_mapping and all other tables dependent on the user_id. This would even cover the deletion of a user without triggering the UserModel.UserRemovedEvent
.
I am using the intended way to remove userers through the admin-ui of Keycloak. I don't know if this triggers the Event UserModel.UserRemovedEvent
It's a 1l
("one lima") because that method requires a long
.
I am using the intended way to remove userers through the admin-ui of Keycloak
Thanks. I'll do a manual test this way and see if I can reproduce.
I agree that both the programmatic way and the database cascade are a good way to enforce the relationship. I just need to figure out how/where it is failing.
I am playing around with importing and exporting realms maybe this could be an issue?
Shouldn't have an impact. However, any reproducible test would be helpful. It's late here, and I'll investigate more tomorrow.
Closing due to lack of reproducible test. Reopen if there is more information.
I encountered a bug that prevented me from seeing which members are part of an organization in the admin-ui. It displayed a JSON Parsing issue. I sadly dont have the error message from the admin-ui at hand.
After some investigation I discovered that one of the user_ids in the organization_member table was the ID of a user i deleted. The user had some roles in the organization at the point of deletion.
Deleting the row containing the deleted user_id from the organization_member table resolved the bug.
I deleted the user through the admin ui for users provided by Keycloak.
I tried to reproduce this. It handled it correctly this time (deleting the entries refrencing this user_id from all relevant tables).