
    df	                        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dS )    )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dS )_EnsureCsrfTokenc                     d S N selfrequestreasons      XD:\Python Project\djangoTemplates\venv\Lib\site-packages\django/views/decorators/csrf.py_rejectz_EnsureCsrfToken._reject       t    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                     d S r   r   r   s      r   r   z_EnsureCsrfCookie._reject!   r   r   c                 n    t                                          ||||          }t          |           |S r   )superprocess_viewr   )r   r   callbackcallback_argscallback_kwargsretval	__class__s         r   r   z_EnsureCsrfCookie.process_view$   s3    %%gxXX'r   )r   r   r   r   r   __classcell__)r$   s   @r   r   r       sG                  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                 v     t                     r fd}n fd}d|_         t                     |          S )zCMark a view function as being exempt from the CSRF view protection.c                 ,   K    | g|R i | d {V S r   r   r   argskwargs	view_funcs      r   _view_wrapperz"csrf_exempt.<locals>._view_wrapper;   s9      "7<T<<<V<<<<<<<<<r   c                      | g|R i |S r   r   r)   s      r   r-   z"csrf_exempt.<locals>._view_wrapper@   s#    9W6t666v666r   T)r   csrf_exemptr   )r,   r-   s   ` r   r/   r/   3   sn     9%% 7	= 	= 	= 	= 	= 	=
	7 	7 	7 	7 	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      s5         , , , , , , @ @ @ @ @ @ @ @ = = = = = =(();<<&      )    0/0@AA 4        *    /./@AA 2    + + + + +r   