%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/alt/python37/lib/python3.7/site-packages/requests/__pycache__/
Upload File :
Create Path :
Current File : //opt/alt/python37/lib/python3.7/site-packages/requests/__pycache__/auth.cpython-37.pyc

B

Ba�_�'�@s�dZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
mZmZddl
mZddlmZddlmZd	Zd
Zdd�ZGd
d�de�ZGdd�de�ZGdd�de�ZGdd�de�ZdS)z]
requests.auth
~~~~~~~~~~~~~

This module contains the authentication handlers for Requests.
�N)�	b64encode�)�urlparse�str�
basestring)�extract_cookies_to_jar)�to_native_string)�parse_dict_headerz!application/x-www-form-urlencodedzmultipart/form-datacCs�t|t�s&tjd�|�td�t|�}t|t�sPtjd�t|��td�t|�}t|t�rd|�d�}t|t�rx|�d�}dt	t
d�||f�����}|S)zReturns a Basic Auth string.z�Non-string usernames will no longer be supported in Requests 3.0.0. Please convert the object you've passed in ({!r}) to a string or bytes object in the near future to avoid problems.)�categoryz�Non-string passwords will no longer be supported in Requests 3.0.0. Please convert the object you've passed in ({!r}) to a string or bytes object in the near future to avoid problems.�latin1zBasic �:)
�
isinstancer�warnings�warn�format�DeprecationWarningr�type�encoderr�join�strip)�username�passwordZauthstr�r�>/opt/alt/python37/lib/python3.7/site-packages/requests/auth.py�_basic_auth_strs&






rc@seZdZdZdd�ZdS)�AuthBasez4Base class that all auth implementations derive fromcCstd��dS)NzAuth hooks must be callable.)�NotImplementedError)�self�rrrr�__call__KszAuthBase.__call__N)�__name__�
__module__�__qualname__�__doc__rrrrrrHsrc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�
HTTPBasicAuthz?Attaches HTTP Basic Authentication to the given Request object.cCs||_||_dS)N)rr)rrrrrr�__init__RszHTTPBasicAuth.__init__cCs(t|jt|dd�k|jt|dd�kg�S)Nrr)�allr�getattrr)r�otherrrr�__eq__VszHTTPBasicAuth.__eq__cCs
||kS)Nr)rr(rrr�__ne__\szHTTPBasicAuth.__ne__cCst|j|j�|jd<|S)N�
Authorization)rrr�headers)rrrrrr_szHTTPBasicAuth.__call__N)r r!r"r#r%r)r*rrrrrr$Os
r$c@seZdZdZdd�ZdS)�
HTTPProxyAuthz=Attaches HTTP Proxy Authentication to a given Request object.cCst|j|j�|jd<|S)NzProxy-Authorization)rrrr,)rrrrrrgszHTTPProxyAuth.__call__N)r r!r"r#rrrrrr-dsr-c@sPeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�ZdS)�HTTPDigestAuthz@Attaches HTTP Digest Authentication to the given Request object.cCs||_||_t��|_dS)N)rr�	threadingZlocal�
_thread_local)rrrrrrr%oszHTTPDigestAuth.__init__cCs@t|jd�s<d|j_d|j_d|j_i|j_d|j_d|j_dS)N�initT�r)�hasattrr0r1�
last_nonce�nonce_count�chal�pos�
num_401_calls)rrrr�init_per_thread_stateusz$HTTPDigestAuth.init_per_thread_statecs�|jjd}|jjd}|jj�d�}|jj�d�}|jj�d�}d�|dkrTd}n|��}|dksl|dkrzd	d
�}	|	�n@|dkr�dd
�}
|
�n*|dkr�dd�}|�n|dkr�dd�}|��fdd�}
�dkr�dSd}t|�}|jp�d}|jr�|d|j7}d|j||jf}d||f}�|�}�|�}||jj	k�rJ|jj
d7_
nd|j_
d|jj
}t|jj
��d�}||�d�7}|t
���d�7}|t�d�7}t�|���dd�}|dk�rЈd|||f�}|�s�|
|d||f�}n<|dk�sd|�d �k�r"d!|||d|f}|
||�}ndS||j_	d"|j||||f}|�rT|d#|7}|�rf|d$|7}|�rx|d%|7}|�r�|d&||f7}d'|S)(z
        :rtype: str
        �realm�nonce�qop�	algorithm�opaqueNZMD5zMD5-SESScSs"t|t�r|�d�}t�|���S)Nzutf-8)r
