https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/boto/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/boto/__pycache__/auth.cpython-310.pyc
o

ckF[V��@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlZddlZddl
Z
ddlmZmZmZmZddlmZddlmZzddlmZddlmZWneyiddlZdZYnwgd	�Zgd
�ZGdd�de�ZGd
d�dee�ZGdd�dee�ZGdd�dee�Z Gdd�dee�Z!Gdd�dee�Z"Gdd�dee�Z#Gdd�de#e�Z$Gdd�de�Z%Gdd�de�Z&Gdd �d e&e�Z'Gd!d"�d"e&e�Z(Gd#d$�d$e&e�Z)Gd%d&�d&e)e�Z*d-d'd(�Z+d)d*�Z,d+d,�Z-dS).z/
Handles authentication required to AWS and GS
�N)�
formatdate)�urllib�encodebytes�
parse_qs_safe�urlparse)�AuthHandler)�BotoClientError)�sha1)�sha256)z-ap-northeast-1z.ap-northeast-1z-ap-southeast-1z.ap-southeast-1z-ap-southeast-2z.ap-southeast-2z
-eu-west-1z
.eu-west-1z-external-1z.external-1z
-sa-east-1z
.sa-east-1z
-us-east-1z
.us-east-1z-us-gov-west-1z.us-gov-west-1z
-us-west-1z
.us-west-1z
-us-west-2z
.us-west-2)
z.cn-z.eu-centralz-eu-centralz.ap-northeast-2z-ap-northeast-2z.ap-south-1z-ap-south-1z
.us-east-2z
-us-east-2z-ca-centralz.ca-centralz
.eu-west-2z
-eu-west-2c@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�HmacKeyszKey based Auth handler helper.cCs2|jdus
|jdurtj���||_|�|�dS�N)�
access_key�
secret_key�boto�auth_handler�NotReadyToAuthenticate�host�update_provider��selfr�config�provider�r�+/usr/lib/python3/dist-packages/boto/auth.py�__init__es
zHmacKeys.__init__cCsL||_tj|jj�d�td�|_tr!tj|jj�d�td�|_dSd|_dS�N�utf-8)�	digestmod)	�	_provider�hmac�newr�encode�sha�_hmacr
�	_hmac_256�rrrrrrks��
zHmacKeys.update_providercCs|jrdSdS)N�
HmacSHA256�HmacSHA1)r$�rrrr�	algorithmuszHmacKeys.algorithmcCs(|jrt}nt}tj|jj�d�|d�Sr)r$r
r"rr rrr!)rrrrr�	_get_hmac{s�zHmacKeys._get_hmaccCs.|��}|�|�d��t|����d���S�Nr)r*�updater!r�digest�decode�strip)r�string_to_sign�new_hmacrrr�sign_string�szHmacKeys.sign_stringcCst�|j�}|d=|d=|S)Nr#r$)�copy�__dict__)r�pickled_dictrrr�__getstate__�szHmacKeys.__getstate__cCs||_|�|j�dSr)r4rr)r�dctrrr�__setstate__�szHmacKeys.__setstate__N)�__name__�
__module__�__qualname__�__doc__rrr)r*r2r6r8rrrrrbs
rcs.eZdZdZdgZ�fdd�Zdd�Z�ZS)�AnonAuthHandlerz(
    Implements Anonymous requests.
    �anoncstt|��|||�dSr)�superr=rr��	__class__rrr�szAnonAuthHandler.__init__cKsdSrr)r�http_request�kwargsrrr�add_auth�szAnonAuthHandler.add_auth)r9r:r;r<�
