
    Bfa                         d dl Z d dlZd dlZd dlZd dlZd dlZd dlmZ d dlm	Z	 d dl
Zd dlmZ d dl
mZ d dlmZ d dlmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5 d dl6m7Z7 d d	l8m9Z9 d d
l:m;Z; d dl<m=Z= d dl>m?Z?m@Z@  ejA        eB          ZCd=dZD G d de'          ZEd ZFd ZGd ZHeHZI G d de          ZJ G d de)          ZK G d deK          ZL G d de          ZM G d deeM          ZN G d deeN          ZO G d d eN          ZP G d! d"e&          ZQ G d# d$e!          ZR G d% d&e           ZS G d' d(e$          ZT G d) d*e+          ZU G d+ d,e          ZV G d- d.e          ZW G d/ d0e          ZX G d1 d2e          ZY G d3 d4e          ZZ G d5 d6e          Z[ G d7 d8e          Z\ G d9 d:eM          Z] G d; d<e,          Z^dS )>    N)deepcopy)sha1)UNSIGNED)compat_shell_split)Config)%!_DEFAULT_ADVISORY_REFRESH_TIMEOUTAssumeRoleCredentialFetcherAssumeRoleProvider!AssumeRoleWithWebIdentityProviderBaseAssumeRoleCredentialFetcherBotoProviderCachedCredentialFetcherCanonicalNameCredentialSourcerConfigNotFoundConfigProviderContainerMetadataFetcherContainerProviderCredentialResolverCredentialRetrievalErrorCredentialsEnvProviderInstanceMetadataProviderInvalidConfigErrorMetadataRetrievalErrorOriginalEC2ProviderPartialCredentialsErrorProcessProviderProfileProviderBuilderReadOnlyCredentialsRefreshableCredentialsRefreshWithMFAUnsupportedErrorSharedCredentialProviderSSOProviderSSOTokenLoaderUnauthorizedSSOTokenErrorUnknownCredentialError_get_client_creator
_local_now_parse_if_needed_serialize_if_neededparseresolve_imds_endpoint_mode)tzutc)resolve_awaitable)	AioConfig)AioSSOTokenProvider)AioContainerMetadataFetcherAioInstanceMetadataFetcherc                                           d          pd}                      d          }                      d          }                                                     d          du}                      d          t                     t                                d          d}|i }t                      }t                      }	t          t          || 	                                |	          
          }
t           ||          }t           fdt           |          ||t          ||	|
g          |          }||g}|                    ||          }t                      t!                      |	|
g}||z   |z   }|r/|                    |           t$                              d           t)          |          }|S )zCreate a default credential resolver.
    This creates a pre-configured credential resolver
    that includes the default lookup chain for
    credentials.
    profiledefaultmetadata_service_timeoutmetadata_service_num_attemptsNec2_metadata_service_endpointec2_metadata_v1_disabled)r8   "ec2_metadata_service_endpoint_modeec2_credential_refresh_windowr9   )timeoutnum_attempts
user_agentconfig)iam_role_fetcher)cacheregion_namec                       j         S N)full_config)sessions   f/home/panchajanya/Development/work/volatility3/lib/python3.11/site-packages/aiobotocore/credentials.py<lambda>z,create_credential_resolver.<locals>.<lambda>l   s
    G/     )load_configclient_creatorrA   profile_namecredential_sourcerprofile_provider_builderrL   disable_env_varszWSkipping environment variable credential check because profile name was explicitly set.)	providers)get_config_variableinstance_variablesgetr,   r   AioEnvProviderAioContainerProviderAioInstanceMetadataProviderr2   r>   AioProfileProviderBuilderAioAssumeRoleProviderr'   !AioCanonicalNameCredentialSourcerrQ   AioOriginalEC2ProviderAioBotoProviderremoveloggerdebugAioCredentialResolver)rF   rA   rB   rL   metadata_timeoutr=   rP   imds_configenv_providercontainer_providerinstance_metadata_providerrN   assume_role_providerpre_profileprofile_providerspost_profilerQ   resolvers   `                 rG   create_credential_resolverrk   B   sG    ..y99FYL223MNN../NOOL113377	BB$N *1)D)D+*
 *
 /I/
 /
 *K$+$?$?&%
 %
 K }!##L-//!<3$%))++	
 
 
