mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-01-31 05:06:41 +00:00
fix: ignoring default groups in get_users
This commit is contained in:
parent
5b2491d160
commit
74c8118f9f
|
@ -177,6 +177,10 @@ class KanidmUserRepository(AbstractUserRepository):
|
||||||
Repository for managing users through Kanidm.
|
Repository for managing users through Kanidm.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _remove_default_groups(groups: list) -> list:
|
||||||
|
return [item for item in groups if item not in DEFAULT_GROUPS]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _check_response_type_and_not_empty(data_type: str, response_data: Any) -> None:
|
def _check_response_type_and_not_empty(data_type: str, response_data: Any) -> None:
|
||||||
"""
|
"""
|
||||||
|
@ -401,12 +405,15 @@ class KanidmUserRepository(AbstractUserRepository):
|
||||||
if exclude_primary and user_type == UserDataUserOrigin.PRIMARY:
|
if exclude_primary and user_type == UserDataUserOrigin.PRIMARY:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
directmemberof = KanidmUserRepository._remove_default_groups(groups=user_attrs.get("directmemberof", []))
|
||||||
|
memberof = KanidmUserRepository._remove_default_groups(groups=user_attrs.get("memberof", []))
|
||||||
|
|
||||||
filled_user = UserDataUser(
|
filled_user = UserDataUser(
|
||||||
username=user_attrs["name"][0],
|
username=user_attrs["name"][0],
|
||||||
user_type=user_type,
|
user_type=user_type,
|
||||||
ssh_keys=[], # actions layer will fill in this field
|
ssh_keys=[], # actions layer will fill in this field
|
||||||
directmemberof=user_attrs.get("directmemberof", []),
|
directmemberof=directmemberof,
|
||||||
memberof=user_attrs.get("memberof", []),
|
memberof=memberof,
|
||||||
displayname=user_attrs.get("displayname", [None])[0],
|
displayname=user_attrs.get("displayname", [None])[0],
|
||||||
email=user_attrs.get("mail", [None])[0],
|
email=user_attrs.get("mail", [None])[0],
|
||||||
)
|
)
|
||||||
|
@ -512,14 +519,8 @@ class KanidmUserRepository(AbstractUserRepository):
|
||||||
|
|
||||||
attrs = user_data["attrs"] # type: ignore
|
attrs = user_data["attrs"] # type: ignore
|
||||||
|
|
||||||
directmemberof = [
|
directmemberof = KanidmUserRepository._remove_default_groups(groups=attrs.get("directmemberof", []))
|
||||||
item
|
memberof = KanidmUserRepository._remove_default_groups(groups=attrs.get("memberof", []))
|
||||||
for item in attrs.get("directmemberof", [])
|
|
||||||
if item not in DEFAULT_GROUPS
|
|
||||||
]
|
|
||||||
memberof = [
|
|
||||||
item for item in attrs.get("memberof", []) if item not in DEFAULT_GROUPS
|
|
||||||
]
|
|
||||||
|
|
||||||
return UserDataUser(
|
return UserDataUser(
|
||||||
username=attrs["name"][0],
|
username=attrs["name"][0],
|
||||||
|
|
Loading…
Reference in a new issue