예제 #1
0
파일: user.py 프로젝트: katyavoid/conductor
 def __init__(self, **kwargs):
     self._salt = None
     ts = now()
     # these should be set before setting salt
     # because salt actually depends on user created_at time
     if not "created_at" in kwargs:
         kwargs["created_at"] = ts
         self.created_at = ts
     if not "updated_at" in kwargs:
         kwargs["updated_at"] = ts
         self.updated_at = ts
     if "password_raw" in kwargs:
         password_raw = kwargs["password_raw"]
         del (kwargs["password_raw"])
         kwargs["password_hash"] = pbkdf2_hex(password_raw, self.salt)
     StorableModel.__init__(self, **kwargs)
예제 #2
0
 def test_pbkdf2(self):
     for case in self.TEST_DATA:
         data, salt, iterations, keylen, expected = case
         self.assertEqual(pbkdf2_hex(data, salt, iterations, keylen),
                          expected)
예제 #3
0
파일: user.py 프로젝트: katyavoid/conductor
 def check_password(self, password_raw):
     return pbkdf2_hex(password_raw, self.salt) == self.password_hash
예제 #4
0
파일: user.py 프로젝트: katyavoid/conductor
 def set_password(self, password_raw):
     self.password_hash = pbkdf2_hex(password_raw, self.salt)
예제 #5
0
 def set_password(self, password_raw):
     # Attention! Here follows a HACK. Supposed to be removed or at least investigated
     # why hmac requires str instead of unicode
     self.password_hash = pbkdf2_hex(str(password_raw), self.salt)