" " "  9u+      1////*7K@@!<-/IJ
 
 ":	 	 	 	K 1::!) ;  
 	  "	L //,>I 
  	&&&8	
 	
 	

 %y999HOrI   c                   ,    e Zd Zd Zd Zd Zd Zd ZdS )rX   c                 ,     t          | fd          S )Nc                       j         j        S rD   _sessionrE   selfs   rG   rH   zDAioProfileProviderBuilder._create_process_provider.<locals>.<lambda>        9 rI   )rL   rJ   )AioProcessProviderrr   rL   s   ` rG   _create_process_providerz2AioProfileProviderBuilder._create_process_provider   s)    !%9999
 
 
 	
rI   c                 X    | j                             d          }t          ||          S )Ncredentials_file)rL   creds_filename)rp   rR   AioSharedCredentialProvider)rr   rL   credential_files      rG   "_create_shared_credential_providerz<AioProfileProviderBuilder._create_shared_credential_provider   s5    -;;<NOO*%*
 
 
 	
rI   c                 X    | j                             d          }t          ||          S )Nconfig_file)rL   config_filename)rp   rR   AioConfigProvider)rr   rL   r~   s      rG   _create_config_providerz1AioProfileProviderBuilder._create_config_provider   s4    m77FF %'
 
 
 	
rI   c                 l     t           fdt           j         j                   j        ||          S )Nc                       j         j        S rD   ro   rq   s   rG   rH   zIAioProfileProviderBuilder._create_web_identity_provider.<locals>.<lambda>   rs   rI   )rJ   rK   rA   rL   rP   )$AioAssumeRoleWithWebIdentityProviderr'   rp   _region_name_cache)rr   rL   rP   s   `  rG   _create_web_identity_providerz7AioProfileProviderBuilder._create_web_identity_provider   sJ    39999.t0  +%-
 
 
 	
