Ńň
$°Lc           @   sf   d  d k  l Z d  d k l Z d e f d     YZ d e f d     YZ d e f d     YZ d	 S(
   i˙˙˙˙(   t   auth(   t   ImproperlyConfiguredt   LazyUserc           B   s   e  Z d d   Z RS(   c         C   s:   t  | d  p# d d k l } | |  | _ n | i S(   Nt   _cached_useri˙˙˙˙(   t   get_user(   t   hasattrt   django.contrib.authR   R   (   t   selft   requestt   obj_typeR   (    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/middleware.pyt   __get__   s    N(   t   __name__t
   __module__t   NoneR
   (    (    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/middleware.pyR      s   t   AuthenticationMiddlewarec           B   s   e  Z d    Z RS(   c         C   s-   t  | d  p
 t d  t   | i _ d  S(   Nt   sessions¸   The Django authentication middleware requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'.(   R   t   AssertionErrorR   t	   __class__t   userR   (   R   R   (    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/middleware.pyt   process_request   s    (   R   R   R   (    (    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/middleware.pyR      s   t   RemoteUserMiddlewarec           B   s&   e  Z d  Z d Z d   Z d   Z RS(   sý  
    Middleware for utilizing Web-server-provided authentication.

    If request.user is not authenticated, then this middleware attempts to
    authenticate the username passed in the ``REMOTE_USER`` request header.
    If authentication is successful, the user is automatically logged in to
    persist the user in the session.

    The header used is configurable and defaults to ``REMOTE_USER``.  Subclass
    this class and change the ``header`` attribute if you need to use a
    different header.
    t   REMOTE_USERc         C   s˝   t  | d  p t d   n y | i |  i } Wn t j
 o d  SX| i i   o( | i i |  i | |  j o d  Sn t	 i
 d |  } | o | | _ t	 i | |  n d  S(   NR   sď   The Django remote user auth middleware requires the authentication middleware to be installed.  Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.auth.middleware.AuthenticationMiddleware' before the RemoteUserMiddleware class.t   remote_user(   R   R   t   METAt   headert   KeyErrorR   t   is_authenticatedt   usernamet   clean_usernameR    t   authenticatet   login(   R   R   R   R   (    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/middleware.pyR   '   s    		c         C   sL   | i  t i } t i |  } y | i |  } Wn t j
 o n X| S(   ss   
        Allows the backend to clean the username, if the backend defines a
        clean_username method.
        (   R   R    t   BACKEND_SESSION_KEYt   load_backendR   t   AttributeError(   R   R   R   t   backend_strt   backend(    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/middleware.pyR   F   s    (   R   R   t   __doc__R   R   R   (    (    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/middleware.pyR      s   	N(   t   django.contribR    t   django.core.exceptionsR   t   objectR   R   R   (    (    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/middleware.pyt   <module>   s   