##// END OF EJS Templates
Add ip reference into BaseController
marcink -
r2374:be2163ef beta
parent child Browse files
Show More
@@ -30,6 +30,16 b' from rhodecode.model.scm import ScmModel'
30 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 43 class BasicAuth(AuthBasicAuthenticator):
34 44
35 45 def __init__(self, realm, authfunc, auth_http_code=None):
@@ -117,15 +127,7 b' class BaseVCSController(object):'
117 127 return True
118 128
119 129 def _get_ip_addr(self, environ):
120 proxy_key = 'HTTP_X_REAL_IP'
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 )
130 return _get_ip_addr(environ)
129 131
130 132 def __call__(self, environ, start_response):
131 133 start = time.time()
@@ -153,6 +155,7 b' class BaseController(WSGIController):'
153 155
154 156 self.sa = meta.Session
155 157 self.scm_model = ScmModel(self.sa)
158 self.ip_addr = ''
156 159
157 160 def __call__(self, environ, start_response):
158 161 """Invoke the Controller"""
@@ -161,6 +164,7 b' class BaseController(WSGIController):'
161 164 # available in environ['pylons.routes_dict']
162 165 start = time.time()
163 166 try:
167 self.ip_addr = _get_ip_addr(environ)
164 168 # make sure that we update permissions each time we call controller
165 169 api_key = request.GET.get('api_key')
166 170 cookie_store = CookieStoreWrapper(session.get('rhodecode_user'))
General Comments 0
You need to be logged in to leave comments. Login now