diff --git a/mellon/backends.py b/mellon/backends.py index 0e4726b..add3c49 100644 --- a/mellon/backends.py +++ b/mellon/backends.py @@ -14,19 +14,26 @@ # along with this program. If not, see . from __future__ import unicode_literals +import logging from django.contrib.auth.backends import ModelBackend from . import utils +logger = logging.getLogger(__name__) + class SAMLBackend(ModelBackend): def authenticate(self, request=None, **credentials): saml_attributes = credentials.get('saml_attributes') or {} # without an issuer we can do nothing if 'issuer' not in saml_attributes: - return + logger.debug('no idp in saml_attributes') + return None idp = utils.get_idp(saml_attributes['issuer']) + if not idp: + logger.debug('unknown idp %s', saml_attributes['issuer']) + return None adapters = utils.get_adapters(idp) for adapter in adapters: if not hasattr(adapter, 'authorize'): diff --git a/mellon/views.py b/mellon/views.py index 1d8d08b..637fcd7 100644 --- a/mellon/views.py +++ b/mellon/views.py @@ -130,7 +130,7 @@ class LoginView(ProfileMixin, LogMixin, View): for idp in utils.get_idps(): return idp else: - return None + return {} else: return utils.get_idp(entity_id) @@ -305,7 +305,6 @@ class LoginView(ProfileMixin, LogMixin, View): 'no entity id found for this artifact %r' % artifact) idp = utils.get_idp(login.remoteProviderId) if not idp: - self.log.warning('entity id %r is unknown', login.remoteProviderId) return HttpResponseBadRequest( 'entity id %r is unknown' % login.remoteProviderId) verify_ssl_certificate = utils.get_setting(