1 2 3 4 5 6 7 8 9 10 11 12 13 | from django.http import HttpResponse
def ip_auth(authorised_ips):
def inner(f):
def authorization(*args,**kwargs):
request = args[0]
request_ip = request.META['REMOTE_ADDR']
if request_ip not in authorised_ips:
return HttpResponse(status=401)
else:
return f(*args, **kwargs)
return authorization
return inner
|
More like this
- Support IP ranges in INTERNAL_IPS by jdunck 3 years, 4 months ago
- Include entire networks in INTERNAL_IPS setting by pmclanahan 4 years, 2 months ago
- caching parsed templates by forgems 5 years, 5 months ago
- Akismet Webservice by sneeu 6 years, 2 months ago
- Test Server Thread by adamlofts 3 years, 11 months ago
Comments
More generic:
#