Comme passlib est un peu stupide, le binding va lui mâcher le boulot

This commit is contained in:
Pierre-Elliott Bécue 2015-06-06 17:46:34 +02:00
parent 3c904e86c1
commit 583bd3d73c

View file

@ -57,6 +57,9 @@ import cranslib.deprecated
from gestion import config
from gestion import annuaires_pg
#: Format d'un hash de mdp ldap
HASH_RE = re.compile(r'{(?P<method>[a-zA-Z]+)}(?P<hash>.*)')
#: Serveur SMTP
smtpserv = "smtp.crans.org"
@ -1508,6 +1511,16 @@ class userPassword(rightProtectedAttr):
can_modify = [nounou, bureau, cableur, soi]
historique = "info"
def __unicode__(self):
"""On met en MAJUSCULES le mot clef qui indique le
type de hashage, car sinon passlib est trop con pour
comprendre"""
matched = HASH_RE.match(self.value)
groupdict = {}.update(matched.groupdict())
groupdict['method'] = groupdict['method'].upper()
return unicode("{%(method)s}%(hash)s" % groupdict)
@crans_attribute
class sshFingerprint(Attr):
__slots__ = ()