rI   c                      t           fd j        j        | j         j        t           j         j        |                    S )Nc                       j         j        S rD   ro   rq   s   rG   rH   z@AioProfileProviderBuilder._create_sso_provider.<locals>.<lambda>   rs   rI   )rA   rL   )rJ   rK   rL   rA   token_cachetoken_provider)AioSSOProviderrp   create_clientr   _sso_token_cacher0   ru   s   ` rG   _create_sso_providerz.AioProfileProviderBuilder._create_sso_provider   s\    9999=6%+-.+)  
 
 
 	
rI   N)__name__
__module____qualname__rv   r|   r   r   r    rI   rG   rX   rX      s_        
 
 

 
 

 
 
	
 	
 	

 
 
 
 
rI   rX   c                 X   K   t          |           }|                                 d {V S rD   )rk   load_credentials)rF   rj   s     rG   get_credentialsr      s7      )'22H**,,,,,,,,,rI   c                       fd}|S )Nc                     K   4 d {V }  | j         di  d {V }d d d           d {V  n# 1 d {V swxY w Y   |d         }|d         |d         |d         t          |d                   dS )Nr   AccessKeyIdSecretAccessKeySessionToken
Expiration
access_key
secret_keytokenexpiry_timer   )assume_roler*   )stsresponsecredentialsclientparamss      rG   refreshz-create_assume_role_refresher.<locals>.refresh   s&      	7 	7 	7 	7 	7 	7 	7S,S_66v66666666H	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7}- &m4%&78 0/L0IJJ	
 
 	
s   2
<<r   )r   r   r   s   `` rG   create_assume_role_refresherr      s)    
 
 
 
 
 
 NrI   c                 <     G d d          } ||           j         S )Nc                       e Zd Zd Zd ZdS )/create_mfa_serial_refresher.<locals>._Refresherc                 "    || _         d| _        d S )NF)_refresh_has_been_called)rr   r   s     rG   __init__z8create_mfa_serial_refresher.<locals>._Refresher.__init__   s    #DM$)D!!!rI   c                 r   K   | j         rt                      d| _         |                                  d {V S NT)r   r!   r   rq   s    rG   callz4create_mfa_serial_refresher.<locals>._Refresher.call   sG      $ 7 5666$(D!(((((((rI   N)r   r   r   r   r   r   rI   rG   
_Refresherr      s2        	* 	* 	*	) 	) 	) 	) 	)rI   r   )r   )actual_refreshr   s     rG   create_mfa_serial_refresherr      s?    ) ) ) ) ) ) ) ) :n%%**rI   c                       e Zd Zd ZdS )AioCredentialsc                 F   K   t          | j        | j        | j                  S rD   )r   r   r   r   rq   s    rG   get_frozen_credentialsz%AioCredentials.get_frozen_credentials   s%      "OT_dj
 
 	
rI   N)r   r   r   r   r   rI   rG   r   r      s#        
 
 
 
 
rI   r   c                        e Zd Z fdZed             Zej        d             Zed             Zej        d             Zed             Zej        d             Zd Z	d	 Z
d
 Z xZS )AioRefreshableCredentialsc                 j     t                      j        |i | t          j                    | _        d S rD   )superr   asyncioLock_refresh_lockrr   argskwargs	__class__s      rG   r   z"AioRefreshableCredentials.__init__  s3    $)&)))$\^^rI   c                      t          d          NzAmissing call to self._refresh. Use get_frozen_credentials instead)NotImplementedError_access_keyrq   s    rG   r   z$AioRefreshableCredentials.access_key	       "1
 
 	
rI   c                     || _         d S rD   )r   rr   values     rG   r   z$AioRefreshableCredentials.access_key       rI   c                      t          d          r   )r   _secret_keyrq   s    rG   r   z$AioRefreshableCredentials.secret_key  r   rI   c                     || _         d S rD   )r   r   s     rG   r   z$AioRefreshableCredentials.secret_key  r   rI   c                      t          d          r   )r   _tokenrq   s    rG   r   zAioRefreshableCredentials.token#  r   rI   c                     || _         d S rD   )r   r   s     rG   r   zAioRefreshableCredentials.token,  s    rI   c                   K   |                      | j                  sd S | j                                        s| j        4 d {V  |                      | j                  s	 d d d           d {V  d S |                      | j                  }|                     |           d {V  	 d d d           d {V  d S # 1 d {V swxY w Y   d S |                      | j                  r~| j        4 d {V  |                      | j                  s	 d d d           d {V  d S |                     d           d {V  d d d           d {V  d S # 1 d {V swxY w Y   d S d S )N)is_mandatoryT)refresh_needed_advisory_refresh_timeoutr   locked_mandatory_refresh_timeout_protected_refresh)rr   is_mandatory_refreshs     rG   r   z"AioRefreshableCredentials._refresh0  s|     ""4#ABB 	F !((** 	A) 	 	 	 	 	 	 	 	**4+IJJ 	 	 	 	 	 	 	 	 	 	 	 	 	 	 (,':':3( ($ --!5 .          	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	   !@AA 	A ) A A A A A A A A**4+JKK A A A A A A A A A A A A A A --4-@@@@@@@@@	A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A	A 	As0   B>47B>>
CC8E'E
E #E c                   K   	 t          |                                            d {V }n7# t          $ r* |rdnd}t                              d|d           |r Y d S w xY w|                     |           t          | j        | j        | j	                  | _
        |                                 r+d}t                              |           t          |          d S )N	mandatoryadvisoryzARefreshing temporary credentials failed during %s refresh period.Texc_infozLCredentials were refreshed, but the refreshed credentials are still expired.)r.   _refresh_using	Exceptionr^   warning_set_from_datar   r   r   r   _frozen_credentials_is_expiredRuntimeError)rr   r   metadataperiod_namemsgs        rG   r   z,AioRefreshableCredentials._protected_refreshI  s"     	.t/B/B/D/DEEEEEEEEHH 	 	 	)5E++:KNN,	        FF!	" 	H%%%#6d.$
 $
   	$;  NN3s###	$ 	$s   ', 0A A c                 H   K   |                                   d {V  | j        S rD   )r   r   rq   s    rG   r   z0AioRefreshableCredentials.get_frozen_credentialsj  s/      mmoo''rI   )r   r   r   r   propertyr   setterr   r   r   r   r   __classcell__r   s   @rG   r   r     s       , , , , ,     X  ! ! !     X  ! ! !   X \  \A A A2$ $ $B( ( ( ( ( ( (rI   r   c                   *     e Zd ZefdZd fd	Z xZS )!AioDeferredRefreshableCredentialsc                     || _         d | _        d | _        d | _        d | _        || _        t          j                    | _        || _	        d | _
        d S rD   )r   r   r   r   _expiry_time_time_fetcherr   r   r   methodr   )rr   refresh_usingr   time_fetchers       rG   r   z*AioDeferredRefreshableCredentials.__init__p  sT    + )$\^^#'   rI   Nc                 X    | j         dS t                                          |          S r   )r   r   r   )rr   
refresh_inr   s     rG   r   z0AioDeferredRefreshableCredentials.refresh_needed{  s)    #+4ww%%j111rI   rD   )r   r   r   r(   r   r   r   r   s   @rG   r   r   o  sT        ;E 	( 	( 	( 	(2 2 2 2 2 2 2 2 2 2rI   r   c                        e Zd Zd Zd Zd ZdS )AioCachedCredentialFetcherc                 $   K   t          d          )Nz_get_credentials())r   rq   s    rG   _get_credentialsz+AioCachedCredentialFetcher._get_credentials  s      !"6777rI   c                 :   K   |                                   d {V S rD   )_get_cached_credentialsrq   s    rG   fetch_credentialsz,AioCachedCredentialFetcher.fetch_credentials  s*      11333333333rI   c                 6  K   |                                  }|0|                                  d{V }|                     |           nt                              d           |d         }t          |d         d          }|d         |d         |d	         |d
S )zGet up-to-date credentials.

        This will check the cache for up-to-date credentials, calling assume
        role if none are available.
        Nz*Credentials for role retrieved from cache.r   r   T)isor   r   r   r   )_load_from_cacher   _write_to_cacher^   r_   r*   )rr   r   creds
expirations       rG   r   z2AioCachedCredentialFetcher._get_cached_credentials  s       ((**!2244444444H  ****LLEFFF')%*=4HHH
. 12>*%	
 
 	
rI   N)r   r   r   r   r  r   r   rI   rG   r   r     sA        8 8 84 4 4
 
 
 
 
rI   r   c                       e Zd ZdS )"AioBaseAssumeRoleCredentialFetcherN)r   r   r   r   rI   rG   r	  r	    s         	DrI   r	  c                       e Zd Zd Zd ZdS )AioAssumeRoleCredentialFetcherc                    K   |                                  }|                                  d{V }|4 d{V } |j        di | d{V cddd          d{V  S # 1 d{V swxY w Y   dS )'Get credentials by calling assume role.Nr   )_assume_role_kwargs_create_clientr   )rr   r   r   r   s       rG   r   z/AioAssumeRoleCredentialFetcher._get_credentials  s"     ))++**,,,,,,,, 	3 	3 	3 	3 	3 	3 	3S(22622222222	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3s   A
A),A)c                    K   | j                                          d{V }|                     d|j        |j        |j                  S )z2Create an STS client using the source credentials.Nr   )aws_access_key_idaws_secret_access_keyaws_session_token)_source_credentialsr   _client_creatorr   r   r   )rr   frozen_credentialss     rG   r  z-AioAssumeRoleCredentialFetcher._create_client  se       *AACCCCCCCC 	 ##0;"4"?06	 $ 
 
 	
rI   N)r   r   r   r   r  r   rI   rG   r  r    s2        3 3 3

 

 

 

 

rI   r  c                   2     e Zd Z	 	 	 d fd	Zd Zd Z xZS )-AioAssumeRoleWithWebIdentityCredentialFetcherNc                 b    || _         t                                          |||||           d S )N)
extra_argsrA   expiry_window_seconds)_web_identity_token_loaderr   r   )rr   rK   web_identity_token_loaderrole_arnr  rA   r  r   s          rG   r   z6AioAssumeRoleWithWebIdentityCredentialFetcher.__init__  sH     +D'!"7 	 	
 	
 	
 	
 	
rI   c                   K   |                                  }t          t                    }|                     d|          4 d{V } |j        di | d{V cddd          d{V  S # 1 d{V swxY w Y   dS )r  )signature_versionr   r?   Nr   )r  r/   r   r  assume_role_with_web_identity)rr   r   r?   r   s       rG   r   z>AioAssumeRoleWithWebIdentityCredentialFetcher._get_credentials  sJ     ))++ X666''f'== 	H 	H 	H 	H 	H 	H 	H==GGGGGGGGGG	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	Hs   	A//
A9<A9c                 `    t          | j                  }|                                 }||d<   |S )zAGet the arguments for assume role based on current configuration.WebIdentityToken)r   _assume_kwargsr  )rr   assume_role_kwargsidentity_tokens      rG   r  zAAioAssumeRoleWithWebIdentityCredentialFetcher._assume_role_kwargs  s6    %d&9::88::1?-.!!rI   )NNN)r   r   r   r   r   r  r   r   s   @rG   r  r    si         "
 
 
 
 
 
&H H H" " " " " " "rI   r  c                   :     e Zd Zej        d fd
Zd Zd Z xZS )rt   )popenc                B     t                      j        |i |d|i d S )Nr)  )r   r   )rr   r)  r   r   r   s       rG   r   zAioProcessProvider.__init__  s0    $6&66666666rI   c                 8   K    j         d S                                 d {V }|                    d          %t                              | fd j                  S t          |d         |d         |                    d           j                  S )Nr   c                  .                                    S rD   )_retrieve_credentials_using)credential_processrr   s   rG   rH   z)AioProcessProvider.load.<locals>.<lambda>  s    889KLL rI   r   r   r   )r   r   r   r   )_credential_processr-  rT   r   create_from_metadataMETHODr   )rr   
creds_dictr.  s   ` @rG   loadzAioProcessProvider.load  s      !5%F;;<NOOOOOOOO
>>-((4,AALLLLL   !,/!,/..));	
 
 
 	
rI   c                   K   t          |          } | j        |t          j        t          j        d d {V }|                                 d {V \  }}|j        dk    r)t          | j        |                    d                    t          j
        j                            |                    d                    }|                    dd          }|dk    rt          | j        d| d	          	 |d
         |d         |                    d          |                    d          dS # t          $ r}t          | j        d|           d }~ww xY w)N)stdoutstderrr   utf-8provider	error_msgVersionz<Version key not provided>   zUnsupported version 'z8' for credential process provider, supported versions: 1r   r   r   r   r   z"Missing required key in response: )r   _popen
subprocessPIPEcommunicate
returncoder   r1  decodebotocorecompatjsonloadsrT   KeyError)	rr   r.  process_listpr5  r6  parsedversiones	            rG   r-  z.AioProcessProvider._retrieve_credentials_using  s      **<==$+*/*/
 
 
 
 
 
 
 
 
  !}}......<1*g0F0F    %++FMM',B,BCC**Y(DEEa<<*7G 7 7 7   	$]3$%67N33%zz,77	    	 	 	*BqBB   	s   98D2 2
E<EE)	r   r   r   r   create_subprocess_execr   r3  r-  r   r   s   @rG   rt   rt     sf        $+$B 7 7 7 7 7 7 7
 
 
(! ! ! ! ! ! !rI   rt   c                       e Zd Zd ZdS )rW   c                    K   | j         }|                                 d {V }|sd S t                              d|d                    t                              || j        |j                  }|S )Nz#Found credentials from IAM Role: %s	role_namer   r   )_role_fetcherretrieve_iam_role_credentialsr^   infor   r0  r1  )rr   fetcherr   r  s       rG   r3  z AioInstanceMetadataProvider.load!  s      $ >>@@@@@@@@ 	418K3H	
 	
 	
 *>>;!? ? 
 

 rI   Nr   r   r   r3  r   rI   rG   rW   rW      s#            rI   rW   c                       e Zd Zd ZdS )rU   c                   K   | j                             | j        d         d          }|rt                              d           |                                 } |d          }|d         }|;t          |          }t          |d         |d         |d         ||| j        	          S t          |d         |d         |d         | j        
          S d S )Nr    z+Found credentials in environment variables.F)require_expiryr   r   r   )r   r   r   )
environrT   _mappingr^   rT  _create_credentials_fetcherr+   r   r1  r   )rr   r   rU  r   r   s        rG   r3  zAioEnvProvider.load3  s      \%%dmL&A2FF
 	KKEFFF6688G!'777K%m4K&#K000--(");    "L)L)G${	    4rI   NrV  r   rI   rG   rU   rU   2  s#            rI   rU   c                       e Zd Zd ZdS )r[   c                 F  K   d| j         v rt          j                            | j         d                   }|                     |          }| j        |v rKt                              d           || j                 }|| j                 }t          ||| j
                  S d S d S )NAWS_CREDENTIAL_FILEz)Found credentials in AWS_CREDENTIAL_FILE.r[  )_environospath
expanduser_parser
ACCESS_KEYr^   rT  
SECRET_KEYr   r1  )rr   	full_pathr  r   r   s        rG   r3  zAioOriginalEC2Provider.loadR  s       DM11**34 I LL++E%''GHHH"4?3
"4?3
%
4;    (' 4rI   NrV  r   rI   rG   r[   r[   Q  s#            rI   r[   c                       e Zd Zd ZdS )rz   c                   K   	 |                      | j                  }n# t          $ r Y d S w xY w| j        |v r|| j                 }| j        |v rst
                              d| j                   |                     || j        | j                  \  }}| 	                    |          }t          |||| j                  S d S d S )Nz0Found credentials in shared credentials file: %sr[  )_ini_parser_creds_filenamer   _profile_namerg  r^   rT  _extract_creds_from_mappingrh  _get_session_tokenr   r1  )rr   available_credsr?   r   r   r   s         rG   r3  z AioSharedCredentialProvider.loade  s      	"..t/CDDOO 	 	 	44	00$T%78F&((F(   *.)I)IDOT_* *&
J //77%
E$+    10((    
--NrV  r   rI   rG   rz   rz   d  s#            rI   rz   c                       e Zd Zd ZdS )r   c                   K   	 |                      | j                  }n# t          $ r Y d S w xY w| j        |d         v r|d         | j                 }| j        |v rqt
                              d| j                   |                     || j        | j                  \  }}| 	                    |          }t          |||| j                  S d S d S )Nprofilesz$Credentials found in config file: %sr[  )_config_parser_config_filenamer   rn  rg  r^   rT  ro  rh  rp  r   r1  )rr   rE   profile_configr   r   r   s         rG   r3  zAioConfigProvider.load{  s     	--d.CDDKK 	 	 	44	Z!888(4T5GHN.00:)   *.)I)I"DOT_* *&
J //??%
E$+    10 4rr  NrV  r   rI   rG   r   r   z  s#            rI   r   c                       e Zd Zd ZdS )r\   c                   K   | j         | j        v r| j        | j                  g}n| j        }|D ]}	 |                     |          }n# t          $ r Y %w xY wd|v ri|d         }| j        |v rXt                              d|           |                     || j        | j	                  \  }}t          ||| j                  c S d S )Nr   z)Found credentials in boto config file: %sr[  )BOTO_CONFIG_ENVrb  DEFAULT_CONFIG_FILENAMESrl  r   rg  r^   rT  ro  rh  r   r1  )rr   potential_locationsfilenamer?   r   r   r   s          rG   r3  zAioBotoProvider.load  s     4=00#'=1E#F"G"&"?+ 	 	H))(33!    &&$]3?k11KKCX   .2-M-M#T_do. .*J
 *"Jt{     	 	s   A
AANrV  r   rI   rG   r\   r\     s#            rI   r\   c                   2    e Zd Zd Zd Zd Zd Zd Zd ZdS )rY   c                   K   |                                  | _        | j                            di           }|                    | j        i           }|                     |          r |                     | j                   d {V S d S )Nru  )_load_config_loaded_configrT   rn  _has_assume_role_config_vars_load_creds_via_assume_role)rr   ru  r4   s      rG   r3  zAioAssumeRoleProvider.load  s      "//11&**:r::,,t1266,,W55 	N99$:LMMMMMMMMM	N 	NrI   c                   K   |                      |          }|                     ||           d {V }i }|                    d          }|||d<   |                    d          }|||d<   |                    d          }|||d<   |                    d          }|||d<   t          | j        ||d	         || j        | j        
          }	|	j        }
|t          |
          }
t          | j
        |
t                    S )Nrole_session_nameRoleSessionNameexternal_id
ExternalId
mfa_serialSerialNumberduration_secondsDurationSecondsr  )rK   source_credentialsr  r  mfa_prompterrA   )r   r   r   )_get_role_config_resolve_source_credentialsrT   r  r  	_prompterrA   r  r   r   r1  r(   )rr   rL   role_configr  r  r  r  r  r  rU  	refreshers              rG   r  z1AioAssumeRoleProvider._load_creds_via_assume_role  sV     ++L99#'#C#C$
 $
 
 
 
 
 
 
 
'OO,?@@(,=J()!oom44"'2J|$ __\22
!)3J~&&??+=>>',<J()0/1 ,!*
 
 
 -	!3I>>I
 1;##
 
 
 	
rI   c                    K   |                     d          }||                     ||           d {V S |d         }| j                            |           |                     |           d {V S )Ncredential_sourcesource_profile)rT    _resolve_credentials_from_source_visited_profilesappend!_resolve_credentials_from_profile)rr   r  rL   r  r  s        rG   r  z1AioAssumeRoleProvider._resolve_source_credentials  s      'OO,?@@(>>!<         %%56%%n555;;NKKKKKKKKKrI   c                   K   | j                             di           }||         }|                     |          r| j        s|                     |          S |                     |          s|                     |          s^| j                            |d          }t          |          }|                                 d {V }|d}t          ||z            |S | 
                    |           d {V S )Nru  TrO   z.The source profile "%s" must have credentials.r:  )r  rT   _has_static_credentials_profile_provider_builder(_resolve_static_credentials_from_profiler  rQ   r`   r   r   r  )rr   rL   ru  r4   rh   profile_chainr   error_messages           rG   r  z7AioAssumeRoleProvider._resolve_credentials_from_profile  sI     &**:r::<( ((11	2	 @@III))
 
 	227;;	 !% > H H)!% !I ! ! 22CDDM - > > @ @@@@@@@K"D  )+l:    55lCCCCCCCCCrI   c                     	 t          |d         |d         |                    d                    S # t          $ r(}t          | j        t          |                    d }~ww xY w)Nr  r  r  )r   r   r   )r9  cred_var)r   rT   rG  r   r1  str)rr   r4   rL  s      rG   r  z>AioAssumeRoleProvider._resolve_static_credentials_from_profile  s    		!"#67"#:;kk"566   
  	 	 	)s1vv   	s   03 
