AareDAQ: RHEL9 provides lowercase groups, so fix to lowercase and add unx-sls_mx to "staff" groups
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user