[minor] read ip from header HTTP_X_FORWARDED_FOR

This commit is contained in:
Rushabh Mehta 2013-11-11 14:39:08 +01:00
parent eddc739d35
commit 0f04fcd2db
2 changed files with 5 additions and 5 deletions

View file

@ -179,7 +179,7 @@ def get_env_vars(env_var):
import os
return os.environ.get(env_var,'None')
remote_ip = get_env_vars('REMOTE_ADDR') #Required for login from python shell
remote_ip = get_env_vars('HTTP_X_FORWARDED_FOR') or get_env_vars('REMOTE_ADDR') #Required for login from python shell
logger = None
def get_db_password(db_name):

View file

@ -20,9 +20,9 @@ class HTTPRequest:
# language
self.set_lang(webnotes.get_env_vars('HTTP_ACCEPT_LANGUAGE'))
webnotes.remote_ip = webnotes.get_env_vars('REMOTE_ADDR')
webnotes.remote_ip = webnotes.get_env_vars('HTTP_X_FORWARDED_FOR') or webnotes.get_env_vars('REMOTE_ADDR')
# load cookies
webnotes.cookie_manager = CookieManager()
@ -115,7 +115,7 @@ class LoginManager:
full_name = " ".join(filter(None, [info.first_name, info.last_name]))
webnotes.response["full_name"] = full_name
webnotes.add_cookies["full_name"] = full_name
def post_login(self):
self.run_trigger()
self.validate_ip_address()
@ -271,4 +271,4 @@ def _update_password(user, password):
@webnotes.whitelist()
def get_logged_user():
return webnotes.session.user
return webnotes.session.user