Show More
@@ -30,6 +30,16 b' from rhodecode.model.scm import ScmModel' | |||||
30 | log = logging.getLogger(__name__) |
|
30 | log = logging.getLogger(__name__) | |
31 |
|
31 | |||
32 |
|
32 | |||
|
33 | def _get_ip_addr(environ): | |||
|
34 | proxy_key = 'HTTP_X_REAL_IP' | |||
|
35 | proxy_key2 = 'HTTP_X_FORWARDED_FOR' | |||
|
36 | def_key = 'REMOTE_ADDR' | |||
|
37 | ||||
|
38 | return environ.get(proxy_key2, | |||
|
39 | environ.get(proxy_key, environ.get(def_key, '0.0.0.0')) | |||
|
40 | ) | |||
|
41 | ||||
|
42 | ||||
33 | class BasicAuth(AuthBasicAuthenticator): |
|
43 | class BasicAuth(AuthBasicAuthenticator): | |
34 |
|
44 | |||
35 | def __init__(self, realm, authfunc, auth_http_code=None): |
|
45 | def __init__(self, realm, authfunc, auth_http_code=None): | |
@@ -117,15 +127,7 b' class BaseVCSController(object):' | |||||
117 | return True |
|
127 | return True | |
118 |
|
128 | |||
119 | def _get_ip_addr(self, environ): |
|
129 | def _get_ip_addr(self, environ): | |
120 | proxy_key = 'HTTP_X_REAL_IP' |
|
130 | return _get_ip_addr(environ) | |
121 | proxy_key2 = 'HTTP_X_FORWARDED_FOR' |
|
|||
122 | def_key = 'REMOTE_ADDR' |
|
|||
123 |
|
||||
124 | return environ.get(proxy_key2, |
|
|||
125 | environ.get(proxy_key, |
|
|||
126 | environ.get(def_key, '0.0.0.0') |
|
|||
127 | ) |
|
|||
128 | ) |
|
|||
129 |
|
131 | |||
130 | def __call__(self, environ, start_response): |
|
132 | def __call__(self, environ, start_response): | |
131 | start = time.time() |
|
133 | start = time.time() | |
@@ -153,6 +155,7 b' class BaseController(WSGIController):' | |||||
153 |
|
155 | |||
154 | self.sa = meta.Session |
|
156 | self.sa = meta.Session | |
155 | self.scm_model = ScmModel(self.sa) |
|
157 | self.scm_model = ScmModel(self.sa) | |
|
158 | self.ip_addr = '' | |||
156 |
|
159 | |||
157 | def __call__(self, environ, start_response): |
|
160 | def __call__(self, environ, start_response): | |
158 | """Invoke the Controller""" |
|
161 | """Invoke the Controller""" | |
@@ -161,6 +164,7 b' class BaseController(WSGIController):' | |||||
161 | # available in environ['pylons.routes_dict'] |
|
164 | # available in environ['pylons.routes_dict'] | |
162 | start = time.time() |
|
165 | start = time.time() | |
163 | try: |
|
166 | try: | |
|
167 | self.ip_addr = _get_ip_addr(environ) | |||
164 | # make sure that we update permissions each time we call controller |
|
168 | # make sure that we update permissions each time we call controller | |
165 | api_key = request.GET.get('api_key') |
|
169 | api_key = request.GET.get('api_key') | |
166 | cookie_store = CookieStoreWrapper(session.get('rhodecode_user')) |
|
170 | cookie_store = CookieStoreWrapper(session.get('rhodecode_user')) |
General Comments 0
You need to be logged in to leave comments.
Login now