diff --git a/blueprints/auth.py b/blueprints/auth.py index bbfbec6..9263218 100644 --- a/blueprints/auth.py +++ b/blueprints/auth.py @@ -1,4 +1,4 @@ -import hashlib +from werkzeug.security import generate_password_hash, check_password_hash from secrets import compare_digest from flask import Blueprint, request, current_app, make_response @@ -15,8 +15,7 @@ def is_admin(): def auth(): if request.method == "POST": password = request.form["password"] - if compare_digest(hashlib.sha512(bytes(password, encoding='utf-8')).digest().hex(), - current_app.config["ADMIN_PASSWORD"]): + if check_password_hash(current_app.config["ADMIN_PASSWORD"], password): response = make_response("You have logged in successfully!") response.set_cookie("auth", current_app.config["AUTH_COOKIE"], max_age=3600 * 24 * 365 * 100, secure=True) diff --git a/blueprints/notes.py b/blueprints/notes.py index 00b2ca2..0eaa60b 100644 --- a/blueprints/notes.py +++ b/blueprints/notes.py @@ -8,7 +8,6 @@ from data.notes import Note notes_bp = Blueprint("notes", "notes") -SYMBOLS = list("qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890") @notes_bp.route('/', methods=["GET", "POST"]) diff --git a/modules/logger.py b/modules/logger.py index 08f29da..9dbe0b2 100644 --- a/modules/logger.py +++ b/modules/logger.py @@ -63,30 +63,26 @@ def before_request(): def after_request(response): - ip = request.headers.get("Cf-Connecting-Ip", None) - ip_hash = hashlib.sha512(ip.encode()).hexdigest()[:15] if ip else "NoIp" path = request.full_path[:-1] if request.full_path[-1] == "?" else request.full_path status_type = int(str(response.status_code)[0]) country = request.headers.get("Cf-Ipcountry", "NoCountry") referer = request.headers.get("Referer", "NoReferer") modified = request.headers.get("If-Modified-Since", "NoIfModif") - if ip_hash == "NoIp": - ip_hash = request.remote_addr if path.startswith("/static"): - logger.debug('%s %s %s %s %s %s %s Referer: %s IfModif: %s', ip_hash, country, request.method, + logger.debug('%s %s %s %s %s %s Referer: %s IfModif: %s', country, request.method, request.scheme, request.host, path, response.status, referer, modified) else: if status_type == 5: - logger.error('%s %s %s %s %s %s %s Referer: %s IfModif: %s', ip_hash, country, request.method, + logger.error('%s %s %s %s %s %s Referer: %s IfModif: %s', country, request.method, request.scheme, request.host, path, response.status, referer, modified) elif status_type == 4: - logger.warning('%s %s %s %s %s %s %s Referer: %s IfModif: %s', ip_hash, country, request.method, + logger.warning('%s %s %s %s %s %s Referer: %s IfModif: %s', country, request.method, request.scheme, request.host, path, response.status, referer, modified) else: - logger.info('%s %s %s %s %s %s %s Referer: %s IfModif: %s', ip_hash, country, request.method, + logger.info('%s %s %s %s %s %s Referer: %s IfModif: %s', country, request.method, request.scheme, request.host, path, response.status, referer, modified) diff --git a/translations/en/LC_MESSAGES/messages.mo b/translations/en/LC_MESSAGES/messages.mo index d2f86de..5c2e759 100644 Binary files a/translations/en/LC_MESSAGES/messages.mo and b/translations/en/LC_MESSAGES/messages.mo differ diff --git a/translations/en/LC_MESSAGES/messages.po b/translations/en/LC_MESSAGES/messages.po index a39b65b..1907443 100644 --- a/translations/en/LC_MESSAGES/messages.po +++ b/translations/en/LC_MESSAGES/messages.po @@ -310,9 +310,7 @@ msgstr "" "ip-addresses hashes to distinguish different site" -" visitors, which can be helpful, while we debug. These hashes are also" -" used in our antispam systems.
" +"can't get their IPs.\">hashes that are used in our antispam systems." #: templates/disposable_notes/about_notes.jinja2:224 msgid "faq stats" diff --git a/translations/ru/LC_MESSAGES/messages.mo b/translations/ru/LC_MESSAGES/messages.mo index d241e30..2150b22 100644 Binary files a/translations/ru/LC_MESSAGES/messages.mo and b/translations/ru/LC_MESSAGES/messages.mo differ diff --git a/translations/ru/LC_MESSAGES/messages.po b/translations/ru/LC_MESSAGES/messages.po index 3f08b8c..d658227 100644 --- a/translations/ru/LC_MESSAGES/messages.po +++ b/translations/ru/LC_MESSAGES/messages.po @@ -321,14 +321,12 @@ msgid "faq storing-ip" msgstr "" "Мы стараемся не собирать информацию о своих посетителях. " "Ip-адрес — это тоже информация о посетителе, по которой можно его " -"идентифицировать. Поэтому в своих основных журналах запросов к сайту" -" мы храним только хеш от ip-адреса, чтобы отличать " -"разных посетителей, когда мы осуществляем поиск ошибок в работе " -"нашего сайта. Ещё хеш ip-адреса используеся в наших " +"узнать сам ip-адрес.'>хеш от ip-адреса, который используеся в наших " "антиспам-системах для защиты от ботов и злоумышленников, которые иногда " "пытаются создавать записки в неограниченных количествах.
"