A%#A  A%c                 v   K   | j                             |           d {V }|t          |d|z            |S )NzBNo credentials found in credential_source referenced in profile %sr8  )_credential_sourcerr  r   )rr   r  rL   r   s       rG   r  z6AioAssumeRoleProvider._resolve_credentials_from_source  sx       !4GG
 
 
 
 
 
 
 
 **$&23    rI   N)	r   r   r   r3  r  r  r  r  r  r   rI   rG   rY   rY     sx        N N N*
 *
 *
X	L 	L 	LD D D:
 
 
    rI   rY   c                       e Zd Zd Zd ZdS )r   c                 :   K   |                                   d {V S rD   )_assume_role_with_web_identityrq   s    rG   r3  z)AioAssumeRoleWithWebIdentityProvider.load&  s*      88:::::::::rI   c                 b  K   |                      d          }|sd S |                     |          }|                      d          }|sd}t          |          i }|                      d          }|||d<   t          | j        |||| j                  }t          | j        |j                  S )	Nweb_identity_token_filer  zThe provided profile or the current environment is configured to assume role with web identity but has no role ARN configured. Ensure that the profile has the role_arnconfiguration set or the AWS_ROLE_ARN env var is set.r  r  r  )rK   r  r  r  rA   rQ  )	_get_config_token_loader_clsr   r  r  rA   r   r1  r  )rr   