capabilityrrD�
__classcell__rrr@rr=�s
r=c�8eZdZdZddgZdd�Z�fdd�Zdd	�Z�ZS)
�HmacAuthV1Handlerz:    Implements the HMAC request signing used by S3 and GS.zhmac-v1�s3cC�*t�||||�t�||||�d|_dSr�rrrr$rrrrr��
zHmacAuthV1Handler.__init__c�tt|��|�d|_dSr)r?rHrr$r%r@rrr��
z!HmacAuthV1Handler.update_providercKs�|j}|j}|j}d|vrtdd�|d<|jjr"|jj}|jj||<tj�	|||d|j�}tj
�d|�|�|�}|jj
}	d|	|jj|f}
tj
�d|
�|
|d<dS)N�DateT��usegmt�StringToSign:
%s�%s %s:%s�
Signature:
%s�
Authorization)�headers�method�	auth_pathrr�security_token�security_token_headerr�utils�canonical_string�log�debugr2�auth_headerr
)rrBrCrVrWrX�keyr0�b64_hmac�auth_hdr�authrrrrD�s$
�
zHmacAuthV1Handler.add_auth�	r9r:r;r<rErrrDrFrrr@rrH�srHcrG)
�HmacAuthV2HandlerzJ
    Implements the simplified HMAC authorization used by CloudFront.
    zhmac-v2�
cloudfrontcCrJrrKrrrrr�rLzHmacAuthV2Handler.__init__crMr)r?rerr$r%r@rrr�rNz!HmacAuthV2Handler.update_providercKsh|j}d|vrtdd�|d<|jjr|jj}|jj||<|�|d�}|jj}d||jj|f|d<dS)NrOTrPrSrU)rVrrrYrZr2r_r
)rrBrCrVr`rarbrrrrD�s��zHmacAuthV2Handler.add_authrdrrr@rre�srec@s(eZdZdZgd�Zdd�Zdd�ZdS)�HmacAuthV3Handlerz@Implements the new Version 3 HMAC authorization used by Route53.)zhmac-v3�route53�sescC�$t�||||�t�||||�dSr�rrrrrrrr��zHmacAuthV3Handler.__init__cKsr|j}d|vrtdd�|d<|jjr|jj}|jj||<|�|d�}d|jj}|d|��|f7}||d<dS)NrOTrPzAWS3-HTTPS AWSAccessKeyId=%s,zAlgorithm=%s,Signature=%s�X-Amzn-Authorization)rVrrrYrZr2r
r))rrBrCrVr`ra�srrrrD�szHmacAuthV3Handler.add_authN)r9r:r;r<rErrDrrrrrg�s
rgc@s>eZdZdZdgZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
S)�HmacAuthV3HTTPHandlerzK
    Implements the new Version 3 HMAC authorization used by DynamoDB.
    zhmac-v3-httpcCrjrrkrrrrrrlzHmacAuthV3HTTPHandler.__init__cCs<d|ji}|j��D]\}}|��}|�d�r|||<q
|S)�k
        Select the headers from the request that need to be included
        in the StringToSign.
        �Host�x-amz)rrV�items�lower�
startswith)rrB�headers_to_sign�name�value�lnamerrrrvs

�z%HmacAuthV3HTTPHandler.headers_to_signcs t�fdd��D��}d�|�S)�

        Return the headers that need to be included in the StringToSign
        in their canonical form by converting all header keys to lower
        case, sorting them in alphabetical order and then joining
        them into a string, separated by newlines.
        cs(g|]}d|�����|��f�qS)�%s:%s�rtr/��.0�n�rvrr�
<listcomp>s
�

�z;HmacAuthV3HTTPHandler.canonical_headers.<locals>.<listcomp>�
��sorted�join�rrv�lrr�r�canonical_headerss�
z'HmacAuthV3HTTPHandler.canonical_headerscCs8|�|�}|�|�}d�|j|jd|d|jg�}||fS)��
        Return the canonical StringToSign as well as a dict
        containing the original version of all headers that
        were included in the StringToSign.
        r��)rvr�r�rWrX�body)rrBrvr�r0rrrr0s

�z$HmacAuthV3HTTPHandler.string_to_signcKs�d|jvr	|jd=tdd�|jd<|jjr|jj|jd<|�|�\}}tj�d|�t|�	d���
�}|�|�}d|jj}|d	|�
�7}|d
d�|�7}|d|7}||jd<d
S)z�
        Add AWS3 authentication to a request.

        :type req: :class`boto.connection.HTTPRequest`
        :param req: The HTTPRequest object.
        rmTrP�
