mirror of
https://github.com/jazzband/django-axes.git
synced 2026-03-16 22:30:23 +00:00
Reduce logging of reverse proxy IP lookup and use configured logger
Instead of logging the notice that django.axes looks for a HTTP header set by a reverse proxy on each attempt, just log it one-time on first module import. Also use the configured logger (by default axes.watch_login) for the message to be more consistent in logging.
This commit is contained in:
parent
4daba3daa3
commit
7f57a86408
1 changed files with 11 additions and 7 deletions
|
|
@ -64,11 +64,20 @@ ERROR_MESSAGE = ugettext_lazy("Please enter a correct username and password. "
|
|||
"Note that both fields are case-sensitive.")
|
||||
|
||||
|
||||
log = logging.getLogger(LOGGER)
|
||||
if VERBOSE:
|
||||
log.info('AXES: BEGIN LOG')
|
||||
log.info('Using django-axes ' + axes.get_version())
|
||||
|
||||
|
||||
if BEHIND_REVERSE_PROXY:
|
||||
log.debug('Axes is configured to be behind reverse proxy...looking for header value %s', REVERSE_PROXY_HEADER)
|
||||
|
||||
|
||||
def get_ip(request):
|
||||
if not BEHIND_REVERSE_PROXY:
|
||||
ip = request.META.get('REMOTE_ADDR', '')
|
||||
else:
|
||||
logging.debug('Axes is configured to be behind reverse proxy...looking for header value %s', REVERSE_PROXY_HEADER)
|
||||
ip = request.META.get(REVERSE_PROXY_HEADER, '')
|
||||
if ip == '':
|
||||
raise Warning('Axes is configured for operation behind a reverse proxy but could not find '\
|
||||
|
|
@ -76,6 +85,7 @@ def get_ip(request):
|
|||
'to make sure this header value is being passed.'.format(REVERSE_PROXY_HEADER))
|
||||
return ip
|
||||
|
||||
|
||||
def get_lockout_url():
|
||||
return getattr(settings, 'AXES_LOCKOUT_URL', None)
|
||||
|
||||
|
|
@ -110,12 +120,6 @@ def ip_in_blacklist(ip):
|
|||
return False
|
||||
|
||||
|
||||
log = logging.getLogger(LOGGER)
|
||||
if VERBOSE:
|
||||
log.info('AXES: BEGIN LOG')
|
||||
log.info('Using django-axes ' + axes.get_version())
|
||||
|
||||
|
||||
def is_user_lockable(request):
|
||||
"""Check if the user has a profile with nolockout
|
||||
If so, then return the value to see if this user is special
|
||||
|
|
|
|||
Loading…
Reference in a new issue