Skip to content
This repository has been archived by the owner on Dec 23, 2017. It is now read-only.

Force HTTPS and HSTS when configured to do so #117

Merged
merged 3 commits into from
May 4, 2015
Merged

Force HTTPS and HSTS when configured to do so #117

merged 3 commits into from
May 4, 2015

Conversation

konklone
Copy link
Contributor

@konklone konklone commented May 1, 2015

This uses flask-sslify to force HTTPS and add HSTS, when an environment variable -- FEC_FORCE_HTTPS -- is set.

As configured, this sets HSTS for 1 year, and includes subdomains. It should only be used on domains where you can guarantee that all subdomains are also available over HTTPS. This could be made configurable with additional variables, but it seemed like the smallest amount of overhead.

The HSTS header will only be sent over HTTPS, and will only take effect if the browser successfully connects over HTTPS. So there's no risk of bricking localhost or whatever.

Fixes https://github.com/18F/openFEC/issues/619.

@konklone
Copy link
Contributor Author

konklone commented May 1, 2015

This also contains a commit that ignores .env, used by one of Kenneth Reitz's other popular tools, autoenv.

Conflicts:
	__init__.py
@konklone
Copy link
Contributor Author

konklone commented May 1, 2015

And, I've updated the branch to resolve the merge conflict. This should be good for review and merge any time.

@@ -8,3 +8,4 @@ static/js/app.js
openfecwebapp/local_config.py
static/styles/styles.css.map
app/
/.env
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No complaints here, but kind of thing can also go in a global .gitignore, since not everyone uses autoenv. Even though it's great.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Good call for future stuff, I honestly had not thought of that.

@jmcarp jmcarp merged commit 921703c into develop May 4, 2015
@konklone konklone deleted the https branch July 10, 2015 04:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants