request.requires_https, thanks Ross
This commit is contained in:
@@ -1 +1 @@
|
||||
Version 1.99.3 (2011-12-09 20:38:05) stable
|
||||
Version 1.99.3 (2011-12-09 20:46:02) stable
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
## File is released under public domain and you can use without limitations
|
||||
#########################################################################
|
||||
|
||||
## if SSL/HTTPS is properly configured and you want all HTTP requests to
|
||||
## be redirected to HTTPS, uncomment the line below:
|
||||
# request.requires_https()
|
||||
|
||||
if not request.env.web2py_runtime_gae:
|
||||
## if NOT running on Google App Engine use SQLite or other DB
|
||||
db = DAL('sqlite://storage.sqlite')
|
||||
|
||||
+12
-2
@@ -18,8 +18,8 @@ from storage import Storage, List
|
||||
from streamer import streamer, stream_file_or_304_or_206, DEFAULT_CHUNK_SIZE
|
||||
from xmlrpc import handler
|
||||
from contenttype import contenttype
|
||||
from html import xmlescape, TABLE, TR, PRE
|
||||
from http import HTTP
|
||||
from html import xmlescape, TABLE, TR, PRE, URL
|
||||
from http import HTTP, redirect
|
||||
from fileutils import up
|
||||
from serializers import json, custom_json
|
||||
import settings
|
||||
@@ -109,6 +109,16 @@ class Request(Storage):
|
||||
for key,value in user_agent.items():
|
||||
if isinstance(value,dict): user_agent[key] = Storage(value)
|
||||
return user_agent
|
||||
|
||||
def requires_https(self):
|
||||
"""
|
||||
If request comes in over HTTP, redirect it to HTTPS
|
||||
and secure the session.
|
||||
"""
|
||||
if not global_settings.cronjob and not self.is_https:
|
||||
redirect(URL(scheme='https', args=self.args, vars=self.vars))
|
||||
|
||||
current.session.secure()
|
||||
|
||||
def restful(self):
|
||||
def wrapper(action,self=self):
|
||||
|
||||
Reference in New Issue
Block a user