Skip to content

Commit

Permalink
Merge pull request #1 from sterapps/changeable-ip-list-settings
Browse files Browse the repository at this point in the history
Make ip list setting changeable
  • Loading branch information
nezhar authored Mar 28, 2023
2 parents 1a73d6c + dc74de5 commit baaba56
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 3 additions & 1 deletion drf_ip_restrictions/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ class AllowedIpList(object):
Ensure the request's IP address is on the ip white list configured in Django settings.
"""

setting_ip_list = "ALLOWED_IP_LIST"

def has_permission(self, request, view):
client_ip, is_routable = get_client_ip(request)

if client_ip:
settings = ip_restriction_settings()
allowed_ips = settings.ALLOWED_IP_LIST
allowed_ips = getattr(settings, self.setting_ip_list)
for allowed_ip in allowed_ips:
if client_ip == allowed_ip or client_ip.startswith(allowed_ip):
return True
Expand Down
1 change: 0 additions & 1 deletion tests/testapp/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

initial = True

dependencies = []
Expand Down

0 comments on commit baaba56

Please sign in to comment.