X-Amz-Date�X-Amz-Security-TokenrRrzAWS3 AWSAccessKeyId=%s,z
Algorithm=%s,zSignedHeaders=%s,�;�Signature=%sN)rVrrrYr0rr]r^r
r!r-r2r
r)r�)r�reqrCr0rv�
hash_valuerarnrrrrD,s
	
zHmacAuthV3HTTPHandler.add_authN)
r9r:r;r<rErrvr�r0rDrrrrro�sroc@s�eZdZdZdgZ	d+dd�Zd,dd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�ZdS)-�HmacAuthV4Handlerz:
    Implements the new Version 4 HMAC authorization.
    �hmac-v4NcCs0t�||||�t�||||�||_||_dSr)rrr�service_name�region_name)rrrrr�r�rrrrLs
zHmacAuthV4Handler.__init__FcCsPt|t�s
|�d�}|rt�||�d�t���}|St�||�d�t���}|Sr+)�
isinstance�bytesr!rr r
�	hexdigestr-)rr`�msg�hex�sigrrr�_signVs

�zHmacAuthV4Handler._signcCsr|�|j|�}|j�d�r|jd}d|i}|j��D]\}}|��}|�d�r6t|t�r2|�	d�}|||<q|S)rprqrrr)
�host_headerrrV�getrsrtrur�r�r.�rrB�host_header_valuervrwrxryrrrrv`s



�z!HmacAuthV4Handler.headers_to_signcCs8|j}|jdk}|dkr|r|dkr|r|Sd||fS�N�https�Pi�r{)�port�protocol�rrrBr��securerrrr�qs

zHmacAuthV4Handler.host_headercCsbt|j���}g}|D] }tj�|j|�}|�tjj	|dd�dtjj	|dd��qd�
|�S)Nr���safe�=�-_~�&)r��params�keysrr[�get_utf8_value�appendr�parse�quoter�)rrB�parameter_names�pairs�pname�pvalrrr�query_stringxs�
zHmacAuthV4Handler.query_stringc	Csh|jdkrdSg}t|j�D] }tj�|j|�}|�dtjj	|dd�tjj	|dd�f�qd�
|�S)N�POSTr��%s=%s�-_.~r�r�)rWr�r�rr[r�r�rr�r�r��rrBr��paramrxrrr�canonical_query_string�s

�
z(HmacAuthV4Handler.canonical_query_stringcCsjg}|D])}|����}t||�}d|vr|��}n	d�|�����}|�d||f�qd�t|��S)rz�"� r{r�)rtr/�strr��splitr�r�)rrv�	canonical�header�c_name�	raw_value�c_valuerrrr��s
z#HmacAuthV4Handler.canonical_headerscCs dd�|D�}t|�}d�|�S)NcS�g|]
}d|�����qS�z%sr|r}rrrr���z4HmacAuthV4Handler.signed_headers.<locals>.<listcomp>r�r�r�rrr�signed_headers�s
z HmacAuthV4Handler.signed_headerscCsF|j}t�|��dd�}tj�|�}t|�dkr!|�d�r!|d7}|S)N�\�/�)	rX�	posixpath�normpath�replacerr�r��len�endswith)rrB�path�
normalized�encodedrrr�
canonical_uri�szHmacAuthV4Handler.canonical_uricCsN|j}t|d�rt|d�rtjj|td�dSt|t�s!|�d�}t|��	�S)N�seek�read)�hash_algorithmrr)
r��hasattrrr[�compute_hashr
r�r�r!r�)rrBr�rrr�payload�s

zHmacAuthV4Handler.payloadcCst|j��g}|�|�|��|�|�|��|�|�}|�|�|�d�|�|�|��|�|�|��d�	|�S)Nr�)
rW�upperr�r�r�rvr�r�r�r�)rrB�crrvrrr�canonical_request�s

z#HmacAuthV4Handler.canonical_requestcCsB|jjg}|�|j�|�|j�|�|j�|�d�d�|�S)N�aws4_requestr�)rr
r��	timestampr�r�r�)rrB�scoperrrr��s


zHmacAuthV4Handler.scopecCs
|�d�S)N�.)r��rrrrr�split_host_parts�s
z"HmacAuthV4Handler.split_host_partscCsj|�|�}|jdur|j}|St|�dkr/|ddkrd}|St|�dkr)d}|S|d}|S|d}|S)Nr�zus-govz
us-gov-west-1��	us-east-1r)r�r�r�)rr�partsr�rrr�determine_region_name�s

�	���z'HmacAuthV4Handler.determine_region_namecCs*|�|�}|jdur|j}|S|d}|S)Nr)r�r�)rrr�r�rrr�determine_service_name�s

�z(HmacAuthV4Handler.determine_service_namecCstg}|jddd�|_|�|j�|�|j�}|�|j�}||_||_|�|j�|�|j�|�d�d�|�S)Nr�r�r�r�)	rVr�r�r�rr�r�r�r�)rrBr�r�r�rrr�credential_scope�s

z"HmacAuthV4Handler.credential_scopecCsHdg}|�|jd�|�|�|��|�t|�d�����d�|�S)r��AWS4-HMAC-SHA256r�rr�)r�rVr�r
r!r�r�)rrBr��stsrrrr0�s

z HmacAuthV4Handler.string_to_signcCsX|jj}|�d|�d�|j�}|�||j�}|�||j�}|�|d�}|j||dd�S)N�AWS4rr�T)r�)rrr�r!r�r�r�)rrBr0r`�k_date�k_region�	k_service�	k_signingrrr�	signatures�zHmacAuthV4Handler.signaturecKsbd|jvr	|jd=tj��}|�d�|jd<|jjr!|jj|jd<|�|�}|}d|vr3|�|d�}|rM|jdkrM||_d|jd<t	t
|j��|jd	<n|j�d
�d|_|r`|jd
||_|�
|�}tj�d|�|�||�}tj�d
|�|�||�}tj�d|�|�|�}	d|�|�g}
|
�d|�|	��|
�d|�d�|
�|jd<dS)z�
        Add AWS4 authentication to a request.

        :type req: :class`boto.connection.HTTPRequest`
        :param req: The HTTPRequest object.
        rm�%Y%m%dT%H%M%SZr�r��
unmangled_reqr��0application/x-www-form-urlencoded; charset=UTF-8�Content-Type�Content-Length�?rzCanonicalRequest:
%srRrTzAWS4-HMAC-SHA256 Credential=%szSignedHeaders=%sr��,rUN)rV�datetime�utcnow�strftimerrYr�rWr�r�r�r�r�r�rr]r^r0r�rvr�r�r�r�)rr�rC�now�qs�
qs_to_postr�r0r�rvr�rrrrDs8
	




zHmacAuthV4Handler.add_auth)NN)F)r9r:r;r<rErr�rvr�r�r�r�r�r�r�r�r�r�r�r�r�r0r�rDrrrrr�Es.
�


	
	r�cs�eZdZdZdgZ�fdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
�fdd�Z�fdd�Zddd�Z�ZS)�S3HmacAuthV4HandlerzN
    Implements a variant of Version 4 HMAC authorization specific to S3.
    �
hmac-v4-s3cs2tt|�j|i|��|jr|�|j�|_dSdSr)r?rrr��clean_region_name)r�argsrCr@rrrOs�zS3HmacAuthV4Handler.__init__cCs|�d�r|dd�S|S)N�s3-r�)ru)rr�rrrrUs
z%S3HmacAuthV4Handler.clean_region_namecCs0tj�|j�}tj�|j�}tjj|dd�}|S)Nz/~r�)rr�rr��unquoter�)rrBr��unquotedr�rrrr�[sz!S3HmacAuthV4Handler.canonical_uric	CsZg}t|j�D] }tj�|j|�}|�dtjj|dd�tjj|dd�f�qd�	|�S)Nr�r�r�r�)
r�r�rr[r�r�rr�r�r�r�rrrr�es
�
z*S3HmacAuthV4Handler.canonical_query_stringcCs<|j}|jdk}|dkr|r|dkr|r|jSd|j|fSr�)r�r�rr�rrrr�ps

