From 934c4877b2c073431a93a3009e1dcaf8741dbff8 Mon Sep 17 00:00:00 2001 From: "max.mehl" Date: Wed, 19 May 2021 09:17:41 +0200 Subject: [PATCH] add password protection --- .gitignore | 1 + autoreply_editor/__init__.py | 2 +- autoreply_editor/config.py | 1 - autoreply_editor/main.py | 3 +++ config.sample.py | 6 ++++++ message.txt.sample | 6 ++++++ requirements.txt | 3 +++ 7 files changed, 20 insertions(+), 2 deletions(-) delete mode 100644 autoreply_editor/config.py create mode 100644 config.sample.py create mode 100644 message.txt.sample create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore index fb88a0e..f0a8630 100644 --- a/.gitignore +++ b/.gitignore @@ -143,3 +143,4 @@ cython_debug/ # Project specific message.txt +config.py diff --git a/autoreply_editor/__init__.py b/autoreply_editor/__init__.py index d04e2f3..9724f03 100644 --- a/autoreply_editor/__init__.py +++ b/autoreply_editor/__init__.py @@ -4,4 +4,4 @@ app = Flask(__name__) import autoreply_editor.main -app.config.from_pyfile("config.py") +app.config.from_pyfile("../config.py") diff --git a/autoreply_editor/config.py b/autoreply_editor/config.py deleted file mode 100644 index 53a1f57..0000000 --- a/autoreply_editor/config.py +++ /dev/null @@ -1 +0,0 @@ -MESSAGE_FILE = "message.txt" diff --git a/autoreply_editor/main.py b/autoreply_editor/main.py index 9cd7530..60eda6a 100644 --- a/autoreply_editor/main.py +++ b/autoreply_editor/main.py @@ -1,5 +1,8 @@ from autoreply_editor import app from flask import Flask, request, render_template, redirect +from flask_basicauth import BasicAuth + +basic_auth = BasicAuth(app) @app.route("/") def index(): diff --git a/config.sample.py b/config.sample.py new file mode 100644 index 0000000..7daad5e --- /dev/null +++ b/config.sample.py @@ -0,0 +1,6 @@ +"""Configuration file""" + +MESSAGE_FILE = "message.txt" +BASIC_AUTH_FORCE = True +BASIC_AUTH_USERNAME = "username" +BASIC_AUTH_PASSWORD = "password" diff --git a/message.txt.sample b/message.txt.sample new file mode 100644 index 0000000..bc8e8b8 --- /dev/null +++ b/message.txt.sample @@ -0,0 +1,6 @@ +Hello, + +This is my autoreply message. + +Best, +Me diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..9550338 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +Flask +Flask-BasicAuth +gunicorn