##// END OF EJS Templates
http: set REMOTE_USER and REMOTE_HOST http variables....
marcink -
r269:413e285e default
parent child Browse files
Show More
@@ -23,6 +23,7 b' import wsgiref.util'
23 import traceback
23 import traceback
24 from itertools import chain
24 from itertools import chain
25
25
26 import simplejson as json
26 import msgpack
27 import msgpack
27 from beaker.cache import CacheManager
28 from beaker.cache import CacheManager
28 from beaker.util import parse_cache_config_options
29 from beaker.util import parse_cache_config_options
@@ -311,6 +312,25 b' class HTTPApplication(object):'
311 return value
312 return value
312 return _render
313 return _render
313
314
315 def set_env_from_config(self, environ, config):
316 dict_conf = {}
317 try:
318 for elem in config:
319 if elem[0] == 'rhodecode':
320 dict_conf = json.loads(elem[2])
321 break
322 except Exception:
323 log.exception('Failed to fetch SCM CONFIG')
324 return
325
326 username = dict_conf.get('username')
327 if username:
328 environ['REMOTE_USER'] = username
329
330 ip = dict_conf.get('ip')
331 if ip:
332 environ['REMOTE_HOST'] = ip
333
314 def hg_proxy(self):
334 def hg_proxy(self):
315 @wsgiapp
335 @wsgiapp
316 def _hg_proxy(environ, start_response):
336 def _hg_proxy(environ, start_response):
@@ -344,9 +364,11 b' class HTTPApplication(object):'
344 app = scm_app.create_hg_wsgi_app(
364 app = scm_app.create_hg_wsgi_app(
345 repo_path, repo_name, config)
365 repo_path, repo_name, config)
346
366
347 # Consitent path information for hgweb
367 # Consistent path information for hgweb
348 environ['PATH_INFO'] = environ['HTTP_X_RC_PATH_INFO']
368 environ['PATH_INFO'] = environ['HTTP_X_RC_PATH_INFO']
349 environ['REPO_NAME'] = repo_name
369 environ['REPO_NAME'] = repo_name
370 self.set_env_from_config(environ, config)
371
350 log.debug('http-app: starting app handler '
372 log.debug('http-app: starting app handler '
351 'with %s and process request', app)
373 'with %s and process request', app)
352 return app(environ, ResponseFilter(start_response))
374 return app(environ, ResponseFilter(start_response))
@@ -370,6 +392,8 b' class HTTPApplication(object):'
370 config = msgpack.unpackb(packed_config)
392 config = msgpack.unpackb(packed_config)
371
393
372 environ['PATH_INFO'] = environ['HTTP_X_RC_PATH_INFO']
394 environ['PATH_INFO'] = environ['HTTP_X_RC_PATH_INFO']
395 self.set_env_from_config(environ, config)
396
373 content_type = environ.get('CONTENT_TYPE', '')
397 content_type = environ.get('CONTENT_TYPE', '')
374
398
375 path = environ['PATH_INFO']
399 path = environ['PATH_INFO']
General Comments 0
You need to be logged in to leave comments. Login now