witten
/
luminotes
Archived
1
0
Fork 0

Checking the start of the requested URL to determine whether it was an https

request simply didn't work. Apache doesn't forward that information. So
instead, I'm now using a hacky work-around that looks at the proxy IP to
determine whether it was an http or https request.

Still need to fix unit tests for this.
This commit is contained in:
Dan Helfman 2007-08-03 19:29:20 +00:00
parent 9e0b611790
commit ccb81d18ee
2 changed files with 5 additions and 1 deletions

View File

@ -17,5 +17,7 @@ settings = {
"decoding_filter.encoding": "utf-8",
"luminotes.http_url": "",
"luminotes.https_url": "",
"luminotes.http_proxy_ip": "127.0.0.1",
"luminotes.https_proxy_ip": "127.0.0.2",
},
}

View File

@ -28,7 +28,9 @@ class Root( object ):
"""
# if the user is logged in and not using https, then redirect to the https version of the page (if available)
https_url = self.__settings[ u"global" ].get( u"luminotes.https_url" )
if cherrypy.session.get( "user_id" ) and https_url and not cherrypy.request.browser_url.startswith( https_url ):
https_proxy_ip = self.__settings[ u"global" ].get( u"luminotes.https_proxy_ip" )
if cherrypy.session.get( "user_id" ) and https_url and cherrypy.request.remote_addr != https_proxy_ip:
return dict( redirect = https_url )
return dict()