DAQ: authenticate for super users added
This commit is contained in:
@@ -21,7 +21,7 @@ ACCESS_TOKEN_EXPIRE_MINUTES = 24 * 60 * 7 # 1 week
|
||||
SESSION_EXPIRE_SECONDS = 60 * 10
|
||||
|
||||
STAFF_GROUP = "unx-MXgroup"
|
||||
|
||||
SUPER_USERS = ["e10019", "e11206", "e18147"]
|
||||
|
||||
class TokenData(BaseModel):
|
||||
sub: str # Username
|
||||
@@ -42,9 +42,9 @@ def authenticate_user(cfg: BeamlineConfig, form_data: OAuth2PasswordRequestForm)
|
||||
|
||||
groups = os.getgrouplist(user_info.pw_name, user_info.pw_gid)
|
||||
supplementary_groups = [grp.getgrgid(g).gr_name.lower() for g in groups]
|
||||
|
||||
super_user = form_data.username in SUPER_USERS
|
||||
pgroups = [group for group in supplementary_groups if group.startswith('p')]
|
||||
staff = "unx-mxgroup" in supplementary_groups or "unx-sls_mx" in supplementary_groups
|
||||
staff = "unx-mxgroup" in supplementary_groups or "unx-sls_mx" in supplementary_groups or super_user
|
||||
token = TokenData(sub=form_data.username,
|
||||
pgroups=pgroups,
|
||||
staff=staff,
|
||||
|
||||
Reference in New Issue
Block a user