backends: return None when authorization fails, return early if no user is found

This commit is contained in:
Benjamin Dauvergne 2008-03-23 00:24:28 +01:00
parent b90059feef
commit ff15b09600
1 changed files with 4 additions and 1 deletions

View File

@ -5,6 +5,7 @@ from . import utils
class SAMLBackend(ModelBackend):
def authenticate(self, saml_attributes):
# without an issuer we can do nothing
if not 'issuer' in saml_attributes:
return
idp = utils.get_idp(saml_attributes['issuer'])
@ -13,13 +14,15 @@ class SAMLBackend(ModelBackend):
if not hasattr(adapter, 'authorize'):
continue
if not adapter.authorize(idp, saml_attributes):
return False
return
for adapter in adapters:
if not hasattr(adapter, 'lookup_user'):
continue
user = adapter.lookup_user(idp, saml_attributes)
if user:
break
else: # no user found
return
for adapter in adapters:
if not hasattr(adapter, 'provision'):
continue