Skip to content

Commit

Permalink
Merge pull request IdentityPython#173 from peppelinux/expired_session…
Browse files Browse the repository at this point in the history
…_acs

Expired session acs
  • Loading branch information
knaperek authored Feb 5, 2020
2 parents b47e3f2 + fca05ae commit d0e4abe
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions djangosaml2/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ def authenticate(self, request, session_info=None, attribute_mapping=None,
else:
logger.error('The nameid is not available. Cannot find user without a nameid.')
else:
saml_user = self.get_attribute_value(django_user_main_attribute, attributes, attribute_mapping)
saml_user = self.get_attribute_value(django_user_main_attribute,
attributes,
attribute_mapping)

if saml_user is None:
logger.error('Could not find saml_user value')
Expand All @@ -111,7 +113,11 @@ def get_attribute_value(self, django_field, attributes, attribute_mapping):
logger.debug('attribute_mapping: %s', attribute_mapping)
for saml_attr, django_fields in attribute_mapping.items():
if django_field in django_fields and saml_attr in attributes:
saml_user = attributes[saml_attr][0]
saml_user = attributes.get('saml_attr', [None])[0]
if not saml_user:
logger.error('attributes[saml_attr] attribute '
'value is missing. Probably the user '
'session is expired.')
return saml_user

def is_authorized(self, attributes, attribute_mapping):
Expand Down

0 comments on commit d0e4abe

Please sign in to comment.