# HG changeset patch # User Marcin Kuzminski # Date 2013-01-27 22:37:55 # Node ID 26bf9c8baad2357f584fd803760b65f689bededa # Parent f5dd76e2a7af3769c7bc05ab364adf3810b71148 added HSTS headers when using SSL for RhodeCode diff --git a/rhodecode/lib/middleware/https_fixup.py b/rhodecode/lib/middleware/https_fixup.py --- a/rhodecode/lib/middleware/https_fixup.py +++ b/rhodecode/lib/middleware/https_fixup.py @@ -23,6 +23,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +from pylons.controllers.util import Request from rhodecode.lib.utils2 import str2bool @@ -34,7 +35,11 @@ class HttpsFixup(object): def __call__(self, environ, start_response): self.__fixup(environ) - return self.application(environ, start_response) + req = Request(environ) + resp = req.get_response(self.application) + if environ['wsgi.url_scheme'] == 'https': + resp.headers['Strict-Transport-Security'] = 'max-age=8640000; includeSubDomains' + return resp(environ, start_response) def __fixup(self, environ): """