Bug #3353
Error with SAML2Transient user login
100%
Description
As a SAML2 SP, at sso response, with a transient nameID, oeping a session,error when authenticating the transient user:
AttributeError at /authsaml2/singleSignOnPost
'SAML2TransientUser' object has no attribute 'pk'
Request Method: POST
Request URL: http://sp.mik.lan:8001/authsaml2/singleSignOnPost
Django Version: 1.5
Exception Type: AttributeError
Exception Value:
'SAML2TransientUser' object has no attribute 'pk'
Exception Location: /usr/local/lib/python2.7/dist-packages/django/contrib/auth/__init__.py in login, line 91
via saml2_endpoints.py in sso_after_response; 635 : auth_login(request, user)
Révisions associées
Historique
Mis à jour par Benjamin Dauvergne il y a presque 11 ans
Je suppose que django.contrib.auth regarde maintenant le champ 'pk' au lieu du champ 'id', il faut fournir les deux dans Saml2TransientUser.
Mis à jour par Mikaël Ates il y a presque 11 ans
- Statut changé de Nouveau à En cours
- Assigné à mis à Benjamin Dauvergne
Voici le patch proposé. J'ai aussi ajouté **kwargs a save qui reçoit dans notre cas un champs 'update_fields'.
diff --git a/authentic2/authsaml2/models.py b/authentic2/authsaml2/models.py
index 2e169c4..3c27b0a 100644
--- a/authentic2/authsaml2/models.py
+++ b/authentic2/authsaml2/models.py@ -5,7 +5,7
@ from django.contrib.auth.models import _user_get_all_permissions, _user_has_perm
class FakePk:
- name = '_pk'
+ name = 'pk'
class FakeMeta:
pk = FakePk()
@ -15,16 +15,18
@ class SAML2TransientUser(object):
which represent an user authenticated using a Transient
federation'''
id = None
+ pk = None
is_staff = False
is_active = False
is_superuser = False
_groups = EmptyManager()
_user_permissions = EmptyManager()
- _pk = -1
_meta = FakeMeta()
def init(self, id):
self.id = id
+ self.pk = id
def unicode(self):
return 'AnonymousUser'
@ -41,7 +43,7
@ class SAML2TransientUser(object):
def hash(self):
return 1 # instances always return the same hash value
- def save(self):
+ def save(self, **kwargs):
pass
def delete(self):
Mis à jour par Benjamin Dauvergne il y a presque 11 ans
- Assigné à changé de Benjamin Dauvergne à Mikaël Ates
Ça m'a l'air bon.
Mis à jour par Mikaël Ates il y a presque 11 ans
- Statut changé de En cours à Résolu (à déployer)
- % réalisé changé de 0 à 100
Appliqué par commit ff113d1c7581c4618a855215bf37077d7e5aaf7d.
authsaml2: fix missing pk of transient model fixes #3353.