rr�hashlibZmd5�	hexdigest)�xrrr�md5_utf8�s

z4HTTPDigestAuth.build_digest_header.<locals>.md5_utf8ZSHAcSs"t|t�r|�d�}t�|���S)Nzutf-8)r
rrr?�sha1r@)rArrr�sha_utf8�s

z4HTTPDigestAuth.build_digest_header.<locals>.sha_utf8zSHA-256cSs"t|t�r|�d�}t�|���S)Nzutf-8)r
rrr?Zsha256r@)rArrr�sha256_utf8�s

z7HTTPDigestAuth.build_digest_header.<locals>.sha256_utf8zSHA-512cSs"t|t�r|�d�}t�|���S)Nzutf-8)r
rrr?Zsha512r@)rArrr�sha512_utf8�s

z7HTTPDigestAuth.build_digest_header.<locals>.sha512_utf8cs�d||f�S)Nz%s:%sr)�s�d)�	hash_utf8rr�<lambda>��z4HTTPDigestAuth.build_digest_header.<locals>.<lambda>�/�?z%s:%s:%sz%s:%srz%08xzutf-8��Zauth�,z%s:%s:%s:%s:%sz>username="%s", realm="%s", nonce="%s", uri="%s", response="%s"z
, opaque="%s"z, algorithm="%s"z
, digest="%s"z , qop="auth", nc=%s, cnonce="%s"z	Digest %s)r0r6�get�upperr�pathZqueryrrr4r5rr�timeZctime�os�urandomr?rCr@�split)r�method�urlr:r;r<r=r>Z
_algorithmrBrDrErFZKDZentdigZp_parsedrSZA1ZA2ZHA1ZHA2ZncvaluerGZcnonceZrespdigZnoncebit�baser)rIr�build_digest_headers~

z"HTTPDigestAuth.build_digest_headercKs|jrd|j_dS)z)Reset num_401_calls counter on redirects.rN)Zis_redirectr0r8)rr�kwargsrrr�handle_redirect�szHTTPDigestAuth.handle_redirectcKs"d|jkrdks$nd|j_|S|jjdk	rB|jj�|jj�|j�dd�}d|�	�k�r|jjdk�r|jjd7_t
jd	t
jd
�}t
|jd|dd��|j_|j|��|j��}t|j|j|j�|�|j�|�|j|j�|jd<|jj|f|�}|j�|�||_|Sd|j_|S)
zo
        Takes the given response and tries digest-auth, if needed.

        :rtype: requests.Response
        i�i�rNzwww-authenticater2Zdigest�zdigest )�flags)�countr+)Zstatus_coder0r8r7Zrequest�body�seekr,rQ�lower�re�compile�
IGNORECASEr	�subr6Zcontent�close�copyrZ_cookies�rawZprepare_cookiesr[rXrYZ
connection�send�history�append)rrr\Zs_authZpatZprepZ_rrrr�
handle_401�s.	
zHTTPDigestAuth.handle_401cCs~|��|jjr&|�|j|j�|jd<y|j��|j_	Wnt
k
rTd|j_	YnX|�d|j�|�d|j
�d|j_|S)Nr+Zresponser)r9r0r4r[rXrYr,ra�tellr7�AttributeErrorZ
register_hookrnr]r8)rrrrrrszHTTPDigestAuth.__call__cCs(t|jt|dd�k|jt|dd�kg�S)Nrr)r&rr'r)rr(rrrr)*szHTTPDigestAuth.__eq__cCs
||kS)Nr)rr(rrrr*0szHTTPDigestAuth.__ne__N)r r!r"r#r%r9r[r]rnrr)r*rrrrr.ls
f,r.)r#rUrdrTr?r/r�base64r�compatrrrZcookiesrZ_internal_utilsrZutilsr	ZCONTENT_TYPE_FORM_URLENCODEDZCONTENT_TYPE_MULTI_PARTr�objectrr$r-r.rrrr�<module>s$,

Zerion Mini Shell 1.0