zmiany w acl
This commit is contained in:
parent
748b4e47a2
commit
8d29328103
13
app.py
13
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('/')
|
||||
|
Loading…
x
Reference in New Issue
Block a user