zS3HmacAuthV4Handler.host_headercCsF|�|j|�}d|i}|j��D]\}}|��}|dvr |||<q|S)rprq)�
authorization)r�rrVrsrtr�rrrrvws�z#S3HmacAuthV4Handler.headers_to_signcCs�|�|�}|jdur|j}|St|�dkr$|�|d�}|dkr"d}|Stt|��D]'\}}|��}|dkrD||}|dkrAd}|S|�d�rQ|�|�}|Sq*|S)Nr�rrIr��	amazonawsr)r�r�r�r�	enumerate�reversedrtru)rrr�r��offset�partrrrr��s.

��

�
�z)S3HmacAuthV4Handler.determine_region_namecCsdS)NrIrr�rrrr��sz*S3HmacAuthV4Handler.determine_service_namec	Cs�t�|�}tj�|j�}|j|_|jduri|_n|j��}||_|j}t|dd�}|�	�D]\}}t
|ttf�rEt
|�dkrE|d||<q.|j�|�|S)z|
        Returns a copy of the request object with fixed ``auth_path/params``
        attributes from the original.
        NT)�keep_blank_valuesr�r)r3rr�rrXr�r��queryrrsr��list�tupler�r,)	rr��modified_req�parsed_path�copy_params�raw_qs�existing_qsr`rxrrr�mangle_path_and_params�s&


��z*S3HmacAuthV4Handler.mangle_path_and_paramscs&|j�d�r|jdStt|��|�S)N�x-amz-content-sha256)rVr�r?rr�)rrBr@rrr��s
zS3HmacAuthV4Handler.payloadcs^d|jvrd|jvr|j�d�|jd<n|�|�|jd<|�|�}tt|�j|fd|i|��S)Nr�_sha256r�)rV�popr�rr?rrD)rr�rC�updated_reqr@rrrD�s


��zS3HmacAuthV4Handler.add_authNcCs|durtj���d�}|�|j�}|�|j�}dd|jj|dd�||f||dd�}|jjr6|jj|d<|�	|�}t
d	d
�|D��}d�|�|d<|j�
|�|�|�}	d
�|	�d
�dd��d}	||jd<|�||	�}
|�||
�}||jd<d|j|j|jtj�|j�fS)z�
        Presign a request using SigV4 query params. Takes in an HTTP request
        and an expiration time in seconds and returns a URL.

        http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html
        Nr�r�z%s/%s/%s/%s/aws4_requestr�r)zX-Amz-AlgorithmzX-Amz-Credentialr�z
X-Amz-Expires�X-Amz-SignedHeadersr�cSr�r�r|r}rrrr�r�z/S3HmacAuthV4Handler.presign.<locals>.<listcomp>r�rr����z
UNSIGNED-PAYLOADr�zX-Amz-Signaturez%s://%s%s?%s)r�r�r�r�rr�rr
rYrvr�r�r�r,r�r�rVr0r�r�r�rr��	urlencode)rr��expires�iso_date�region�servicer�rvr�r�r�r�rrr�presign�s<
��




�zS3HmacAuthV4Handler.presignr)r9r:r;r<rErrr�r�r�rvr�r�rr�rDr$rFrrr@rrIs
-*rc@s.eZdZdZdgZdd�Zdd�Zdd�Zd	S)
�STSAnonHandlerz�
    Provides pure query construction (no actual signing).

    Used for making anonymous STS request for operations like
    ``assume_role_with_web_identity``.
    zsts-anoncCstj�|�Sr)rr�r�)rrxrrr�
_escape_value4szSTSAnonHandler._escape_valuec	Csbt|���}|jdd�d�g}|D]}tj�||�}|�|d|�|�d���qd�	|�S)NcS�|��Sr�rt��xrrr�<lambda>=�z4STSAnonHandler._build_query_string.<locals>.<lambda>�r`r�rr�)
rr��sortrr[r�r�r&r.r�)rr�r�r�r`�valrrr�_build_query_string;s 
z"STSAnonHandler._build_query_stringcKs4|j}|�|j�}tj�d|�d|d<||_dS)Nzquery_string in body: %sz!application/x-www-form-urlencodedr�)rVr0r�rr]r^r�)rrBrCrVrrrrrDDs�
zSTSAnonHandler.add_authN)r9r:r;r<rEr&r0rDrrrrr%*s	r%c@seZdZdZdd�ZdS)�QuerySignatureHelperzy
    Helper for Query signature based Auth handler.

    Concrete sub class need to implement _calc_sigature method.
    cKs�|j}|j}|jj|d<|j|d<tj��|d<|�|j|j	|j
|j�\}}tj�
d||f�|j	dkrPd|d<|dtj�|�|_tt|j��|jd	<dSd
|_|j�d�d|_|jd|dtj�|�|_dS)
N�AWSAccessKeyId�SignatureVersion�	Timestamp�query_string: %s Signature: %sr�r�r��&Signature=r�r�r�r)rVr�rr
r3rr[�get_ts�_calc_signaturerWrXrr]r^rr��
quote_plusr�r�r�r�r�)rrBrCrVr�rr�rrrrDWs*
�
�

�zQuerySignatureHelper.add_authN)r9r:r;r<rDrrrrr1Psr1c@s"eZdZdZdZdgZdd�ZdS)�QuerySignatureV0AuthHandlerzProvides Signature V0 Signingrzsign-v0c
Gs�tj�d�|��}|d|d}|�|�d��|��}|jdd�d�g}|D]}tj�	||�}|�
|dtj�
|��q*d	�|�}	|	t�|���fS)
Nzusing _calc_signature_0�Actionr4rcSst|��|���Sr)�cmprt)r*�yrrrr+z�z=QuerySignatureV0AuthHandler._calc_signature.<locals>.<lambda>)r<r�r�)rr]r^r*r,r!r�r.r[r�r�rr�r�r��base64�	b64encoder-)
rr�rrrnr�r�r`r/rrrrr8ts
z+QuerySignatureV0AuthHandler._calc_signatureN�r9r:r;r<r3rEr8rrrrr:ns
r:c@s,eZdZdZdZddgZdd�Zdd�Zd	S)
�QuerySignatureV1AuthHandlerz5
    Provides Query Signature V1 Authentication.
    r�zsign-v1�mturkcOs:tj|g|�Ri|��tj|g|�Ri|��d|_dSr)r1rrr$)rr�kwrrrr�s
