Exemplo n.º 1
0
 def authorize(self, auth_info):
     username, password = auth_info
     if username in self.dict:
         stored_password = self.dict[username]
         if stored_password.startswith('{SHA}'):
             password_hash = sha1(as_bytes(password)).hexdigest()
             return stored_password[5:] == password_hash
         else:
             return stored_password == password
     else:
         return False
Exemplo n.º 2
0
 def authorize(self, auth_info):
     username, password = auth_info
     if username in self.dict:
         stored_password = self.dict[username]
         if stored_password.startswith('{SHA}'):
             password_hash = sha1(as_bytes(password)).hexdigest()
             return stored_password[5:] == password_hash
         else:
             return stored_password == password
     else:
         return False
Exemplo n.º 3
0
 def test_authorize_gooduser_goodpassword_sha(self):
     password = '******' + sha1(as_bytes('password')).hexdigest()
     authorizer = self._makeOne({'foo': password})
     self.assertTrue(authorizer.authorize(('foo', 'password')))
Exemplo n.º 4
0
 def test_authorize_gooduser_goodpassword_sha(self):
     password = '******' + sha1(as_bytes('password')).hexdigest()
     authorizer = self._makeOne({'foo':password})
     self.assertTrue(authorizer.authorize(('foo', 'password')))