Skip to content
Snippets Groups Projects
Commit fb7fee04 authored by Diana Gudu's avatar Diana Gudu
Browse files

Merge branch 'fix-70' into 'master'

add support for additional groups

See merge request feudal/feudalAdapterLdf!90
parents 3daa9121 a9bd1d90
No related branches found
No related tags found
1 merge request!90add support for additional groups
......@@ -28,6 +28,12 @@ backend = local_unix
# authorisation!
fallback_group = nogroup
### additional_groups
# Specify additional groups for the users to be added to.
# Multiple groups can be provided as a space-separated list.
# If the groups do not exist, they will be created by the backend.
#additional_groups =
### interactive -- default: false
# If true, user may be asked to choose a primary group or to
# specify a different username.
......
......@@ -22,12 +22,10 @@ from .results import (
Deployed,
NotDeployed,
Rejection,
Failure,
Question,
raise_question,
Status,
)
from .name_generators import FriendlyNameGenerator, PooledNameGenerator, NameGenerator
from .name_generators import NameGenerator
from .userinfo import UserInfo
logger = logging.getLogger(__name__)
......@@ -102,6 +100,12 @@ class User:
backend.Group(grp) for grp in self.data.groups # type:ignore
]
self.additional_groups = [
backend.Group(grp) for grp in list(set( # type:ignore
CONFIG["ldf_adapter"].get("additional_groups", "").split()
))
]
if CONFIG.get(
"ldf_adapter", "backend_supports_preferring_existing_user", fallback=False
):
......@@ -645,7 +649,7 @@ class User:
"""
group_list = filter(
lambda grp: not grp.exists(),
[self.service_user.primary_group] + self.service_groups,
[self.service_user.primary_group] + self.service_groups + self.additional_groups,
)
for group in group_list:
if group.name is not None:
......@@ -666,6 +670,11 @@ class User:
]:
group_list.append(self.service_user.primary_group)
group_list_names = [grp.name for grp in group_list]
for grp in self.additional_groups:
if grp.name not in group_list_names:
group_list.append(grp)
if group_list[0].name is None:
config_file_name = globalconfig.info["config_files_read"]
message = (
......
......@@ -12,6 +12,7 @@ import regex
from . import logsetup
from . import eduperson
from .config import CONFIG
from .results import raise_question
logger = logging.getLogger(__name__)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment