Commit 87f25d10 by Chris Dodge Committed by Jonathan Piacenti

cdodge/get-ip-restriction-list-from-config: change settings name to make clearer…

cdodge/get-ip-restriction-list-from-config: change settings name to make clearer and make sure we are getting values from lms.envs.json
parent 399c5bbb
......@@ -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):
......
......@@ -573,7 +573,9 @@ if FEATURES.get('ENABLE_OAUTH2_PROVIDER'):
##### ADVANCED_SECURITY_CONFIG #####
ADVANCED_SECURITY_CONFIG = ENV_TOKENS.get('ADVANCED_SECURITY_CONFIG', {})
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')
##### GOOGLE ANALYTICS IDS #####
GOOGLE_ANALYTICS_ACCOUNT = AUTH_TOKENS.get('GOOGLE_ANALYTICS_ACCOUNT')
......
......@@ -312,4 +312,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