Commit 745c4b06 by chrisndodge

Merge pull request #54 from edx-solutions/cdodge/get-ip-restriction-list-from-config

Cdodge/get ip restriction list from config
parents f2e3df1f f9f09306
......@@ -63,7 +63,7 @@ class IPAddressRestrictedPermission(permissions.BasePermission):
def has_permission(self, request, view):
ip_address = get_client_ip_address(request)
allowed_ip_addresses = getattr(settings, 'ALLOWED_IP_ADDRESSES', None)
allowed_ip_addresses = getattr(settings, 'API_ALLOWED_IP_ADDRESSES', None)
if allowed_ip_addresses:
for allowed_ip_address in allowed_ip_addresses:
if '/' in allowed_ip_address:
......
......@@ -13,7 +13,7 @@ from django.test.utils import override_settings
TEST_API_KEY = "123456ABCDEF"
@override_settings(ALLOWED_IP_ADDRESSES=['127.0.0.1', '10.0.2.2', '192.168.0.0/24'])
@override_settings(API_ALLOWED_IP_ADDRESSES=['127.0.0.1', '10.0.2.2', '192.168.0.0/24'])
class PermissionsTests(TestCase):
""" Test suite for Permissions helper classes """
def setUp(self):
......
......@@ -416,4 +416,6 @@ GOOGLE_ANALYTICS_LINKEDIN = AUTH_TOKENS.get('GOOGLE_ANALYTICS_LINKEDIN')
##### Google Analytics and Google Web Master Tools #####
GOOGLE_ANALYTICS_ACCOUNT_ID = ENV_TOKENS.get('GOOGLE_ANALYTICS_ACCOUNT_ID', GOOGLE_ANALYTICS_ACCOUNT_ID)
GOOGLE_SITE_VERIFICATION = ENV_TOKENS.get('GOOGLE_SITE_VERIFICATION', GOOGLE_SITE_VERIFICATION)
ALLOWED_IP_ADDRESSES = ['127.0.0.1']
##### SET THE LIST OF ALLOWED IP ADDRESSES FOR THE API ######
API_ALLOWED_IP_ADDRESSES = ENV_TOKENS.get('API_ALLOWED_IP_ADDRESSES')
......@@ -293,4 +293,4 @@ except ImportError:
pass
########################## ALLOWED API USER IP ########################
ALLOWED_IP_ADDRESSES = ['127.0.0.1']
API_ALLOWED_IP_ADDRESSES = ['127.0.0.1']
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment