From 37d5de9d679b8041b08aad19804b8b3020c4d2a5 Mon Sep 17 00:00:00 2001 From: kageru <8497max@gmail.com> Date: Wed, 18 Oct 2017 12:49:48 +0200 Subject: [PATCH] finished simple auth system --- add_user.py | 8 +++++++- pyshare_receiver.py | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/add_user.py b/add_user.py index 69e74a0..1f28e0f 100644 --- a/add_user.py +++ b/add_user.py @@ -2,6 +2,9 @@ # It only generates a string that you can copy-paste into users.py from pyshare_receiver import salthash +from pyshare import character_pool +from random import choices + import sys @@ -13,4 +16,7 @@ if __name__ == '__main__': ''') sys.exit(0) else: - print() \ No newline at end of file + username, password = sys.argv[1:] + salt = choices(character_pool, k=10) + hash = salthash(password, salt) + print(f" '{username}': ['{hash}', '{salt}'],") diff --git a/pyshare_receiver.py b/pyshare_receiver.py index 3644946..2adfcf4 100644 --- a/pyshare_receiver.py +++ b/pyshare_receiver.py @@ -5,6 +5,7 @@ from flask import Flask, request from werkzeug.utils import secure_filename from hashlib import sha3_256 from users import users +import config app = Flask(__name__) @@ -33,7 +34,7 @@ def receive_file() -> tuple: file = request.files.get('file') filename = secure_filename(file.filename) file.save(filename) - return filename, 201 + return config.url_template.format(filename), 201 else: return 'Wrong or no credentials', 403 return 'you\'re doing this wrong', 418