From 21f80f089feb4338f02bec97f66389498aab69bf Mon Sep 17 00:00:00 2001 From: Tim Kreuzer <t.kreuzer@fz-juelich.de> Date: Mon, 17 Mar 2025 16:21:15 +0100 Subject: [PATCH] fix entitlements + instructor group --- jsc_custom/apihandler/workshops_manage.py | 6 +++--- jsc_custom/handler/workshop_manage.py | 6 +++--- jsc_custom/spawner/api_options_form.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/jsc_custom/apihandler/workshops_manage.py b/jsc_custom/apihandler/workshops_manage.py index 5f40134..757883a 100644 --- a/jsc_custom/apihandler/workshops_manage.py +++ b/jsc_custom/apihandler/workshops_manage.py @@ -10,7 +10,7 @@ from ..misc import get_custom_config from ..orm.workshops import WorkshopShares -def isInstructor(entitlements=[]): +def isInstructor(groups=[]): instructorGroup = ( get_custom_config() .get("workshop", {}) @@ -19,7 +19,7 @@ def isInstructor(entitlements=[]): "geant:dfn.de:fz-juelich.de:jsc:jupyter:workshop_instructors", ) ) - if instructorGroup in entitlements: + if instructorGroup in groups: return True else: return False @@ -32,7 +32,7 @@ class WorkshopManagerAPIHandler(APIHandler): if not user: raise web.HTTPError(403) auth_state = await user.get_auth_state() - if not isInstructor(auth_state.get("entitlements", [])) and workshop_id: + if not isInstructor(auth_state.get("groups", [])) and workshop_id: db_entry = WorkshopShares.find_by_workshop_id( self.db, workshop_id=workshop_id ) diff --git a/jsc_custom/handler/workshop_manage.py b/jsc_custom/handler/workshop_manage.py index 7c51ed0..d3b45aa 100644 --- a/jsc_custom/handler/workshop_manage.py +++ b/jsc_custom/handler/workshop_manage.py @@ -11,7 +11,7 @@ from ..misc import get_custom_config from ..orm.workshops import WorkshopShares -def isInstructor(entitlements=[]): +def isInstructor(groups=[]): instructorGroup = ( get_custom_config() .get("workshop", {}) @@ -20,7 +20,7 @@ def isInstructor(entitlements=[]): "geant:dfn.de:fz-juelich.de:jsc:jupyter:workshop_instructors", ) ) - if instructorGroup in entitlements: + if instructorGroup in groups: return True else: return False @@ -43,7 +43,7 @@ class WorkshopManageHandler(BaseHandler): user=user, auth_state=auth_state, db_workshops=db_workshops, - is_instructor=isInstructor(auth_state.get("entitlements", [])), + is_instructor=isInstructor(auth_state.get("groups", [])), ) self.finish(form) diff --git a/jsc_custom/spawner/api_options_form.py b/jsc_custom/spawner/api_options_form.py index 7fc9c76..192b461 100644 --- a/jsc_custom/spawner/api_options_form.py +++ b/jsc_custom/spawner/api_options_form.py @@ -121,7 +121,7 @@ class SpawnOptionsFormAPIHandler(APIHandler): system = spawner.user_options.get("system") account = spawner.user_options.get("hpc", {}).get("account") - entitlements = auth_state.get("entitlements") + entitlements = auth_state.get("oauth_user", {}).get("entitlements") ret = get_dropdown_lists(entitlements, system, account) self.write(json.dumps(ret)) -- GitLab