관리-도구
편집 파일: auth.cpython-39.opt-1.pyc
a �������g�'����������������������@���s����d�Z�ddlZddlZddlZddlZddlZddlZddlmZ�ddl m Z mZmZ�ddl mZ�ddlmZ�ddlmZ�d Zd Zdd��ZG�d d��de�ZG�dd��de�ZG�dd��de�ZG�dd��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-datac�����������������C���s����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�encoder���r����join�strip)�username�passwordZauthstr��r����1/usr/lib/python3.9/site-packages/requests/auth.py�_basic_auth_str���s0���� �� �� �r���c�������������������@���s���e�Zd�ZdZdd��ZdS�)�AuthBasez4Base class that all auth implementations derive fromc�����������������C���s���t�d��d�S�)NzAuth hooks must be callable.)�NotImplementedError��self�rr���r���r����__call__K���s����zAuthBase.__call__N��__name__� __module__�__qualname__�__doc__r ���r���r���r���r���r���H���s���r���c�������������������@���s0���e�Zd�ZdZdd��Zdd��Zdd��Zdd ��Zd S�)� HTTPBasicAuthz?Attaches HTTP Basic Authentication to the given Request object.c�����������������C���s���||�_�||�_d�S��N)r���r����r���r���r���r���r���r����__init__R���s����zHTTPBasicAuth.__init__c�����������������C���s(���t�|�jt|dd��k|�jt|dd��kg�S��Nr���r�����allr����getattrr����r����otherr���r���r����__eq__V���s�����zHTTPBasicAuth.__eq__c�����������������C���s ���|�|k�S�r'���r���r.���r���r���r����__ne__\���s����zHTTPBasicAuth.__ne__c�����������������C���s���t�|�j|�j�|jd<�|S�)N� Authorization�r���r���r����headersr���r���r���r���r ���_���s����zHTTPBasicAuth.__call__N)r"���r#���r$���r%���r)���r0���r1���r ���r���r���r���r���r&���O���s ���r&���c�������������������@���s���e�Zd�ZdZdd��ZdS�)� HTTPProxyAuthz=Attaches HTTP Proxy Authentication to a given Request object.c�����������������C���s���t�|�j|�j�|jd<�|S�)NzProxy-Authorizationr3���r���r���r���r���r ���g���s����zHTTPProxyAuth.__call__Nr!���r���r���r���r���r5���d���s���r5���c�������������������@���sP���e�Zd�ZdZdd��Zdd��Zdd��Zdd ��Zd d��Zdd ��Z dd��Z dd��ZdS�)�HTTPDigestAuthz@Attaches HTTP Digest Authentication to the given Request object.c�����������������C���s���||�_�||�_t���|�_d�S�r'���)r���r���� threading�local� _thread_localr(���r���r���r���r)���o���s����zHTTPDigestAuth.__init__c�����������������C���s@���t�|�jd�s<d|�j_d|�j_d|�j_i�|�j_d�|�j_d�|�j_d�S�)N�initT��r���)�hasattrr9���r:���� last_nonce�nonce_count�chal�pos� num_401_calls)r���r���r���r����init_per_thread_stateu���s����z$HTTPDigestAuth.init_per_thread_statec��������������������s���|�j�jd�}|�j�jd�}|�j�j�d�}|�j�j�d�}|�j�j�d�}d��|du�rTd}n|���}|dksl|dkrzd d ��} | ��n@|dkr�dd ��} | ��n*|dkr�dd��}|��n|dkr�dd��}|����fdd�} ��du�r�dS�d}t|�}|jp�d}|jr�|d|j�7�}d|�j||�jf�}d||f�}��|�}��|�}||�j�j k�rJ|�j��j d7��_ nd|�j�_ d|�j�j �}t|�j�j ��d�}||�d�7�}|t ����d�7�}|t�d�7�}t�|����dd��}|dk�rЈ�d|||f��}|�s�| |d||f��}n<|dk�sd|�d �v��r"d!|||d|f�}| ||�}ndS�||�j�_ d"|�j||||f�}|�rT|d#|�7�}|�rf|d$|�7�}|�rx|d%|�7�}|�r�|d&||f�7�}d'|�S�)(z :rtype: str �realm�nonce�qop� algorithm�opaqueNZMD5zMD5-SESSc�����������������S���s"���t�|�t�r|��d�}�t�|�����S��N�utf-8)r ���r���r����hashlibZmd5� hexdigest��xr���r���r����md5_utf8����s���� z4HTTPDigestAuth.build_digest_header.<locals>.md5_utf8ZSHAc�����������������S���s"���t�|�t�r|��d�}�t�|�����S�rH���)r ���r���r���rJ����sha1rK���rL���r���r���r����sha_utf8����s���� z4HTTPDigestAuth.build_digest_header.<locals>.sha_utf8zSHA-256c�����������������S���s"���t�|�t�r|��d�}�t�|�����S�rH���)r ���r���r���rJ���Zsha256rK���rL���r���r���r����sha256_utf8����s���� z7HTTPDigestAuth.build_digest_header.<locals>.sha256_utf8zSHA-512c�����������������S���s"���t�|�t�r|��d�}�t�|�����S�rH���)r ���r���r���rJ���Zsha512rK���rL���r���r���r����sha512_utf8����s���� z7HTTPDigestAuth.build_digest_header.<locals>.sha512_utf8c��������������������s�����d|�|f��S�)N�%s:%sr���)�s�d�Z hash_utf8r���r����<lambda>���������z4HTTPDigestAuth.build_digest_header.<locals>.<lambda>�/�?z%s:%s:%srS���r���z%08xrI�����������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)r9���r?����get�upperr����path�queryr���r���r=���r>���r���r����time�ctime�os�urandomrJ���rO���rK����split)r����method�urlrC���rD���rE���rF���rG���Z _algorithmrN���rP���rQ���rR���ZKDZentdigZp_parsedr`���ZA1ZA2ZHA1ZHA2ZncvaluerT���ZcnonceZrespdigZnoncebit�baser���rV���r����build_digest_header���s����� ��z"HTTPDigestAuth.build_digest_headerc�����������������K���s���|j�rd|�j_dS�)z)Reset num_401_calls counter on redirects.r���N)Zis_redirectr9���rA���)r���r����kwargsr���r���r����handle_redirect����s����zHTTPDigestAuth.handle_redirectc�����������������K���s&��d|j���krdk�s$n�d|�j_|S�|�jjdurB|jj�|�jj��|j�dd�}d|� ��v��r|�jjdk��r|�j�jd7��_t jd t jd �}t |jd|dd��|�j_|j�|����|j���}t|j|j|j��|�|j��|��|j|j�|jd<�|jj|fi�|��}|j�|��||_|S�d|�j_|S�) zo Takes the given response and tries digest-auth, if needed. :rtype: requests.Response i���i���r���Nzwww-authenticater;���Zdigest����zdigest )�flags)�countr2���)Zstatus_coder9���rA���r@���Zrequest�body�seekr4���r^����lower�re�compile� IGNORECASEr ����subr?���Zcontent�close�copyr���Z_cookies�rawZprepare_cookiesrj���rg���rh���Z connection�send�history�append)r���r���rk���Zs_auth�patZprepZ_rr���r���r���� handle_401����s0���� � zHTTPDigestAuth.handle_401c�����������������C���s|���|������|�jjr&|��|j|j�|jd<�z|j���|�j_ W�n�t yR���d�|�j_ Y�n0�|�d|�j��|�d|�j ��d|�j_|S�)Nr2���Zresponser���)rB���r9���r=���rj���rg���rh���r4���rp����tellr@����AttributeErrorZ register_hookr~���rl���rA���r���r���r���r���r �����s����zHTTPDigestAuth.__call__c�����������������C���s(���t�|�jt|dd��k|�jt|dd��kg�S�r*���r+���r.���r���r���r���r0���*��s�����zHTTPDigestAuth.__eq__c�����������������C���s ���|�|k�S�r'���r���r.���r���r���r���r1���0��s����zHTTPDigestAuth.__ne__N)r"���r#���r$���r%���r)���rB���rj���rl���r~���r ���r0���r1���r���r���r���r���r6���l���s��� f,r6���)r%���rd���rs���rb���rJ���r7���r����base64r����compatr���r���r���Zcookiesr���Z_internal_utilsr���Zutilsr ���ZCONTENT_TYPE_FORM_URLENCODEDZCONTENT_TYPE_MULTI_PARTr����objectr���r&���r5���r6���r���r���r���r����<module>���s$���,