Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
_auth.cpython-313.pyc107 linesDownload Raw Back to __pycache__
1�

2�js.��P�SSKJr SSKrSSKrSSKrSSKrSSKrSSKJr SSK	J3r4 SSKJr SSK
JrJrJr SSKJrJrJr \R*(aSS	KJr /S5Qr"SS5r"S
S\5r"SS\5r"SS\5r"SS\5r"SS\R:5rg)�)�annotationsN)�	b64encode)�parse_http_list�)�
ProtocolError)�Cookies�Request�Response)�to_bytes�to_str�unquote)�_Hash)�Auth�	BasicAuth�6DigestAuth�	NetRCAuthc�N�\rSrSrSrSrSrS	SjrS	SjrS7Sjr	Sr8g)r�a�9Base class for all authentication schemes.10 11To implement a custom authentication scheme, subclass `Auth` and override12the `.auth_flow()` method.13 14If the authentication scheme does I/O such as disk access or network calls, or uses15synchronization primitives such as locks, you should override `.sync_auth_flow()`16and/or `.async_auth_flow()` instead of `.auth_flow()` to provide specialized17implementations that will be used by `Client` and `AsyncClient` respectively.18Fc#�# �Uv� g7f)a�19Execute the authentication flow.20 21To dispatch a request, `yield` it:22 23```24yield request25```26 27The client will `.send()` the response back into the flow generator. You can28access it like so:29 30```31response = yield request32```33 34A `return` (or reaching the end of the generator) will result in the35client returning the last response obtained from the server.36 37You can dispatch as many requests as is necessary.38N���self�requests  �QD:\code\apps\devtools\python\user_packages\Python313\site-packages\httpx/_auth.py�	auth_flow�Auth.auth_flow&s���,�
�s�c#�# �UR(aUR5 URU5n[U5nUv�nUR(aUR5 URU5nM9![a gf=f7f)z�39Execute the authentication flow synchronously.40 41By default, this defers to `.auth_flow()`. You should override this method42when the authentication scheme does I/O and/or uses concurrency primitives.43N)�requires_request_body�readr�next�requires_response_body�send�
StopIteration�rr�flow�responses    r�sync_auth_flow�Auth.sync_auth_flow>sw����%�%��L�L�N��~�~�g�&���t�*���$�}�H��*�*��
�
��
��)�)�H�-��
��!�
��
�s*�A$B44�'A:�8B45�:46B�B47�B�B48c�B# �UR(aUR5IShv�N URU5n[U5nU7v�nUR(aUR5IShv�N URU5nMBNcN![a gf=f7f)z�49Execute the authentication flow asynchronously.50 51By default, this defers to `.auth_flow()`. You should override this method52when the authentication scheme does I/O and/or uses concurrency primitives.53N)r�areadrr r!r"r#r$s    r�async_auth_flow�Auth.async_auth_flowWs�����%�%��-�-�/�!�!��~�~�g�&���t�*���$�}�H��*�*��n�n�&�&�&�
��)�)�H�-��
�
"�'��!�
��
�sF�%B�B�A54B�2B
�3B�8B�	B�
B�55B�B�B�BrN�rr	�returnz)typing.Generator[Request, Response, None])rr	r.z(typing.AsyncGenerator[Request, Response])�__name__�56__module__�__qualname__�__firstlineno__�__doc__rr!rr'r+�__static_attributes__r�rrrsD��57�"��"���0���	2��2���	1�r5rc�,�\rSrSrSrSSjrSSjrSrg)	�FunctionAuth�qz�58Allows the 'auth' argument to be passed as a simple callable function,59that takes the request, and returns a new, modified request.60c��Xlg�N��_func)r�funcs  r�__init__�FunctionAuth.__init__ws���61r5c#�2# �URU5v� g7fr:r;rs  rr�FunctionAuth.auth_flowzs����j�j��!�!�s�r;N)r=z#typing.Callable[[Request], Request]r.�Noner-)r/r0r1r2r3r>rr4rr5rr7r7qs���62�"r5r7c�6�\rSrSrSrSSjrS	SjrS63SjrSrg)r�~zm64Allows the 'auth' argument to be passed as a (username, password) pair,65and uses HTTP Basic authentication.66c�0�URX5Ulgr:)�_build_auth_header�_auth_header�r�username�passwords   rr>�BasicAuth.__init__�s�� �3�3�H�G��r5c#�F# �URURS'Uv� g7f)N�
Authorization)rG�headersrs  rr�BasicAuth.auth_flow�s���+/�+<�+<�����(��
�s�!c��SR[U5[U545n[U5R5nSU3$�N�:zBasic ��joinrr�decode�rrIrJ�userpass�tokens     rrF�BasicAuth._build_auth_header��?���9�9�h�x�0�(�8�2D�E�F���(�#�*�*�,����w��r5)rGN�rI�str | bytesrJr\r.rBr-�rIr\rJr\r.�str�	r/r0r1r2r3r>rrFr4rr5rrr~s���67H�� r5rc�:�\rSrSrSrSS	SjjrS68SjrSSjrSrg)r�zL69Use a 'netrc' file to lookup basic auth credentials based on the url host.70Nc�8�SSKnURU5Ulg)Nr)�netrc�_netrc_info)r�filercs   rr>�NetRCAuth.__init__�s��	� �;�;�t�,��r5c#��# �URRURR5nUb71US(dUv� gUR	USUSS9UR72S'Uv� g7f)N�r)rIrJrM)rd�authenticators�url�hostrFrN)rr�	auth_infos   rr�NetRCAuth.auth_flow�sk����$�$�3�3�G�K�K�4D�4D�E�	���I�a�L��M�04�/F�/F�"�1��	�!��0G�0�G�O�O�O�,��M�s�A*A,c��SR[U5[U545n[U5R5nSU3$rQrSrVs     rrF�NetRCAuth._build_auth_header�rZr5)rdr:)rez73str | Noner.rBr-r]r_rr5rrr�s���-�74� r5rc	�8�\rSrSr%\R75\R76\R\R\R\R\R\RS.r	S\77S'SSjrSSjrSSjr
SSjrSS	jrSS78jrSSjrSrg
)r�)�MD5zMD5-SESS�SHAzSHA-SESSzSHA-256zSHA-256-SESSzSHA-512zSHA-512-SESSz*dict[str, typing.Callable[[bytes], _Hash]]�_ALGORITHM_TO_HASH_FUNCTIONc�`�[U5Ul[U5UlSUlSUlg)Nr)r�	_username�	_password�_last_challenge�_nonce_countrHs   rr>�DigestAuth.__init__�s*��!�(�+���!�(�+���<@�����r5c#�T# �UR(a(URXR5URS'Uv�nURS:wdSUR;agURR	S5H)nUR5R
S5(dM) O gURXU5UlSUlURXR5URS'UR(a"[UR5RUS9 Uv� g7f)NrMi�zwww-authenticatezdigest r�r)rxrFrN�status_code�get_list�lower�79startswith�_parse_challengery�cookiesr�set_cookie_header)rrr&�auth_headers    rr�DigestAuth.auth_flow�s������/3�/F�/F��-�-�0�G�O�O�O�,�!�=�����3�&�*<�H�DT�DT�*T�
�#�+�+�4�4�5G�H�K�� � �"�-�-�i�8�8��I�
�#�4�4�W��T������+/�+B�+B��)�)�,80�����(�����H�$�$�%�7�7��7�H��
�s
�BD(�%BD(c��URS5upEnUR5S:Xde0n[U5H2nUR5R	SS5up�[U815Xy'M4 USR
5nUSR
5nURSS5n
S	U;aUS	R
5OS82nSU;aUSR
5OS83n[X�X�US9$![anS
n[UUS9UeS84nAff=f)z�85Returns a challenge from a Digest WWW-Authenticate header.86These take the form of:87`Digest realm="realm@host.com",qop="auth,auth-int",nonce="abc",opaque="xyz"`88� �digest�=r�realm�nonce�	algorithmrr�opaqueN�qop)r�r�r�r�r�z(Malformed Digest WWW-Authenticate headerr|)�	partitionrr�strip�splitr
�encode�get�_DigestAuthChallenge�KeyErrorr)rrr&r��scheme�_�fields�header_dict�field�key�valuer�r�r�r�r��exc�messages                  rr��DigestAuth._parse_challenge�s��(�1�1�#�6���6��|�|�~��)�)�)�&(��$�V�,�E�����,�,�S�!�4�J�C�&�u�~�K��-�	C���(�/�/�1�E���(�/�/�1�E�#����U�;�I�7?�;�7N�[��*�1�1�3�TX�F�16�+�1E�+�e�$�+�+�-�4�C�'��I�RU��
���	C�@�G����9�s�B��	C�s�/A8C(�(89D�2
C?�?Dc	�L^�URURR5mSU4SjjnSRURUR90UR45nURRnSRURR5U45nU"U5nSUR-nURURUR5n	U=RS-
slU"U5n91URR5RS5(a#U"SRX�RU	455n92UR!UR"US9nUcX�RU/nOX�RX�X�/nURUR93URUU"SRU55URR5S.n
UR$(aUR$U
S'U(a
S	U
S94'X�S'X�S'S
UR'U
5-$)Nc�L>�T"U5R5R5$r:)�	hexdigestr�)�data�	hash_funcs �rr��-DigestAuth._build_auth_header.<locals>.digests����T�?�,�,�.�5�5�7�7r5rRs%08xrz-sessr|)rIr�r��urir&r�r��authr��nc�cnoncezDigest )r��bytesr.r�)rtr��upperrTrvr�rwrj�raw_path�methodr�ry�_get_client_noncer�r�endswith�_resolve_qopr�r��_get_header_value)rr�	challenger��A1�path�A2�HA2�nc_valuer��HA1r��digest_data�format_argsr�s              @rrF�DigestAuth._build_auth_header�s�����4�4�Y�5H�5H�5N�5N�5P�Q�	�	8��Y�Y����	������H�
I���{�{�#�#��
�Y�Y����-�-�/��6�
7���R�j���T�.�.�.���'�'��(9�(9�9�?�?�K�����Q����R�j�����$�$�&�/�/��8�8�����C���&�#A�B�C�C����	�
�
�w��?���;�����5�K�����3�L�K�����_�_��_�_���t�y�y��5�6�"�,�,�3�3�5�
95�����$-�$4�$4�K��!��!(�K��� (���$*��!��4�1�1�+�>�>�>r5c�$�[U5R5nX2-
nU[R"5R5-
nU[R96"S5-
n[R"U5R5SSR5$)N��)	r^r��time�ctime�os�urandom�hashlib�sha1r�)r�nonce_countr��ss    rr��DigestAuth._get_client_nonce/sn�����#�#�%��	�97��	�T�Z�Z�\�
 �
 �
"�"��	�R�Z�Z��]����|�|�A��(�(�*�3�B�/�6�6�8�8r5c���SnSnSnSn[UR55H9unupxUS:�aUS-
nXr;aUOUn	XYRU[U55-
nM; U$)N)r�r�r�z{}="{}"z{}={}�rz, )�	enumerate�items�formatr)98r�
header_fields�NON_QUOTED_FIELDS�QUOTED_TEMPLATE�NON_QUOTED_TEMPLATE�header_value�ir�r��templates99          rr��DigestAuth._get_header_value7s��6��#��%����!*�=�+>�+>�+@�!A��A�~���1�u���$���1� �(�
�100
�O�O�E�6�%�=�A�A�L�"B��r5c��Ucg[R"SU5nSU;agUS/:Xa[S5eSU<S3n[XBS9e)Ns, ?r�sauth-intz.Digest auth-int support is not yet implementedzUnexpected qop value "z" in digest authr|)�rer��NotImplementedErrorr)rr�r�qopsr�s     rr��DigestAuth._resolve_qopIsT���;���x�x���$���d�?���K�=� �%�&V�W�W�*�3�'�1A�B���G�5�5r5)rxryrwrvNr[r-)rr	r&r101r�r^r.r�)rr	r�r�r.r^)r��intr�r�r.r�)r�zdict[str, bytes]r.r^)r��bytes | Nonerr	r.r�)r/r0r1r2r��md5r��sha256�sha512rt�__annotations__r>rr�rFr�r�r�r4rr5rrr�s����{�{��K�K��|�|��L�L��>�>�����>�>����	O��!K�	���>C��C�*2�C�AD�C�	�C�>.?��.?�+?�.?�	�.?�`9��$6r5rc�H�\rSrSr%S\S'S\S'S\S'S\S'S\S	'S102rg)r�iWr�r�r�r^r�r�r�r�rN)r/r0r1r2r�r4rr5rr�r�Ws���L��L��N���	�r5r�)�103__future__rr�r�r�r��typing�base64r�urllib.requestr�_exceptionsr�_modelsrr	r104�_utilsrrr
�
TYPE_CHECKINGr�__all__rr7rrr�105NamedTupler�rr5r�<module>r�s���"��	�	��
��*�&�/�/�-�-�	����;��X�X�v106"�4�107"� �� �& �� �<e6��e6�P�6�,�,�r5
codekingpro/portable-devtools · Team Ai