conf.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. from __future__ import unicode_literals
  2. from django.conf import settings
  3. from django.utils.translation import gettext_lazy as _
  4. from appconf import AppConf
  5. class MyAppConf(AppConf):
  6. # see if the user has overridden the failure limit
  7. FAILURE_LIMIT = 3
  8. # see if the user has set axes to lock out logins after failure limit
  9. LOCK_OUT_AT_FAILURE = True
  10. USE_USER_AGENT = False
  11. # use a specific username field to retrieve from login POST data
  12. USERNAME_FORM_FIELD = 'username'
  13. # use a specific password field to retrieve from login POST data
  14. PASSWORD_FORM_FIELD = 'password'
  15. # use a provided callable to transform the POSTed username into the one used in credentials
  16. USERNAME_CALLABLE = None
  17. # only check user name and not location or user_agent
  18. ONLY_USER_FAILURES = False
  19. # reset the number of failed attempts after one successful attempt
  20. RESET_ON_SUCCESS = False
  21. # lock out user from particular IP based on combination USER+IP
  22. LOCK_OUT_BY_COMBINATION_USER_AND_IP = False
  23. DISABLE_ACCESS_LOG = False
  24. DISABLE_SUCCESS_ACCESS_LOG = False
  25. LOGGER = 'axes.watch_login'
  26. LOCKOUT_TEMPLATE = None
  27. LOCKOUT_URL = None
  28. COOLOFF_TIME = None
  29. VERBOSE = True
  30. # whitelist and blacklist
  31. # TODO: convert the strings to IPv4 on startup to avoid type conversion during processing
  32. NEVER_LOCKOUT_WHITELIST = False
  33. ONLY_WHITELIST = False
  34. IP_WHITELIST = None
  35. IP_BLACKLIST = None
  36. # message to show when locked out and have cooloff enabled
  37. COOLOFF_MESSAGE = _('Account locked: too many login attempts. Please try again later')
  38. # message to show when locked out and have cooloff disabled
  39. PERMALOCK_MESSAGE = _('Account locked: too many login attempts. Contact an admin to unlock your account.')
  40. # if your deployment is using reverse proxies, set this value to 'left-most' or 'right-most' per your configuration
  41. PROXY_ORDER = 'left-most'
  42. # if your deployment is using reverse proxies, set this value to the number of proxies in front of Django
  43. PROXY_COUNT = None
  44. # if your deployment is using reverse proxies, set to your trusted proxy IP addresses prefixes if needed
  45. PROXY_TRUSTED_IPS = None
  46. # set to the names of request.META attributes that should be checked for the IP address of the client
  47. # if your deployment is using reverse proxies, ensure that the header attributes are securely set by the proxy
  48. # ensure that the client can not spoof the headers by setting them and sending them through the proxy
  49. META_PRECEDENCE_ORDER = getattr(
  50. settings, 'AXES_META_PRECEDENCE_ORDER', getattr(
  51. settings, 'IPWARE_META_PRECEDENCE_ORDER', (
  52. 'REMOTE_ADDR',
  53. )
  54. )
  55. )