Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There should be a way to set HSTS headers #1329

Closed
CyBeRoni opened this issue Jun 28, 2016 · 6 comments · Fixed by #2340
Closed

There should be a way to set HSTS headers #1329

CyBeRoni opened this issue Jun 28, 2016 · 6 comments · Fixed by #2340

Comments

@CyBeRoni
Copy link
Contributor

It would be incredibly nice for TLS-enabled Zotonic websites to be able to set an HSTS (HTTP Strict-Transport-Security) headers.

The header should have a configurable max age and allow configuring other directives (such as includeSubDomains and preload) as required. If enabled, it should be included on every response served over HTTPS (taking into account possible TLS-offloading proxies.)

See also https://tools.ietf.org/html/rfc6797.

@mworrell mworrell added this to the 1.0 milestone Jul 2, 2016
@ddeboer ddeboer mentioned this issue Sep 21, 2016
21 tasks
@ddeboer
Copy link
Member

ddeboer commented Nov 7, 2016

Oddly enough, the RFC mentions only two directives, includeSubDomains and max-age; preload is only mentioned by OWASP.

We usually have a TLS terminator in front of Zotonic, in which case mod_ssl is not enabled. So either we add this to a separate module (other than mod_ssl) or we document that when a TLS terminator is used, setting the Strict-Transport-Security header should be done in that endpoint instead.

@ddeboer ddeboer removed this from the 1.0 milestone Nov 7, 2016
@mworrell
Copy link
Member

mworrell commented Nov 8, 2016

I am redoing mod_ssl a bit. My plan is to make it aware of any SSL terminator proxies in front of the site. In that case we can add these headers to mod_ssl, just like the secure flags for the cookies.

@mworrell
Copy link
Member

mworrell commented Nov 8, 2016

BTW I will need a way to see if the request originated via SSL or not. Is there any information added in haproxy (or other SSL terminators) to derive this?

@CyBeRoni
Copy link
Contributor Author

CyBeRoni commented Nov 8, 2016

RFC7239 defines such a thing.

@ddeboer
Copy link
Member

ddeboer commented Nov 8, 2016

Exactly: what used to be X-Forwarded-Proto: https has now become Forwarded: proto=https. So then the logic becomes simple: when mod_ssl is enabled, set the Strict-Transport-Security header either

  • if the current requests is over HTTPS
  • or if Forwarded: proto=https is set.

The includeSubDomain, preLoad and max-age should be configurable from the mod_ssl settings in the admin, with an (already existing) fallback to zotonic.config values.

@mworrell
Copy link
Member

mworrell commented Feb 3, 2020

Merge the changes in #2297 into master

mworrell added a commit that referenced this issue Mar 10, 2020
mworrell added a commit that referenced this issue Mar 10, 2020
* Add HSTS options. Fix #1329

* Fix rst

* Fix environment docs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants