Skip to content

Instantly share code, notes, and snippets.

@kl4us
kl4us / Django-RFC1918.md
Last active March 3, 2025 08:39
Django RFC1918 IP Restrictions

Django RFC1918 IP Restrictions

A Django middleware and URL helper functions to restrict access to specific URLs to only allow RFC1918 private IP addresses (intranet IPs).

Overview

This package provides:

  1. A middleware that checks if requests come from RFC1918 private IP ranges
  2. Helper functions to use in urls.py to easily protect specific URLs or URL patterns