Project

General

Profile

0003-misc-pass-SAML-identifier-model-on-login-41949.patch

Benjamin Dauvergne, 24 Apr 2020 01:22 PM

Download (1.81 KB)

View differences:

Subject: [PATCH 3/7] misc: pass SAML identifier model on login (#41949)

 mellon/adapters.py | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
mellon/adapters.py
306 306
            name_id = saml_attributes['name_id_content']
307 307
        issuer = saml_attributes['issuer']
308 308
        try:
309
            user = self.get_users_queryset(idp, saml_attributes).get(
310
                saml_identifiers__name_id=name_id,
311
                saml_identifiers__issuer=issuer)
309
            saml_identifier = models.UserSAMLIdentifier.objects.select_related('user').get(
310
                name_id=name_id,
311
                issuer=issuer)
312
            user = saml_identifier.user
313
            user.saml_identifier = saml_identifier
312 314
            logger.info('looked up user %s with name_id %s from issuer %s', user, name_id, issuer)
313 315
            return user
314
        except User.DoesNotExist:
316
        except models.UserSAMLIdentifier.DoesNotExist:
315 317
            pass
316 318

  
317 319
        user = self.lookup_by_attributes(idp, saml_attributes)
......
401 403
    def _link_user(self, idp, saml_attributes, issuer, name_id, user):
402 404
        saml_id, created = models.UserSAMLIdentifier.objects.get_or_create(
403 405
            name_id=name_id, issuer=issuer, defaults={'user': user})
406
        assert user is saml_id.user
407
        user.saml_identifier = saml_id
404 408
        if created:
405 409
            return user
406 410
        else:
411

  
407 412
            return saml_id.user
408 413

  
409 414
    def provision(self, user, idp, saml_attributes):
410
-