def parse_and_save_digests(digests_path, passwords_content, client_id, configuration): """Check password strength and write the digest content to passwords_path using the credential digest helper. """ # TODO: validate? status, msg = True, '' if passwords_content == keyword_unchanged: return (status, msg) try: if not passwords_content: password_digest = '' else: valid_password(passwords_content) password_digest = make_digest(dav_domain, client_id, passwords_content, configuration.site_digest_salt) digests_fd = open(digests_path, 'wb') digests_fd.write(password_digest) digests_fd.close() except Exception, exc: status = False msg = 'ERROR: writing %s digests file: %s' % (client_id, exc) import traceback msg += '\n%s' % traceback.format_exc() msg += '\n%s %s %s %s' % (dav_domain, client_id, passwords_content, configuration.site_digest_salt)
def parse_and_save_digests(digests_path, passwords_content, client_id, configuration, check_valid=True): """Check password strength and write the digest content to passwords_path using the credential digest helper. The optional check_valid can be used to disable password check for basic validity as well as compliance with configured site policy. No need to do that again if already done in parse_and_save_passwords call. """ status, msg = True, '' if passwords_content == keyword_unchanged: return (status, msg) try: if not passwords_content: password_digest = '' else: if check_valid: # Make sure password is valid and complies with site policy valid_password(passwords_content) assure_password_strength(configuration, passwords_content) password_digest = make_digest(dav_domain, client_id, passwords_content, configuration.site_digest_salt) digests_fd = open(digests_path, 'wb') digests_fd.write(password_digest) digests_fd.close() except ValueError, vae: status = False msg = 'invalid password: %s' % vae
def parse_and_save_passwords(passwords_path, passwords_content, client_id, configuration): """Check password strength and write the hashed content to passwords_path using the password hashing helper. """ # TODO: validate? status, msg = True, '' if passwords_content == keyword_unchanged: return (status, msg) try: if not passwords_content: password_hash = '' else: valid_password(passwords_content) password_hash = make_hash(passwords_content) passwords_fd = open(passwords_path, 'wb') passwords_fd.write(password_hash) passwords_fd.close() except Exception, exc: status = False msg = 'ERROR: writing %s passwords file: %s' % (client_id, exc)
def valid_session_hash(arg): """Make sure only valid session hashes are allowed""" valid_password(arg, extra_chars='=', max_length=512)