Show More
1 | NO CONTENT: new file 100644 |
|
NO CONTENT: new file 100644 |
@@ -0,0 +1,21 b'' | |||||
|
1 | class HttpsFixup(object): | |||
|
2 | def __init__(self, app): | |||
|
3 | self.application = app | |||
|
4 | ||||
|
5 | def __call__(self, environ, start_response): | |||
|
6 | self.__fixup(environ) | |||
|
7 | return self.application(environ, start_response) | |||
|
8 | ||||
|
9 | ||||
|
10 | def __fixup(self, environ): | |||
|
11 | """Function to fixup the environ as needed. In order to use this | |||
|
12 | middleware you should set this header inside your | |||
|
13 | proxy ie. nginx, apache etc. | |||
|
14 | """ | |||
|
15 | proto = environ.get('HTTP_X_URL_SCHEME') | |||
|
16 | ||||
|
17 | if proto == 'https': | |||
|
18 | environ['wsgi.url_scheme'] = proto | |||
|
19 | else: | |||
|
20 | environ['wsgi.url_scheme'] = 'http' | |||
|
21 | return None |
@@ -7,7 +7,8 b' from paste.deploy.converters import asbo' | |||||
7 | from pylons.middleware import ErrorHandler, StatusCodeRedirect |
|
7 | from pylons.middleware import ErrorHandler, StatusCodeRedirect | |
8 | from pylons.wsgiapp import PylonsApp |
|
8 | from pylons.wsgiapp import PylonsApp | |
9 | from routes.middleware import RoutesMiddleware |
|
9 | from routes.middleware import RoutesMiddleware | |
10 | from pylons_app.lib.simplehg import SimpleHg |
|
10 | from pylons_app.lib.middleware.simplehg import SimpleHg | |
|
11 | from pylons_app.lib.middleware.https_fixup import HttpsFixup | |||
11 | from pylons_app.config.environment import load_environment |
|
12 | from pylons_app.config.environment import load_environment | |
12 |
|
13 | |||
13 | def make_app(global_conf, full_stack=True, static_files=True, **app_conf): |
|
14 | def make_app(global_conf, full_stack=True, static_files=True, **app_conf): | |
@@ -42,6 +43,8 b' def make_app(global_conf, full_stack=Tru' | |||||
42 | app = SessionMiddleware(app, config) |
|
43 | app = SessionMiddleware(app, config) | |
43 |
|
44 | |||
44 |
# CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares) |
|
45 | # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares) | |
|
46 | #set the https based on HTTP_X_URL_SCHEME | |||
|
47 | app = HttpsFixup(app) | |||
45 | app = SimpleHg(app, config) |
|
48 | app = SimpleHg(app, config) | |
46 |
|
49 | |||
47 | if asbool(full_stack): |
|
50 | if asbool(full_stack): |
@@ -34,8 +34,6 b' class SimpleHg(object):' | |||||
34 | self.authenticate = AuthBasicAuthenticator(realm, authfunc) |
|
34 | self.authenticate = AuthBasicAuthenticator(realm, authfunc) | |
35 |
|
35 | |||
36 | def __call__(self, environ, start_response): |
|
36 | def __call__(self, environ, start_response): | |
37 | #dirty fix for https |
|
|||
38 | environ['wsgi.url_scheme'] = 'https' |
|
|||
39 | if not is_mercurial(environ): |
|
37 | if not is_mercurial(environ): | |
40 | return self.application(environ, start_response) |
|
38 | return self.application(environ, start_response) | |
41 | else: |
|
39 | else: |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now