token_pathtoken_loaderr  r:  r  r  rU  s           rG   r  zCAioAssumeRoleWithWebIdentityProvider._assume_role_with_web_identity)  s      %%&?@@
 	4--j99##J// 	:H  %y9999
 ,,-@AA(,=J()?/&2!*
 
 
 1;!3
 
 
 	
rI   N)r   r   r   r3  r  r   rI   rG   r   r   %  s2        ; ; ;"
 "
 "
 "
 "
rI   r   c                       e Zd Zd Zd ZdS )rZ   c                    K   |                      |          }t          |t                    r|                                 d{V S |                                 d{V S )a  Loads source credentials based on the provided configuration.

        :type source_name: str
        :param source_name: The value of credential_source in the config
            file. This is the canonical name of the credential provider.

        :rtype: Credentials
        N)_get_provider
isinstancer`   r   r3  )rr   source_namesources      rG   r  z4AioCanonicalNameCredentialSourcer.source_credentialsO  sr       ##K00f344 	300222222222[[]]"""""""rI   c                     |                      |          }|                                dv r,|                     d          }|||S t          ||g          S |t	          |          |S )a#  Return a credential provider by its canonical name.

        :type canonical_name: str
        :param canonical_name: The canonical name of the provider.

        :raises UnknownCredentialError: Raised if no
            credential provider by the provided name
            is found.
        )sharedconfigsharedcredentialszassume-roleN)name)_get_provider_by_canonical_namelower_get_provider_by_methodr`   r&   )rr   canonical_namer9  rf   s       rG   r  z/AioCanonicalNameCredentialSourcer._get_provider]  s     77GG !!%JJJ#'#?#?#N#N #/
 #//
 -.BH-MNNN(n====rI   N)r   r   r   r  r  r   rI   rG   rZ   rZ   N  s2        # # #$ $ $ $ $rI   rZ   c                   0     e Zd Z fdZd Zd Zd Z xZS )rV   c                      t                      j        |i | t          | j        t                    rt                      | _        d S d S rD   )r   r   r  _fetcherr   r1   r   s      rG   r   zAioContainerProvider.__init__  sQ    $)&))) dm%=>> 	:799DMMM	: 	:rI   c                 v   K   | j         | j        v s| j        | j        v r|                                  d {V S d S rD   )ENV_VARrb  ENV_VAR_FULL_retrieve_or_failrq   s    rG   r3  zAioContainerProvider.load  sQ      <4=((D,=,N,N//111111111 -O,NrI   c           
      p  K   |                                  r+| j                            | j        | j                           }n| j        | j                 }|                     |          } |             d {V }t          |d         |d         |d         | j        t          |d                   |          S )Nr   r   r   r   )r   r   r   r   r   r   )
