mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-02-05 23:50:37 +00:00
feat: add DEFAULT_GROUPS group check
This commit is contained in:
parent
7fa6887e39
commit
ea22935b88
|
@ -27,6 +27,9 @@ from selfprivacy_api.repositories.users.exceptions import (
|
|||
InvalidConfiguration,
|
||||
)
|
||||
|
||||
|
||||
DEFAULT_GROUPS = ["idm_all_persons@bloodwine.cyou", "idm_all_accounts@bloodwine.cyou"]
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
@ -155,12 +158,20 @@ def update_user(
|
|||
|
||||
if groups_to_add:
|
||||
for group in groups_to_add:
|
||||
|
||||
if group in DEFAULT_GROUPS:
|
||||
continue
|
||||
|
||||
ACTIVE_USERS_PROVIDER.add_users_to_group(
|
||||
group_name=group, users=[username]
|
||||
)
|
||||
|
||||
if groups_to_delete:
|
||||
for group in groups_to_delete:
|
||||
|
||||
if group in DEFAULT_GROUPS:
|
||||
continue
|
||||
|
||||
ACTIVE_USERS_PROVIDER.remove_users_from_group(
|
||||
group_name=group, users=[username]
|
||||
)
|
||||
|
|
|
@ -31,7 +31,7 @@ from selfprivacy_api.repositories.users.abstract_user_repository import (
|
|||
REDIS_TOKEN_KEY = "kanidm:token"
|
||||
|
||||
KANIDM_URL = "https://127.0.0.1:3013"
|
||||
ADMIN_KANIDM_GROUPS = ["sp.admin"]
|
||||
ADMIN_GROUPS = ["sp.admin"]
|
||||
|
||||
redis = RedisPool().get_connection()
|
||||
|
||||
|
@ -213,7 +213,7 @@ class KanidmUserRepository(AbstractUserRepository):
|
|||
UserDataUserOrigin: The origin type of the user (PRIMARY or NORMAL).
|
||||
"""
|
||||
|
||||
if all(group in memberof for group in ADMIN_KANIDM_GROUPS):
|
||||
if all(group in memberof for group in ADMIN_GROUPS):
|
||||
return UserDataUserOrigin.PRIMARY
|
||||
else:
|
||||
return UserDataUserOrigin.NORMAL
|
||||
|
|
Loading…
Reference in a new issue