AareDAQ: RHEL9 provides lowercase groups, so fix to lowercase and add unx-sls_mx to "staff" groups

This commit is contained in:
2025-09-25 09:03:01 +02:00
parent 9e223d0fd6
commit b116641d9f
+3 -4
View File
@@ -37,16 +37,15 @@ def authenticate_user(cfg: BeamlineConfig, form_data: OAuth2PasswordRequestForm)
user_info = pwd.getpwnam(form_data.username)
groups = os.getgrouplist(user_info.pw_name, user_info.pw_gid)
supplementary_groups = [grp.getgrgid(g).gr_name for g in groups]
supplementary_groups = [grp.getgrgid(g).gr_name.lower() for g in groups]
pgroups = [group for group in supplementary_groups if group.startswith('p')]
staff = "unx-MXgroup" in supplementary_groups
pgroups.append("p20000")
staff = "unx-mxgroup" in supplementary_groups or "unx-sls_mx" in supplementary_groups
token = TokenData(sub=form_data.username,
pgroups=pgroups,
staff=staff,
session=cfg.generate_session())
print(f"User {form_data.username} groups: {groups} supplementary groups: {supplementary_groups} pgroups: {pgroups} staff: {staff}")
return create_access_token(token)