-
Notifications
You must be signed in to change notification settings - Fork 5
Feature/ch-220 - Add Organization Support into Cloudharness from Keycloak and support admin sync #831
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to sync groups that are not assigned to users
| }) | ||
| return True | ||
| return False | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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):