From 572fcbed6da6872e1b4237f1a7f9fa0097032cf8 Mon Sep 17 00:00:00 2001 From: Scott Wallace Date: Tue, 28 Dec 2021 16:13:33 +0000 Subject: [PATCH] Small fixes --- Dockerfile | 1 + config.yaml | 2 ++ requirements.txt | 1 + slinky/templates/list.html | 2 +- slinky/web.py | 2 +- 5 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0783579..725f6e6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,4 +33,5 @@ EXPOSE 8080/tcp # Copy in the code COPY slinky slinky/ COPY templates templates/ +COPY config.yaml . COPY main.py . diff --git a/config.yaml b/config.yaml index 710c173..53abaeb 100644 --- a/config.yaml +++ b/config.yaml @@ -1,2 +1,4 @@ --- db: sqlite:///slinky.db +allowed_ips: + - 127.0.0.1 diff --git a/requirements.txt b/requirements.txt index 5a5c7fe..555122e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ flask flask_bootstrap flask_wtf +psycopg2-binary pyyaml waitress Flask-SQLAlchemy diff --git a/slinky/templates/list.html b/slinky/templates/list.html index f9fd973..7c4a29b 100644 --- a/slinky/templates/list.html +++ b/slinky/templates/list.html @@ -3,7 +3,7 @@
-

Add a shortcode

+

Shortcodes


diff --git a/slinky/web.py b/slinky/web.py index 98342c8..8a6166f 100644 --- a/slinky/web.py +++ b/slinky/web.py @@ -82,7 +82,7 @@ def protect(func: Callable[..., Response]) -> Callable[..., Response]: @wraps(func) def check_ip(*args: Any, **kwargs: Any) -> Response: - if request.remote_addr not in cfg['allowed_ips']: + if request.headers['X-Forwarded-For'] not in cfg['allowed_ips']: print(f'Protected URL access attempt from {request.remote_addr}') return Response('Not found', 404) return func(*args, **kwargs)