
from django.conf import settings

DEFAULT_REALM = getattr(settings, 'RATED_DEFAULT_REALM', 'default')
DEFAULT_LIMIT = getattr(settings, 'RATED_DEFAULT_LIMIT', 100)
DEFAULT_DURATION = getattr(settings, 'RATED_DEFAULT_DURATION', 60 * 60)

RESPONSE_CODE = getattr(settings, 'RATED_RESPONSE_CODE', 429)
RESPONSE_MESSAGE = getattr(settings, 'RATED_RESPONSE_MESSAGE', '')

DEFAULT_WHITELIST = getattr(settings, 'RATED_DEFAULT_WHITELIST', [])

REALMS = getattr(settings, 'RATED_REALMS', {})

REALM_MAP = getattr(settings, 'RATED_REALM_MAP', {})

# Redis config parameters
REDIS = getattr(settings, 'RATED_REDIS', {})



from django.conf import settings

DEFAULT_REALM = getattr(settings, 'RATED_DEFAULT_REALM', 'default')
DEFAULT_LIMIT = getattr(settings, 'RATED_DEFAULT_LIMIT', 100)
DEFAULT_DURATION = getattr(settings, 'RATED_DEFAULT_DURATION', 60 * 60)

RESPONSE_CODE = getattr(settings, 'RATED_RESPONSE_CODE', 429)
RESPONSE_MESSAGE = getattr(settings, 'RATED_RESPONSE_MESSAGE', '')

DEFAULT_WHITELIST = getattr(settings, 'RATED_DEFAULT_WHITELIST', [])

REALMS = getattr(settings, 'RATED_REALMS', {})

REALM_MAP = getattr(settings, 'RATED_REALM_MAP', {})

# Redis config parameters
REDIS = getattr(settings, 'RATED_REDIS', {})

USE_X_FORWARDED_FOR = getattr(settings, 'USE_X_FORWARDED_FOR', False)

Fix USE_X_FORWARDED_FOR for proxied environments
Fix USE_X_FORWARDED_FOR for proxied environments

The settings for USE_X_FORWARDED_FOR were not being respected because the settings were not being passed through.
  
  from django.conf import settings
  
  DEFAULT_REALM = getattr(settings, 'RATED_DEFAULT_REALM', 'default')
  DEFAULT_LIMIT = getattr(settings, 'RATED_DEFAULT_LIMIT', 100)
  DEFAULT_DURATION = getattr(settings, 'RATED_DEFAULT_DURATION', 60 * 60)
  
  RESPONSE_CODE = getattr(settings, 'RATED_RESPONSE_CODE', 429)
  RESPONSE_MESSAGE = getattr(settings, 'RATED_RESPONSE_MESSAGE', '')
  
  DEFAULT_WHITELIST = getattr(settings, 'RATED_DEFAULT_WHITELIST', [])
  
  REALMS = getattr(settings, 'RATED_REALMS', {})
  
  REALM_MAP = getattr(settings, 'RATED_REALM_MAP', {})
  
  # Redis config parameters
  REDIS = getattr(settings, 'RATED_REDIS', {})
  
+ USE_X_FORWARDED_FOR = getattr(settings, 'USE_X_FORWARDED_FOR', False)
  
Fix USE_X_FORWARDED_FOR for proxied environments
## Code Before:

from django.conf import settings

DEFAULT_REALM = getattr(settings, 'RATED_DEFAULT_REALM', 'default')
DEFAULT_LIMIT = getattr(settings, 'RATED_DEFAULT_LIMIT', 100)
DEFAULT_DURATION = getattr(settings, 'RATED_DEFAULT_DURATION', 60 * 60)

RESPONSE_CODE = getattr(settings, 'RATED_RESPONSE_CODE', 429)
RESPONSE_MESSAGE = getattr(settings, 'RATED_RESPONSE_MESSAGE', '')

DEFAULT_WHITELIST = getattr(settings, 'RATED_DEFAULT_WHITELIST', [])

REALMS = getattr(settings, 'RATED_REALMS', {})

REALM_MAP = getattr(settings, 'RATED_REALM_MAP', {})

# Redis config parameters
REDIS = getattr(settings, 'RATED_REDIS', {})


## Instruction:
Fix USE_X_FORWARDED_FOR for proxied environments
## Code After:

from django.conf import settings

DEFAULT_REALM = getattr(settings, 'RATED_DEFAULT_REALM', 'default')
DEFAULT_LIMIT = getattr(settings, 'RATED_DEFAULT_LIMIT', 100)
DEFAULT_DURATION = getattr(settings, 'RATED_DEFAULT_DURATION', 60 * 60)

RESPONSE_CODE = getattr(settings, 'RATED_RESPONSE_CODE', 429)
RESPONSE_MESSAGE = getattr(settings, 'RATED_RESPONSE_MESSAGE', '')

DEFAULT_WHITELIST = getattr(settings, 'RATED_DEFAULT_WHITELIST', [])

REALMS = getattr(settings, 'RATED_REALMS', {})

REALM_MAP = getattr(settings, 'RATED_REALM_MAP', {})

# Redis config parameters
REDIS = getattr(settings, 'RATED_REDIS', {})

USE_X_FORWARDED_FOR = getattr(settings, 'USE_X_FORWARDED_FOR', False)
