diff options
| author | LV-426 <lv-426@taproot.org.il> | 2015-01-13 01:52:35 +0200 |
|---|---|---|
| committer | LV-426 <lv-426@taproot.org.il> | 2015-01-13 01:52:35 +0200 |
| commit | de29536fa1fc8d57c522637250c294027cb4ebef (patch) | |
| tree | 9a7d948bb3f5c45ff2092b3fff97433a7e97bba2 /src/server/crypt_util.py | |
| parent | e6ab11939fa2055224243676ee31332ed48b39d5 (diff) | |
mv init_pw_db to rz_cli_tool, improve
Diffstat (limited to 'src/server/crypt_util.py')
| -rw-r--r-- | src/server/crypt_util.py | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/server/crypt_util.py b/src/server/crypt_util.py index 464fac94..7eec4c57 100644 --- a/src/server/crypt_util.py +++ b/src/server/crypt_util.py @@ -1,23 +1,17 @@ -import pickle import hashlib, uuid -import os import logging +import pickle -log = logging.getLogger('rhizi') -def add_user_login(config, u, p): - htpasswd_path = config.htpasswd_path +log = logging.getLogger('rhizi') - if False == os.path.exists(htpasswd_path): - with open(htpasswd_path, 'wb') as f: - pickle.dump({}, f) +def add_user_login(htpasswd_path, salt, u, p): with open(htpasswd_path, 'rb') as f: data = f.read() pw_db = pickle.loads(data) with open(htpasswd_path, 'wb') as f: - salt = config.secret_key pw_db[u] = hash_pw(str(p), salt) pickle.dump(pw_db, f) @@ -38,9 +32,9 @@ def validate_login(config, u, p): existing_pw_hash = pw_db.get(u) if None == existing_pw_hash: - raise Exception('Not autorhized') + raise Exception('Not authorized') if hash_pw(p, salt) != existing_pw_hash: - raise Exception('Not autorhized') + raise Exception('Not authorized') |
