HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/requests/__pycache__/auth.cpython-310.pyc
o

;j�'�@s�dZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZm
Z
mZddlmZddlmZd	Zd
Zdd�ZGd
d�d�ZGdd�de�ZGdd�de�ZGdd�de�ZdS)z]
requests.auth
~~~~~~~~~~~~~

This module contains the authentication handlers for Requests.
�N)�	b64encode�)�to_native_string)�
basestring�str�urlparse)�extract_cookies_to_jar)�parse_dict_headerz!application/x-www-form-urlencodedzmultipart/form-datacCs�t|t�stjd|�d�td�t|�}t|t�s*tjdt|��d�td�t|�}t|t�r4|�d�}t|t�r>|�d�}dtt	d�
||f�����}|S)zReturns a Basic Auth string.zpNon-string usernames will no longer be supported in Requests 3.0.0. Please convert the object you've passed in (zC) to a string or bytes object in the near future to avoid problems.)�categoryzpNon-string passwords will no longer be supported in Requests 3.0.0. Please convert the object you've passed in (�latin1zBasic �:)�
isinstancer�warnings�warn�DeprecationWarningr�type�encoderr�join�strip)�username�passwordZauthstr�r�A/opt/saltstack/salt/lib/python3.10/site-packages/requests/auth.py�_basic_auth_strs0

��
��



�rc@�eZdZdZdd�ZdS)�AuthBasez4Base class that all auth implementations derive fromcCstd��)NzAuth hooks must be callable.)�NotImplementedError��self�rrrr�__call__HszAuthBase.__call__N��__name__�
__module__�__qualname__�__doc__r rrrrrE�rc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�
HTTPBasicAuthz?Attaches HTTP Basic Authentication to the given Request object.cCs||_||_dS�N)rr�rrrrrr�__init__Os
zHTTPBasicAuth.__init__cC�(t|jt|dd�k|jt|dd�kg�S�Nrr��allr�getattrr�r�otherrrr�__eq__S�
��zHTTPBasicAuth.__eq__cC�
||kSr(rr0rrr�__ne__[�
zHTTPBasicAuth.__ne__cC�t|j|j�|jd<|S)N�
Authorization�rrr�headersrrrrr ^�zHTTPBasicAuth.__call__N)r"r#r$r%r*r2r5r rrrrr'Lsr'c@r)�
HTTPProxyAuthz=Attaches HTTP Proxy Authentication to a given Request object.cCr7)NzProxy-Authorizationr9rrrrr fr;zHTTPProxyAuth.__call__Nr!rrrrr<cr&r<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��|_dSr()rr�	threading�local�
_thread_localr)rrrr*nszHTTPDigestAuth.__init__cCsDt|jd�s d|j_d|j_d|j_i|j_d|j_d|j_dSdS)N�initT�r)�hasattrr@rA�
last_nonce�nonce_count�chal�pos�
num_401_calls)rrrr�init_per_thread_statets�z$HTTPDigestAuth.init_per_thread_statecs�|jjd}|jjd}|jj�d�}|jj�d�}|jj�d�}d�|dur*d}n|��}|dks6|dkr=d	d
�}	|	�n |dkrHdd
�}
|
�n|dkrSdd�}|�n
|dkr]dd�}|��fdd�}
�duridSd}t|�}|jpsd}|jr|d|j��7}|j�d|�d|j��}|�d|��}�|�}�|�}||jj	kr�|jj
d7_
nd|j_
|jj
d�}t|jj
��d�}||�d�7}|t
���d�7}|t�d�7}t�|���dd�}|dkr�|�d|�d|���}|s�|
||�d|���}n"|dk�sd|�d�v�r|�d|�d|�d |��}|
||�}ndS||j_	d!|j�d"|�d#|�d$|�d%|�d&�}|�r?|d'|�d&�7}|�rJ|d(|�d&�7}|�rU|d)|�d&�7}|�rc|d*|�d+|�d&�7}d,|��S)-z
        :rtype: str
        �realm�nonce�qop�	algorithm�opaqueN�MD5zMD5-SESScS�"t|t�r
|�d�}t�|���S�N�utf-8)r
rr�hashlib�md5�	hexdigest��xrrr�md5_utf8��

z4HTTPDigestAuth.build_digest_header.<locals>.md5_utf8ZSHAcSrPrQ)r
rrrS�sha1rUrVrrr�sha_utf8�rYz4HTTPDigestAuth.build_digest_header.<locals>.sha_utf8zSHA-256cSrPrQ)r
rrrS�sha256rUrVrrr�sha256_utf8�rYz7HTTPDigestAuth.build_digest_header.<locals>.sha256_utf8zSHA-512cSrPrQ)r
rrrS�sha512rUrVrrr�sha512_utf8�rYz7HTTPDigestAuth.build_digest_header.<locals>.sha512_utf8cs�|�d|���S)N�:r)�s�d�Z	hash_utf8rr�<lambda>�sz4HTTPDigestAuth.build_digest_header.<locals>.<lambda>�/�?r`rZ08xrR��Zauth�,z:auth:z
username="z
", realm="z
", nonce="z", uri="z
", response="�"z
, opaque="z
, algorithm="z
, digest="z, qop="auth", nc=z
, cnonce="zDigest )r@rF�get�upperr�path�queryrrrDrErr�time�ctime�os�urandomrSrZrU�split)r�method�urlrJrKrLrMrNZ
_algorithmrXr[r]r_ZKDZentdigZp_parsedrmZA1ZA2ZHA1ZHA2ZncvalueraZcnonceZrespdigZnoncebit�baserrcr�build_digest_header~s�
���
z"HTTPDigestAuth.build_digest_headercKs|jr	d|j_dSdS)z)Reset num_401_calls counter on redirects.rN)Zis_redirectr@rH)rr�kwargsrrr�handle_redirect�s�zHTTPDigestAuth.handle_redirectcKs"d|jkrdksnd|j_|S|jjdur!|jj�|jj�|j�dd�}d|�	�vr�|jjdkr�|jjd7_t
jd	t
jd
�}t
|jd|dd��|j_|j|��|j��}t|j|j|j�|�|j�|�|j|j�|jd<|jj|fi|��}|j�|�||_|Sd|j_|S)
zo
        Takes the given response and tries digest-auth, if needed.

        :rtype: requests.Response
        i�i�rNzwww-authenticaterB�digest�zdigest )�flags)�countr8)Zstatus_coder@rHrG�request�body�seekr:rk�lower�re�compile�
IGNORECASEr	�subrF�content�close�copyrZ_cookies�rawZprepare_cookiesrwrtru�
connection�send�history�append)rrrxZs_auth�patZprepZ_rrrr�
handle_401�s0	

�zHTTPDigestAuth.handle_401cCs||��|jjr|�|j|j�|jd<z	|j��|j_	Wn
t
y)d|j_	Ynw|�d|j�|�d|j
�d|j_|S)Nr8�responser)rIr@rDrwrtrur:r�tellrG�AttributeErrorZ
register_hookr�ryrHrrrrr s�zHTTPDigestAuth.__call__cCr+r,r-r0rrrr21r3zHTTPDigestAuth.__eq__cCr4r(rr0rrrr59r6zHTTPDigestAuth.__ne__N)r"r#r$r%r*rIrwryr�r r2r5rrrrr=ks
n,r=)r%rSrqr�r>ror�base64rZ_internal_utilsr�compatrrrZcookiesr�utilsr	ZCONTENT_TYPE_FORM_URLENCODEDZCONTENT_TYPE_MULTI_PARTrrr'r<r=rrrr�<module>s&,