Projet

Général

Profil

0001-do-not-crash-if-no-idp-is-found-19260.patch

Benjamin Dauvergne, 04 juillet 2019 19:10

Télécharger (2,21 ko)

Voir les différences:

Subject: [PATCH] do not crash if no idp is found (#19260)

Also improve logging of no idp situation in default backend.
 mellon/backends.py | 9 ++++++++-
 mellon/views.py    | 3 +--
 2 files changed, 9 insertions(+), 3 deletions(-)
mellon/backends.py
14 14
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
15 15

  
16 16
from __future__ import unicode_literals
17
import logging
17 18

  
18 19
from django.contrib.auth.backends import ModelBackend
19 20

  
20 21
from . import utils
21 22

  
23
logger = logging.getLogger(__name__)
24

  
22 25

  
23 26
class SAMLBackend(ModelBackend):
24 27
    def authenticate(self, saml_attributes, request=None):
25 28
        # without an issuer we can do nothing
26 29
        if 'issuer' not in saml_attributes:
27
            return
30
            logger.debug('no idp in saml_attributes')
31
            return None
28 32
        idp = utils.get_idp(saml_attributes['issuer'])
33
        if not idp:
34
            logger.debug('unknown idp %s', saml_attributes['issuer'])
35
            return None
29 36
        adapters = utils.get_adapters(idp)
30 37
        for adapter in adapters:
31 38
            if not hasattr(adapter, 'authorize'):
mellon/views.py
130 130
            for idp in utils.get_idps():
131 131
                return idp
132 132
            else:
133
                return None
133
                return {}
134 134
        else:
135 135
            return utils.get_idp(entity_id)
136 136

  
......
305 305
                'no entity id found for this artifact %r' % artifact)
306 306
        idp = utils.get_idp(login.remoteProviderId)
307 307
        if not idp:
308
            self.log.warning('entity id %r is unknown', login.remoteProviderId)
309 308
            return HttpResponseBadRequest(
310 309
                'entity id %r is unknown' % login.remoteProviderId)
311 310
        verify_ssl_certificate = utils.get_setting(
312
-