Bug #6376
Boolean SAML attribute mapping values not handled
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
Historique
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]
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.
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).
Mis à jour par Serghei Mihai il y a environ 9 ans
- Fichier 0001-attributes-other-that-unicode-convertered-to-unicode.patch ajouté
Mis à jour par Serghei Mihai il y a environ 9 ans
- Fichier
0001-attributes-other-that-unicode-convertered-to-unicode.patchsupprimé
Mis à jour par Serghei Mihai il y a environ 9 ans
- Fichier 0001-boolean-attributes-convertered-to-unicode-and-lower-.patch 0001-boolean-attributes-convertered-to-unicode-and-lower-.patch ajouté
- Patch proposed changé de Non à Oui
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
Appliqué par commit 262a8a152461ce7aa17913c846b0d47f109c32c1.
Mis à jour par Benjamin Dauvergne il y a environ 9 ans
- Statut changé de Résolu (à déployer) à Fermé
boolean attributes convertered to unicode and lower-cased and the other converted to unicode
Closes #6376