Skip to content

Commit

Permalink
don't rely to groups claim being in token
Browse files Browse the repository at this point in the history
  • Loading branch information
vbrik committed Apr 12, 2024
1 parent 175af8e commit b08c286
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions user_mgmt/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ async def is_associate(self, experiment, username):

def is_super_admin(self):
"""Is the current user a super admin?"""
return '/admin' in self.auth_data['groups']
return '/admin' in self.auth_data.get('groups', [])

async def get_admins(self, group_path):
ret = await self.group_cache.get_members(group_path+'/_admin')
Expand Down Expand Up @@ -110,7 +110,7 @@ async def get_admin_groups(self):
if self.is_super_admin(): # super admin - all groups
admin_groups = await self.group_cache.list_groups()
else:
admin_groups = [g[:-7] for g in self.auth_data['groups'] if g.endswith('/_admin')]
admin_groups = [g[:-7] for g in self.auth_data.get('groups', []) if g.endswith('/_admin')]
groups = set()
for group in admin_groups:
val = group.strip('/').split('/')
Expand All @@ -130,7 +130,7 @@ async def get_admin_institutions(self):
val = group.split('/')
insts[val[2]].append(val[3])
else:
admin_groups = [g[:-7] for g in self.auth_data['groups'] if g.endswith('/_admin')]
admin_groups = [g[:-7] for g in self.auth_data.get('groups', []) if g.endswith('/_admin')]
insts = defaultdict(list)
for group in admin_groups:
val = group.strip('/').split('/')
Expand Down

0 comments on commit b08c286

Please sign in to comment.