_provided_relative_urir  full_urlrb  r  r  _create_fetcherr   r1  r)   )rr   full_urirU  r  s       rG   r  z&AioContainerProvider._retrieve_or_fail  s      &&(( 	8}--dmDL.IJJHH}T%67H&&x00gii(\*\*.;(})=>>!
 
 
 	
rI   c                       fd}|S )Nc                  Z  K   	                                  } j                            |            d {V }nR# t          $ rE}t                              d|d           t          j        t          |                    d }~ww xY w|d         |d         |d         |d	         d
S )N)headersz'Error retrieving container metadata: %sTr   r8  r   r   Tokenr   r   )	_build_headersr  retrieve_full_urir   r^   r_   r   r1  r  )r  r   rL  r  rr   s      rG   fetch_credsz9AioContainerProvider._create_fetcher.<locals>.fetch_creds  s      --//!%!@!@g "A " "       *   =q4     /![CFF   	 '}5&'89!'*'5	  s   6< 
BA BBr   )rr   r  r   r   r  s   ``   rG   r  z$AioContainerProvider._create_fetcher  s*    	 	 	 	 	 	( rI   )r   r   r   r   r3  r  r  r   r   s   @rG   rV   rV     se        : : : : :2 2 2
 
 
       rI   rV   c                       e Zd Zd ZdS )r`   c                    K   | j         D ]B}t                              d|j                   |                                 d{V }||c S CdS )zw
        Goes through the credentials chain, returning the first ``Credentials``
        that could be loaded.
        zLooking for credentials via: %sN)rQ   r^   r_   r1  r3  )rr   r9  r  s      rG   r   z&AioCredentialResolver.load_credentials  sj        	 	HLL:HOLLL"--//))))))E  ! trI   N)r   r   r   r   r   rI   rG   r`   r`     s#            rI   r`   c                   @     e Zd ZdZ	 	 	 	 	 d fd	Zd Zd Zd Z xZS )AioSSOCredentialFetcherz%Y-%m-%dT%H:%M:%SZNc                     || _         || _        || _        || _        || _        || _        |	| _        |
