p2-inc / keycloak-orgs

Single realm, multi-tenancy for SaaS apps
https://phasetwo.io
Other
401 stars 68 forks source link

review admin events for org methods #1

Closed xgp closed 6 months ago

xgp commented 2 years ago

Events are not consistently emitted for org methods. This is a placeholder for:

  1. documenting what is there
  2. todos for additions
xgp commented 1 year ago

We should have the following admin events:

xgp commented 1 year ago
    adminEvent.operation(OperationType.CREATE).resourcePath(session.getContext().getUri(), child.getId());
    adminEvent.operation(OperationType.CREATE).resourcePath(session.getContext().getUri(), user.getId()).representation(rep).success();
xgp commented 1 year ago

There seem to be some problems with our resourcePath method usage that are causing a duplication of resource id in the path. Also need to bring inline with expectations from Keycloak event types (e.g. no representation when it's a DELETE). Need to review and add unit tests.

xgp commented 6 months ago
  1. validate that all expected events are present. add them if not.
  2. validate that the content of the events is consistent
  3. add documentation linked to the README explaining which Admin and Login event types are emitted and when
xgp commented 6 months ago

Possible to load a test EventListener implementation into a Realm you create in the integration test.

  1. Run the org API method
  2. Check the EventListener to see if the expected event and content were emitted.

If you make the test EventListener in the src/test/java, you will need to add target/test-classes to testcontainers to load the extension, in order to make it available to be activated by the Realm. https://github.com/p2-inc/keycloak-orgs/blob/main/src/test/java/io/phasetwo/service/AbstractOrganizationTest.java#L81

xgp commented 6 months ago

Completed in https://github.com/p2-inc/keycloak-orgs/pull/181 🥇 @rtufisi