Projet

Général

Profil

Bug #6376

Boolean SAML attribute mapping values not handled

Ajouté par Serghei Mihai il y a environ 9 ans. Mis à jour il y a environ 9 ans.

Statut:
Fermé
Priorité:
Normal
Assigné à:
-
Catégorie:
-
Version cible:
Début:
28 janvier 2015
Echéance:
% réalisé:

100%

Temps estimé:
Patch proposed:
Oui
Planning:

Description

When a boolean user attribute is declared to be sent through SAML attributes, like is_superuser, the following error is raised:

Exception Type:    AttributeError
Exception Value:    
'bool' object has no attribute 'encode'
Exception Location:    /usr/lib/python2.7/dist-packages/authentic2/saml/models.py in to_lasso_attribute, line 398


Fichiers

Révisions associées

Révision 262a8a15 (diff)
Ajouté par Serghei Mihai il y a environ 9 ans

boolean attributes convertered to unicode and lower-cased and the other converted to unicode

Closes #6376

Historique

#1

Mis à jour par Serghei Mihai il y a environ 9 ans

I guess a test like this should be performed before:

    Modified   authentic2/saml/models.py
diff --git a/authentic2/saml/models.py b/authentic2/saml/models.py
index aac57a6..caea0c3 100644
--- a/authentic2/saml/models.py
+++ b/authentic2/saml/models.py
@@ -395,6 +395,8 @@ class SAMLAttribute(models.Model):
    Modified   authentic2/saml/models.py
diff --git a/authentic2/saml/models.py b/authentic2/saml/models.py
index aac57a6..dbe66a3 100644
--- a/authentic2/saml/models.py
+++ b/authentic2/saml/models.py
@@ -395,7 +395,10 @@ class SAMLAttribute(models.Model):
         atvs = []
         for value in values:
             atv = lasso.Saml2AttributeValue()
-            value = value.encode('utf-8')
+            if isinstance(value, bool):
+                value = str(value):
+            else:
+                value = value.encode('utf-8')
             tn = lasso.MiscTextNode.newWithString(value)
             tn.textChild = True
             atv.any = [tn]

#2

Mis à jour par Frédéric Péters il y a environ 9 ans

I would do it the other way, if unicode: encode, else: str(); this will it should work for all the types.

#3

Mis à jour par Benjamin Dauvergne il y a environ 9 ans

I would prefer if boolean were coded ala XSD, i.e. lowercase true and false, and I agree with fred, just look for unicode otherwise do unicode() (or any other transformation, like for booleans).

#4

Mis à jour par Serghei Mihai il y a environ 9 ans

  • Fichier 0001-attributes-other-that-unicode-convertered-to-unicode.patch ajouté
#5

Mis à jour par Serghei Mihai il y a environ 9 ans

  • Fichier 0001-attributes-other-that-unicode-convertered-to-unicode.patch supprimé
#7

Mis à jour par Benjamin Dauvergne il y a environ 9 ans

Ack.

#8

Mis à jour par Serghei Mihai il y a environ 9 ans

  • Statut changé de Nouveau à Résolu (à déployer)
  • % réalisé changé de 0 à 100
#9

Mis à jour par Benjamin Dauvergne il y a environ 9 ans

  • Version cible mis à 2.1.12
#10

Mis à jour par Benjamin Dauvergne il y a environ 9 ans

  • Statut changé de Résolu (à déployer) à Fermé

Formats disponibles : Atom PDF