Skip to content

Commit

Permalink
added flask-talisman to force https
Browse files Browse the repository at this point in the history
  • Loading branch information
chr-peters committed Mar 18, 2021
1 parent 9793458 commit 906a913
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ brotli==1.0.9
# via strong-but-simple-passwords (setup.py)
click==7.1.2
# via flask
flask-talisman==0.7.0
# via strong-but-simple-passwords (setup.py)
flask==1.1.2
# via strong-but-simple-passwords (setup.py)
gunicorn==20.0.4
Expand All @@ -18,6 +20,8 @@ jinja2==2.11.3
# via flask
markupsafe==1.1.1
# via jinja2
six==1.15.0
# via flask-talisman
werkzeug==1.0.1
# via flask
whitenoise==5.2.0
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
version="0.1.0",
packages=find_packages(),
include_package_data=True,
install_requires=["flask", "whitenoise", "brotli", "gunicorn"],
install_requires=["flask", "flask-talisman", "whitenoise", "brotli", "gunicorn"],
)
5 changes: 5 additions & 0 deletions strong_but_simple_passwords/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from flask import Flask
from flask_talisman import Talisman
from whitenoise import WhiteNoise
from pathlib import Path
from .config import get_config_from_env_vars
Expand All @@ -20,4 +21,8 @@ def create_app(config=None):
static_root = Path(__file__).parent / "static/"
app.wsgi_app = WhiteNoise(app.wsgi_app, root=static_root, prefix="static/")

# disable force_https during testing
force_https = not app.config["TESTING"]
Talisman(app, force_https=force_https)

return app

0 comments on commit 906a913

Please sign in to comment.