fix: from review

This commit is contained in:
dettlaff 2024-12-23 16:47:35 +04:00
parent b864ca5fea
commit b83a448e94
3 changed files with 7 additions and 8 deletions

View file

@ -9,7 +9,7 @@ from selfprivacy_api.utils.strings import PLEASE_UPDATE_APP_TEXT
from selfprivacy_api.models.group import Group from selfprivacy_api.models.group import Group
from selfprivacy_api.models.user import UserDataUser, UserDataUserOrigin from selfprivacy_api.models.user import UserDataUser, UserDataUserOrigin
from selfprivacy_api.utils import is_username_forbidden from selfprivacy_api.utils import get_domain, is_username_forbidden
from selfprivacy_api.actions.ssh import get_ssh_keys from selfprivacy_api.actions.ssh import get_ssh_keys
@ -27,8 +27,9 @@ from selfprivacy_api.repositories.users.exceptions import (
InvalidConfiguration, InvalidConfiguration,
) )
domain = get_domain()
DEFAULT_GROUPS = ["idm_all_persons@bloodwine.cyou", "idm_all_accounts@bloodwine.cyou"] DEFAULT_GROUPS = [f"idm_all_persons@{domain}", "idm_all_accounts@{domain}"]
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -89,9 +90,7 @@ def create_user(
if password: if password:
logger.error(PLEASE_UPDATE_APP_TEXT) logger.error(PLEASE_UPDATE_APP_TEXT)
if ( if displayname and len(displayname) >= 255:
displayname and len(displayname) >= 32
): # we don't know the limitations of each service
raise DisplaynameTooLong raise DisplaynameTooLong
# need to maintain the logic of the old repository, since ssh management uses it. # need to maintain the logic of the old repository, since ssh management uses it.
@ -148,7 +147,7 @@ def update_user(
if displayname: if displayname:
if isinstance(ACTIVE_USERS_PROVIDER, JsonUserRepository): if isinstance(ACTIVE_USERS_PROVIDER, JsonUserRepository):
raise ApiUsingWrongUserRepository raise ApiUsingWrongUserRepository
if len(displayname) >= 512: # we don't know the limitations of each service if len(displayname) >= 255:
raise DisplaynameTooLong raise DisplaynameTooLong
ACTIVE_USERS_PROVIDER.update_user( ACTIVE_USERS_PROVIDER.update_user(

View file

@ -32,7 +32,7 @@ from selfprivacy_api.repositories.users.abstract_user_repository import (
REDIS_TOKEN_KEY = "kanidm:token" REDIS_TOKEN_KEY = "kanidm:token"
KANIDM_URL = "https://127.0.0.1:3013" KANIDM_URL = "https://127.0.0.1:3013"
ADMIN_GROUPS = ["idm_admins@bloodwine.cyou"] ADMIN_GROUPS = ["sp.admin"]
redis = RedisPool().get_connection() redis = RedisPool().get_connection()