From deed1b968541b03552278290eaeda50bf42a8112 Mon Sep 17 00:00:00 2001 From: Jose Plana Date: Wed, 1 May 2019 01:15:52 +0200 Subject: [PATCH] Don't fail if googleGroups is not found in user profile --- lemur/auth/views.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lemur/auth/views.py b/lemur/auth/views.py index 7a1bb34c..a18d37fe 100644 --- a/lemur/auth/views.py +++ b/lemur/auth/views.py @@ -129,13 +129,16 @@ def create_user_roles(profile): roles = [] # update their google 'roles' - for group in profile['googleGroups']: - role = role_service.get_by_name(group) - if not role: - role = role_service.create(group, description='This is a google group based role created by Lemur', third_party=True) - if not role.third_party: - role = role_service.set_third_party(role.id, third_party_status=True) - roles.append(role) + if 'googleGroups' in profile: + for group in profile['googleGroups']: + role = role_service.get_by_name(group) + if not role: + role = role_service.create(group, description='This is a google group based role created by Lemur', third_party=True) + if not role.third_party: + role = role_service.set_third_party(role.id, third_party_status=True) + roles.append(role) + else: + current_app.logger.warning("'googleGroups' not sent by identity provider, no specific roles will assigned to the user.") role = role_service.get_by_name(profile['email'])