From 8d29328103b53b9d31af73fcc6b0482c421d4888 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Gruszczy=C5=84ski?= Date: Tue, 13 May 2025 08:33:10 +0200 Subject: [PATCH] zmiany w acl --- app.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index f92906e..21ff955 100644 --- a/app.py +++ b/app.py @@ -76,8 +76,10 @@ def get_real_ip(): return request.remote_addr - def is_allowed_ip(remote_ip, allowed_hosts_str): + if remote_ip in ("127.0.0.1", "::1"): + return True + if os.path.exists("emergency_access.txt"): return True @@ -93,7 +95,6 @@ def is_allowed_ip(remote_ip, allowed_hosts_str): except Exception: continue - # Log reverse DNS dla IP odwiedzającego try: hostname = socket.gethostbyaddr(remote_ip)[0] app.logger.info(f"Odwiedzający IP: {remote_ip}, host: {hostname}") @@ -102,11 +103,19 @@ def is_allowed_ip(remote_ip, allowed_hosts_str): return remote_ip in allowed_ips + # Dodaj filtr Markdown – pozwala na zagnieżdżanie linków i obrazków w opisie @app.template_filter('markdown') def markdown_filter(text): return Markup(md.markdown(text)) +@app.context_processor +def inject_ip_allowed(): + settings = GlobalSettings.query.first() + allowed_hosts_str = settings.allowed_login_hosts if settings and settings.allowed_login_hosts else "" + client_ip = get_real_ip() + return {'is_ip_allowed': is_allowed_ip(client_ip, allowed_hosts_str)} + # TRASY PUBLICZNE @app.route('/')