
    Vh	                         d dl mZ d dlmZ d dlmZmZ d dlmZ  ee      Z	de	_
        de	_         G d de      Z ee      Zd	e_
        d
e_         G d de      Z ee      Zde_
        de_        d Zy)    )wraps)iscoroutinefunction)CsrfViewMiddleware	get_token)decorator_from_middlewarecsrf_protectz
This decorator adds CSRF protection in exactly the same way as
CsrfViewMiddleware, but it can be used on a per view basis.  Using both, or
using the decorator multiple times, is harmless and efficient.
c                       e Zd Zd Zy)_EnsureCsrfTokenc                      y N selfrequestreasons      L/home/dcms/DCMS/lib/python3.12/site-packages/django/views/decorators/csrf.py_rejectz_EnsureCsrfToken._reject           N)__name__
__module____qualname__r   r   r   r   r
   r
      s    r   r
   requires_csrf_tokenz
Use this decorator on views that need a correct csrf_token available to
RequestContext, but without the CSRF protection that csrf_protect
enforces.
c                   $     e Zd Zd Z fdZ xZS )_EnsureCsrfCookiec                      y r   r   r   s      r   r   z_EnsureCsrfCookie._reject!   r   r   c                 B    t         |   ||||      }t        |       |S r   )superprocess_viewr   )r   r   callbackcallback_argscallback_kwargsretval	__class__s         r   r   z_EnsureCsrfCookie.process_view$   s%    %gxX'r   )r   r   r   r   r   __classcell__)r$   s   @r   r   r       s     r   r   ensure_csrf_cookiez
Use this decorator to ensure that a view sets a CSRF cookie, whether or not it
uses the csrf_token template tag, or the CsrfViewMiddleware is used.
c                 `     t               r fd}n fd}d|_         t               |      S )zCMark a view function as being exempt from the CSRF view protection.c                 8   K    | g|i | d {   S 7 wr   r   r   argskwargs	view_funcs      r   _view_wrapperz"csrf_exempt.<locals>._view_wrapper;   s"     "7<T<V<<<<s   c                      | g|i |S r   r   r)   s      r   r-   z"csrf_exempt.<locals>._view_wrapper@   s    W6t6v66r   T)r   csrf_exemptr   )r,   r-   s   ` r   r/   r/   3   s3     9%	=
	7 !%M5M**r   N)	functoolsr   asgiref.syncr   django.middleware.csrfr   r   django.utils.decoratorsr   r   r   __doc__r
   r   r   r&   r/   r   r   r   <module>r5      s     , @ =();<&  )  00@A 4    *  //@A 2    +r   