mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-06-03 10:50:20 +00:00
Redirect all requests to HTTPS.
This commit is contained in:
parent
c99f074f22
commit
63045d1928
13
plinth.py
13
plinth.py
@ -29,6 +29,19 @@ __maintainer__ = "James Vasile"
|
||||
__email__ = "james@jamesvasile.com"
|
||||
__status__ = "Development"
|
||||
|
||||
|
||||
import urlparse
|
||||
|
||||
def make_secure(header="Secure"):
|
||||
secure = cherrypy.request.headers.get(header, False)
|
||||
if not secure:
|
||||
url = urlparse.urlparse(cherrypy.url())
|
||||
secure_url = urlparse.urlunsplit(('https', url[1], url[2],
|
||||
url[3], url[4]))
|
||||
raise cherrypy.HTTPRedirect(secure_url)
|
||||
|
||||
cherrypy.tools.secure = cherrypy.Tool('before_handler', make_secure)
|
||||
|
||||
def error_page(status, dynamic_msg, stock_msg):
|
||||
return u.page_template(template="err", title=status, main="<p>%s</p>%s" % (dynamic_msg, stock_msg))
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user