Ejemplo n.º 1
0
    def test_pass_salted(self):
        check = ssha.checkPassword(_passwd, _passwd_ssha512,
                                   salt_size = 8, suffixed = 1,
                                   debug = 3)
        assert check

        create = ssha.hashPassword('sha512', _passwd, _salt,
                                   8, suffixed = 1, debug = 3)

        assert create == _passwd_ssha512
 def check_pwdHistory(self, password):
     """
     if returns True means that this password was already used in the past
     """
     res = None
     for e in self.pwdHistory:
         old_pwd = e.split('#')[-1]
         res = ssha.checkPassword(password, old_pwd,
                                  settings.LDAP_PASSWORD_SALT_SIZE,
                                  'suffixed')
         if res: break
     return res
Ejemplo n.º 3
0
    def test_pass(self):
        # without salt
        check = ssha.checkPassword(_passwd, _passwd_sha,
                                   salt_size = 0, suffixed = 1,
                                   debug = 3)

        assert check

        create = ssha.hashPassword('sha', _passwd, '',
                                   0, suffixed = 1, debug = 3)

        assert create == _passwd_sha
Ejemplo n.º 4
0
def valid_login(user_id, passwd):
    server = Server(cf.LDAP_SERVER, port=cf.LDAP_PORTNO, use_ssl=cf.USE_LDAPS)
    conn = Connection(server, cf.LDAP_USER, cf.LDAP_PASSWD, auto_bind=True)
    user_filter = '(&(objectclass=inetOrgPerson)(uid=%s))' % (user_id)
    conn.search(cf.LDAP_DOMAIN,
                user_filter,
                attributes=['uid', 'userPassword'])
    for entry in conn.entries:
        data_json = json.loads(entry.entry_to_json())
        app.logger.debug("==================")
        app.logger.debug(data_json)
        app.logger.debug("==================")
        ssha_pw = data_json['attributes']['userPassword'][0]
        check = ssha.checkPassword(passwd,
                                   ssha_pw,
                                   suffixed=True,
                                   salt_size=4,
                                   debug=3)
        return check