diff --git a/django/contrib/csrf/__init__.py b/django/contrib/csrf/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/django/contrib/csrf/middleware.py b/django/contrib/csrf/middleware.py new file mode 100644 index 00000000000..4c00461b898 --- /dev/null +++ b/django/contrib/csrf/middleware.py @@ -0,0 +1,84 @@ +""" +Cross Site Request Forgery Middleware. + +This module provides a middleware that implements protection +against request forgeries from other sites. + +""" +from django.conf import settings +from django.http import HttpResponseForbidden +import md5 +import re + +_ERROR_MSG = "
Cross Site Request Forgery detected. Request aborted.
" + +_POST_FORM_RE = \ + re.compile(r'(