diff --git a/mellon/adapters.py b/mellon/adapters.py index a895892..3ff85c5 100644 --- a/mellon/adapters.py +++ b/mellon/adapters.py @@ -314,10 +314,7 @@ class DefaultAdapter(object): except User.DoesNotExist: pass - user = None - lookup_by_attributes = utils.get_setting(idp, 'LOOKUP_BY_ATTRIBUTES') - if lookup_by_attributes: - user = self._lookup_by_attributes(idp, saml_attributes, lookup_by_attributes) + user = self.lookup_by_attributes(idp, saml_attributes) created = False if not user: @@ -343,6 +340,12 @@ class DefaultAdapter(object): logger.info('created new user %s with name_id %s from issuer %s', nameid_user, name_id, issuer) return nameid_user + def lookup_by_attributes(self, idp, saml_attributes): + rules = utils.get_setting(idp, 'LOOKUP_BY_ATTRIBUTES') + if rules: + return self._lookup_by_attributes(idp, saml_attributes, rules) + return None + def _lookup_by_attributes(self, idp, saml_attributes, lookup_by_attributes): if not isinstance(lookup_by_attributes, list): logger.error('invalid LOOKUP_BY_ATTRIBUTES configuration %r: it must be a list', lookup_by_attributes)