z$QuerySignatureV1AuthHandler.__init__c	Gs�tj�d�|��}t|���}|jdd�d�g}|D]$}|�|�d��tj	�
||�}|�|�|�|dtj
�|��qd�|�}|t�|���fS)Nzusing _calc_signature_1cSr'rr(r)rrrr+�r,z=QuerySignatureV1AuthHandler._calc_signature.<locals>.<lambda>r-rr�r�)rr]r^r*rr�r.r,r!r[r�r�rr�r�r�r?r@r-)	rr�rrr�r�r`r/rrrrr8�s

z+QuerySignatureV1AuthHandler._calc_signatureN)r9r:r;r<r3rErr8rrrrrB�srBc@s$eZdZdZdZgd�Zdd�ZdS)�QuerySignatureV2AuthHandlerz+Provides Query Signature V2 Authentication.�)zsign-v2�ec2rG�emr�fps�ecs�sdb�iam�rds�sns�sqs�cloudformationc
Cstj�d�d||��|f}|��}|��|d<|jjr#|jj|d<t|�	��}g}|D]}	tj
�||	�}
|�t
jj|	dd�dt
jj|
dd��q-d	�|�}tj�d
|�||7}tj�d|�|�|�d��t�|���}tj�d
t|��tj�d|�||fS)Nzusing _calc_signature_2z	%s
%s
%s
�SignatureMethod�
SecurityTokenr�r�r�r�r�zquery string: %szstring_to_sign: %srzlen(b64)=%dzbase64 encoded digest: %s)rr]r^rtr*r)rrYr�r�r[r�r�rr�r�r�r,r!r?r@r-r�)
rr��verbr��server_namer0rr�r�r`r/r�b64rrrr8�s,�
z+QuerySignatureV2AuthHandler._calc_signatureNrArrrrrE�s
rEc@seZdZdZdgZdd�ZdS)�POSTPathQSV2AuthHandlerz�
    Query Signature V2 Authentication relocating signed query
    into the path and allowing POST requests with Content-Types.
    �mwscKs�|jj|jd<|j|jd<tj��|jd<|�|j|j|j	|j
�\}}tj�d||f�|jdkrGt
t|j��|jd<|j�dd�|jd<nd	|_|j�d
�d|_|jd
|dtj�|�|_dS)
Nr2r3r4r5r�r�r�z
text/plainr�r�rr6)rr
r�r3rr[r7r8rWrXrr]r^r�r�r�rVr�r�r�rr�r9)rr�rCrr�rrrrD�s&�
��

�z POSTPathQSV2AuthHandler.add_authN)r9r:r;r<rErDrrrrrV�srVc		Cs�g}tj�t|�}|D]}z|�||||��Wqtjjy#Yqw|s=|}dd�|D�}tj�dt	|�t
|�f��|dS)a�Finds an AuthHandler that is ready to authenticate.

    Lists through all the registered AuthHandlers to find one that is willing
    to handle for the requested capabilities, config and provider.

    :type host: string
    :param host: The name of the host

    :type config:
    :param config:

    :type provider:
    :param provider:

    Returns:
        An implementation of AuthHandler.

    Raises:
        boto.exception.NoAuthHandlerFound
    cSsg|]}|j�qSr)r9)r~�handlerrrrr��r>z$get_auth_handler.<locals>.<listcomp>zYNo handler was ready to authenticate. %d handlers were checked. %s Check your credentialsr)r�plugin�
get_pluginrr�rr�	exception�NoAuthHandlerFoundr�r�)	rrr�requested_capability�ready_handlers�
auth_handlersrX�checked_handlers�namesrrr�get_auth_handler�s"���rbc��fdd�}|S)Ncsjtj�dd�r
dgStj�ddd�rdgSt|d�r1t|jdd�r1tD]
}||jj	vr0dgSq#�|�S)	N�
EC2_USE_SIGV4Fr�rG�	use-sigv4r"�endpointr�)
�os�environr�rrr��getattrr"�SIGV4_DETECTrf)r�test��funcrr�_wrapper
s

�z(detect_potential_sigv4.<locals>._wrapperr�rmrnrrlr�detect_potential_sigv4srpcrc)Ncs�tj�dd�r
dgStj�ddd�rdgSt�d�s���StD]}|�jvr,dgSq �j}�j�d�r<�j�d�r@d|}t	|�j
}|�d	�sS|�d
�sS���S|�d�r\���St�fdd
�t
D��rk���St�d�rw�jrw���SdgS)N�S3_USE_SIGV4FrrIrerzhttp://zhttps://z
amazonaws.comzamazonaws.com.cnzs3.amazonaws.comc3s�|]}|�jvVqdSr)r)r~rkr(rr�	<genexpr>As�z=detect_potential_s3sigv4.<locals>._wrapper.<locals>.<genexpr>r>)rgrhr�rrr�rjrrur�netlocr��any�S3_AUTH_DETECTr>)rrkrrsrlr(rrn"s6


�
�

�
z*detect_potential_s3sigv4.<locals>._wrapperrrorrlr�detect_potential_s3sigv4!s)rvr).r<r?r�boto.auth_handler�boto.exception�boto.plugin�
boto.utilsr3r��email.utilsrrrgr��boto.compatrrrrrr�hashlibr	r"r
�ImportErrorrurj�objectrr=rHrergror�rr%r1r:rBrErVrbrprvrrrr�<module>sZ�1#Kb&
2

https://t.me/RX1948 - 2025