
X?_c           @   sJ   d  d l  Z  d  d l m Z d d d  Z d e d  Z e d  Z d S(   iN(   t   httpauthc      	   C   s^  t  j j } d | j k rZt j | j d  } | d
 k rR t  j d d   n  | sk t j t j	 } n  t
 |  d  r yA |    }  t |  t  s t d   n  |  j | d d
  } Wqt k
 r |  | d  } qXn4 t |  t  s t d   n  |  j | d d
  } t j | | d | j d | d	 | rN| d | _ t St | _ n  t S(   sK   If an authorization header contains credentials, return True or False.
    t   authorizationi  s   Bad Requestt   __call__s)   Authentication users must be a dictionaryt   usernamet   methodt   encryptt   realmN(   t   cherrypyt   servingt   requestt   headersR    t   parseAuthorizationt   Nonet	   HTTPErrort   DIGEST_AUTH_ENCODERSt   MD5t   hasattrt
   isinstancet   dictt
   ValueErrort   gett	   TypeErrort   checkResponseR   t   logint   Truet   False(   t   usersR   R   R	   t   aht   password(    (    sx   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/lib/auth.pyt
   check_auth   s2    	c         C   s^   t  | |  r, | r( t j d d  n  d St j |   t j j j d <t j d d   d S(   sq  If auth fails, raise 401 with a basic authentication header.

    realm
        A string containing the authentication realm.

    users
        A dict of the form: {username: password} or a callable returning
        a dict.

    encrypt
        callable used to encrypt the password returned from the user-agent.
        if None it defaults to a md5 encryption.

    s   Auth successfuls   TOOLS.BASIC_AUTHNs   www-authenticatei  s.   You are not authorized to access that resource(	   R   R   t   logR    t	   basicAuthR   t   responseR
   R   (   R   R   R   t   debug(    (    sx   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/lib/auth.pyt
   basic_auth2   s    c         C   sa   t  | d |  r/ | r+ t j d d  n  d St j |   t j j j d <t j d d   d S(   s   If auth fails, raise 401 with a digest authentication header.

    realm
        A string containing the authentication realm.
    users
        A dict of the form: {username: password} or a callable returning
        a dict.
    R   s   Auth successfuls   TOOLS.DIGEST_AUTHNs   www-authenticatei  s.   You are not authorized to access that resource(	   R   R   R   R    t
   digestAuthR   R    R
   R   (   R   R   R!   (    (    sx   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/lib/auth.pyt   digest_authN   s    	(   R   t   cherrypy.libR    R   R   R   R"   R$   (    (    (    sx   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/lib/auth.pyt   <module>   s   -