Feature/ch-220 - Add Organization Support into Cloudharness from Keycloak and support admin sync#831
Feature/ch-220 - Add Organization Support into Cloudharness from Keycloak and support admin sync#831D-GopalKrishna wants to merge 8 commits intodevelopfrom
Conversation
| is_superuser = any([admin_user for admin_user in all_admin_users if admin_user["id"] == kc_user["id"]]) | ||
| self.sync_kc_user(kc_user, is_superuser) | ||
|
|
||
| # sync the groups |
There was a problem hiding this comment.
this method is used in the admin - for sync_keycloak in both - User page or in Group page. To continue using that, i have added the sync of the organization within the same scope.
That being said, i don't like the naming of the method in that case (since its doing a lot more than just sync groups). Do you think changing the name of the method is a good idea?
I understand this will be part of a new release - but will we need a deprecated method in such case?
… sync and orgnaization member sync
| def sync_keycloak(self, request): | ||
| from cloudharness_django.services import get_user_service | ||
| get_user_service().sync_kc_users_groups() | ||
| get_user_service().sync_kc_groups() |
There was a problem hiding this comment.
this sync_kc_groups() - was removed from sync_kc_users_groups - so there's no way to sync groups if users are not already assigned to groups. This will ensure groups can be synced in the group admin panel
There was a problem hiding this comment.
We don't need to sync groups that are not assigned to users
| }) | ||
| return True | ||
| return False | ||
|
|
There was a problem hiding this comment.
these additions are unnecessary, as the pattern is to lazily sync groups/organizations together with users (and organizations were coming already)
| return False | ||
|
|
||
| @with_refreshtoken | ||
| def get_organizations(self, with_members=False) -> List[dict]: |
There was a problem hiding this comment.
There is no much use in typing when returning a List[dict] where a proper type can be used. CloudHarness defines a type for organizations
|
Closing as implemented by other means |
Closes CH-220
Implemented solution
Two models to support - Organization and OrganizationMember (to relate which user is linked to which organization)
add three sync service methods -
sync_kc_organizationsandsync_kc_organizationandsync_kc_user_organizationsextend - Keycloak
AuthClient- to support -get_organization_members,get_user_organizationsandget_organizations- NOTE - these are only introduced in the 5.4.0 or later version ofpython-keycloakpackage.Add admin sync support using - CHOrganizationAdmin -> sync button supports sync (using
sync_kc_organizations) to sync the django organizations with what's currently in Keycloak....
How to test this PR
...
Sanity checks:
Breaking changes (select one):
breaking-changeand the migration procedure is well described abovePossible deployment updates issues (select one):
alert:deploymentTest coverage (select one):
Documentation (select one):
Nice to have (if relevant):