| _        t                      	                    ||           d S rD   )
r  _sso_region
_role_name_account_id
_start_url_token_loader_token_provider_sso_session_namer   r   )rr   	start_url
sso_regionrP  
account_idrK   r  rA   r  r   sso_session_namer   s              rG   r   z AioSSOCredentialFetcher.__init__  sd      .%#%#)-!1 566666rI   c                    | j         | j        d}| j        r| j        |d<   n
| j        |d<   t	          j        |dd          }t          |                    d                                                    }| 	                    |          S )N)roleName	accountIdsessionNamestartUrlT),:)	sort_keys
separatorsr7  )
r  r  r  r  rE  dumpsr   encode	hexdigest_make_file_safe)rr   r   argument_hashs      rG   _create_cache_keyz)AioSSOCredentialFetcher._create_cache_key  s    )
 
 ! 	/"&"8D#Dz$$:FFFT[[1122<<>>##M222rI   c                     |dz  }t           j                             |t                                }|                    | j                  S )Ng     @@)datetimefromtimestampr-   strftime_UTC_DATE_FORMAT)rr   timestamp_mstimestamp_seconds	timestamps       rG   _parse_timestampz(AioSSOCredentialFetcher._parse_timestamp  sA    (61%334EuwwOO	!!$"7888rI   c           	        K   t          t          | j                  }|                     d|          4 d{V }| j        r9| j                                        }|                                 d{V j        }n |                     | j	                  d         }| j
        | j        |d}	  |j        di | d{V }n!# |j        j        $ r t                      w xY w|d         }d|d         |d	         |d
         |                     |d                   dd}|cddd          d{V  S # 1 d{V swxY w Y   dS )z4Get credentials by calling SSO get role credentials.)r   rB   ssor!  NaccessToken)r  r  r  roleCredentialsaccessKeyIdsecretAccessKeysessionTokenr  )r   r   r   r   )ProviderTyper   r   )r   r   r  r  r  
load_tokenget_frozen_tokenr   r  r  r  r  get_role_credentials
exceptionsUnauthorizedExceptionr%   r  )rr   r?   r   initial_token_datar   r   r   r   s           rG   r   z(AioSSOCredentialFetcher._get_credentials  s5     &(
 
 
 ''f'== 	 	 	 	 	 	 	# K%)%9%D%D%F%F"1BBDDDDDDDDK**4?;;MJ !O!-$ F
2!<!<!F!Fv!F!FFFFFFF$: 2 2 2/1112"#45K !&#.}#='23D'E$/$?"&"7"7#L1# #	   
 
K ;	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s+   A1D3-C D3CAD33
D= D=)NNNNN)	r   r   r   r  r   r  r  r   r   r   s   @rG   r  r    s        + "7 7 7 7 7 7.3 3 39 9 9# # # # # # #rI   r  c                       e Zd Zd ZdS )r   c                 4  K   |                                  }|sd S |d         |d         |d         |d         | j        t          | j                  | j        d}d|v r|d         |d<   | j        |d	<   t          di |}t          | j        |j	        
          S )Nsso_start_urlr  sso_role_namesso_account_id)rA   )r  r  rP  r  rK   r  rA   sso_sessionr  r   rQ  r   )
_load_sso_configr  r$   _token_cacherA   r  r  r   r1  r  )rr   
sso_configfetcher_kwargssso_fetchers       rG   r3  zAioSSOProvider.load#  s      **,,
 	4 $O4$\2#O4$%56"2*1BCCCZ
 
 J&&1;M1JN-./3/CN+,-????0;%7
 
 
 	
rI   NrV  r   rI   rG   r   r   "  s#        
 
 
 
 
rI   r   )NN)_r   r  rE  loggingrc  r>  copyr   hashlibr   botocore.compatrC  r   r   botocore.configr   botocore.credentialsr   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   dateutil.tzr-   aiobotocore._helpersr.   aiobotocore.configr/   aiobotocore.tokensr0   aiobotocore.utilsr1   r2   	getLoggerr   r^   rk   rX   r   r   r   create_aio_mfa_serial_refresherr   r   r   r   r	  r  r  rt   rW   rU   r[   rz   r   r\   rY   r   rZ   rV   r`   r  r   r   rI   rG   <module>r      s       				                           . . . . . . " " " " " "& & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & &N       2 2 2 2 2 2 ( ( ( ( ( ( 2 2 2 2 2 2       
 
	8	$	$[ [ [ [|,
 ,
 ,
 ,
 ,
 6 ,
 ,
 ,
^- - -
  "+ + +& #> 
 
 
 
 
[ 
 
 
j( j( j( j( j( 6 j( j( j(Z2 2 2 2 2(A 2 2 2$
 
 
 
 
!8 
 
 
<	 	 	 	 	#%?	 	 	
 
 
 
 
!C
 
 
.%" %" %" %" %"&%" %" %"P9 9 9 9 9 9 9 9x    ":   $    [   >    0   &    ":   ,       0    l   4v v v v v. v v vr&
 &
 &
 &
 &
+L &
 &
 &
R3 3 3 3 3(F 3 3 3l1 1 1 1 1, 1 1 1h    .   ,Q Q Q Q Q8 Q Q Qh
 
 
 
 
[ 
 
 
 
 
rI   