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
def test_authorize_gooduser_goodpassword_sha(self): password = '******' + sha1(as_bytes('password')).hexdigest() authorizer = self._makeOne({'foo': password}) self.assertTrue(authorizer.authorize(('foo', 'password')))
def test_authorize_gooduser_goodpassword_sha(self): password = '******' + sha1(as_bytes('password')).hexdigest() authorizer = self._makeOne({'foo':password}) self.assertTrue(authorizer.authorize(('foo', 'password')))