z]c@sddlZddlZddlZddlZddlZddlZddlZddlZddlm Z ddl m Z ddl m Z ddlmZddlmZddlZddlZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z"ddl#m$Z$m%Z%ddl#m&Z&ddl#m'Z'ej(e)Z*e ddddgZ+e,dZ-de.fdYZ/dZ0dZ1dZ2e3d Z4d!Z5d"Z6d#e.fd$YZ7d%e.fd&YZ8d'e8fd(YZ9d)e9fd*YZ:d+e.fd,YZ;d-e;fd.YZ<d/e<fd0YZ=d1e<fd2YZ>d3e.fd4YZ?d5e?fd6YZ@d7e?fd8YZAd9e?fd:YZBd;e?fd<YZCd=e?fd>YZDd?e?fd@YZEdAe?fdBYZFdCe?fdDYZGdEe?fdFYZHdGe.fdHYZIdIe?fdJYZJdKe.fdLYZKdS(MiN(t namedtuple(tdeepcopy(tsha1(tparse(ttzlocal(tUNSIGNED(t total_seconds(tcompat_shell_split(tConfig(tUnknownCredentialError(tPartialCredentialsError(tConfigNotFound(tInvalidConfigError(tInfiniteLoopConfigError(tRefreshWithMFAUnsupportedError(tMetadataRetrievalError(tCredentialRetrievalError(tInstanceMetadataFetchertparse_key_val_file(tContainerMetadataFetcher(tFileWebIdentityTokenLoadertReadOnlyCredentialst access_keyt secret_keyttokencsyjdpd}jd}jd}jjddk }|dkrci}nt}t}tdtd|d|dj}t d |} t d fd d j d |d |dt |||gd| } || g} | j d |d|} tt||g} | | | }|rf|j|tjdntd|}|S(sCreate a default credential resolver. This creates a pre-configured credential resolver that includes the default lookup chain for credentials. tprofiletdefaulttmetadata_service_timeouttmetadata_service_num_attemptstiam_role_fetcherttimeoutt num_attemptst user_agenttcachet load_configcsjS(N(t full_config((tsession(s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pytPttclient_creatort profile_nametcredential_sourcertprofile_provider_buildertdisable_env_varssWSkipping environment variable credential check because profile name was explicitly set.t providersN(tget_config_variabletinstance_variablestgettNonet EnvProvidertContainerProvidertInstanceMetadataProviderRR tProfileProviderBuildertAssumeRoleProvidert create_clienttCanonicalNameCredentialSourcerR,tOriginalEC2Providert BotoProvidertremovetloggertdebugtCredentialResolver(R$R!R(tmetadata_timeoutRR+t env_providertcontainer_providertinstance_metadata_providerR*tassume_role_providert pre_profiletprofile_providerst post_profileR,tresolver((R$s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pytcreate_credential_resolver5sJ           R4cBsJeZdZddZedZdZdZdZ dZ RS(sThis class handles the creation of profile based providers. NOTE: This class is only intended for internal use. This class handles the creation and ordering of the various credential providers that primarly source their configuration from the shared config. This is needed to enable sharing between the default credential chain and the source profile chain created by the assume role provider. cCs||_||_dS(N(t_sessiont_cache(tselfR$R!((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyt__init__s cCs7|j|||j||j||j|gS(N(t_create_web_identity_providert"_create_shared_credential_providert_create_process_providert_create_config_provider(RJR(R+((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyR,s    cstd|dfdS(NR(R"cs jjS(N(RHR#((RJ(s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyR%R&(tProcessProvider(RJR(((RJs6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRNscCs%|jjd}td|d|S(Ntcredentials_fileR(tcreds_filename(RHR-tSharedCredentialProvider(RJR(tcredential_file((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRMscCs%|jjd}td|d|S(Nt config_fileR(tconfig_filename(RHR-tConfigProvider(RJR(RU((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyROsc s7tdfddjjdjd|d|S(NR"cs jjS(N(RHR#((RJ(s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyR%R&R'R!R(R+(t!AssumeRoleWithWebIdentityProviderRHR6RI(RJR(R+((RJs6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRLs   N( t__name__t __module__t__doc__R0RKtFalseR,RNRMRORL(((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyR4s     cCst|}|jS(N(RGtload_credentials(R$RF((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pytget_credentialss cCstjjtS(N(tdatetimetnowR(((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyt _local_nowscCs t|tjr|St|S(N(t isinstanceR_R(tvalue((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyt_parse_if_neededscCs3t|tjr/|r"|jS|jdS|S(Ns%Y-%m-%dT%H:%M:%S%Z(RbR_t isoformattstrftime(Rctiso((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyt_serialize_if_neededs   csfd}|S(NcsOj}|d}i|dd6|dd6|dd6t|dd 6S( Nt Credentialst AccessKeyIdRtSecretAccessKeyRt SessionTokenRt Expirationt expiry_time(t assume_roleRh(tresponset credentials(tclienttparams(s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pytrefreshs    ((RrRsRt((RrRss6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pytcreate_assume_role_refreshers cCs dtfdY}||S(Nt _RefreshercBseZdZdZRS(cSs||_t|_dS(N(t_refreshR\t_has_been_called(RJRt((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRKs cSs(|jrtnt|_|jS(N(RxRtTrueRw(RJ((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyt__call__s   (RYRZRKRz(((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRvs (tobject(tactual_refreshRv((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pytcreate_mfa_serial_refresherst JSONFileCachecBseeZdZejjejjddddZedZdZ dZ dZ d Z RS( sJSON file cache. This provides a dict like interface that stores JSON serializable objects. The objects are serialized to JSON and stored in a file. These values can be retrieved at a later time. t~s.awstbotoR!cCs ||_dS(N(t _working_dir(RJt working_dir((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRKscCs|j|}tjj|S(N(t_convert_cache_keytostpathtisfile(RJt cache_keyt actual_key((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyt __contains__scCsb|j|}y&t|}tj|SWdQXWn&tttfk r]t|nXdS(s Retrieve value from a cache key.N(RtopentjsontloadtOSErrort ValueErrortIOErrortKeyError(RJRRtf((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyt __getitem__s cCs|j|}ytj|dt}Wn'ttfk rQtd|nXtjj|j sztj |j ntj tj |tj tjBdd}|j|j|WdQXdS(NRs5Value cannot be cached, must be JSON serializable: %sitw(RRtdumpsRht TypeErrorRRRtisdirRtmakedirstfdopenRtO_WRONLYtO_CREATttruncatetwrite(RJRRctfull_keyt file_contentR((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyt __setitem__ s cCs tjj|j|d}|S(Ns.json(RRtjoinR(RJRt full_path((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRs( RYRZR[RRt expanduserRt CACHE_DIRRKRRRR(((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyR~s'   RicBs/eZdZdddZdZdZRS(s\ Holds the credentials needed to authenticate requests. :ivar access_key: The access key part of the credentials. :ivar secret_key: The secret key part of the credentials. :ivar token: The security token, valid only for session credentials. :ivar method: A string which identifies where the credentials were found. cCsG||_||_||_|dkr0d}n||_|jdS(Ntexplicit(RRRR0tmethodt _normalize(RJRRRR((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRK)s      cCs4tjj|j|_tjj|j|_dS(N(tbotocoretcompattensure_unicodeRR(RJ((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyR5scCst|j|j|jS(N(RRRR(RJ((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pytget_frozen_credentials?s N(RYRZR[R0RKRR(((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRis   tRefreshableCredentialscBseZdZdZdZedZdZedZ e dZ e j dZ e d Z e j d Z e d Zej d Zd ZddZdZdZdZedZdZdZRS(s Holds the credentials needed to authenticate requests. In addition, it knows how to refresh itself. :ivar access_key: The access key part of the credentials. :ivar secret_key: The secret key part of the credentials. :ivar token: The security token, valid only for session credentials. :ivar method: A string which identifies where the credentials were found. ii<i cCsq||_||_||_||_||_||_tj|_||_ t ||||_ |j dS(N( t_refresh_usingt _access_keyt _secret_keyt_tokent _expiry_timet _time_fetchert threadingtLockt _refresh_lockRRt_frozen_credentialsR(RJRRRRnt refresh_usingRt time_fetcher((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRKWs       cCs4tjj|j|_tjj|j|_dS(N(RRRRR(RJ((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRfsc CsJ|d|dd|dd|dd|j|dd|d|}|S(NRRRRnRR(t_expiry_datetime(tclstmetadataRRtinstance((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pytcreate_from_metadatajs    cCs|j|jS(sWarning: Using this property can lead to race conditions if you access another property subsequently along the refresh boundary. Please use get_frozen_credentials instead. (RwR(RJ((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRvs cCs ||_dS(N(R(RJRc((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRscCs|j|jS(sWarning: Using this property can lead to race conditions if you access another property subsequently along the refresh boundary. Please use get_frozen_credentials instead. (RwR(RJ((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRs cCs ||_dS(N(R(RJRc((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRscCs|j|jS(sWarning: Using this property can lead to race conditions if you access another property subsequently along the refresh boundary. Please use get_frozen_credentials instead. (RwR(RJ((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRs cCs ||_dS(N(R(RJRc((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRscCs|j|j}t|S(N(RRR(RJtdelta((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyt_seconds_remainingscCsR|jdkrtS|dkr+|j}n|j|krAtStjdtS(sCheck if a refresh is needed. A refresh is needed if the expiry time associated with the temporary credentials is less than the provided ``refresh_in``. If ``time_delta`` is not provided, ``self.advisory_refresh_needed`` will be used. For example, if your temporary credentials expire in 10 minutes and the provided ``refresh_in`` is ``15 * 60``, then this function will return ``True``. :type refresh_in: int :param refresh_in: The number of seconds before the credentials expire in which refresh attempts should be made. :return: True if refresh neeeded, False otherwise. s!Credentials need to be refreshed.N(RR0R\t_advisory_refresh_timeoutRR;R<Ry(RJt refresh_in((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pytrefresh_neededs   cCs|jddS(NRi(R(RJ((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyt _is_expiredscCs|j|jsdS|jjtr|z@|j|jsAdS|j|j}|jd|dSWd|jjXnK|j|jr|j+|j|jsdS|jdtWdQXndS(Nt is_mandatory( RRRtacquireR\t_mandatory_refresh_timeoutt_protected_refreshtreleaseRy(RJtis_mandatory_refresh((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRws   cCsy|j}WnHtk rZ}|r.dnd}tjd|dt|rVndSX|j|t|j|j|j |_ |j rd}tj|t |ndS(Nt mandatorytadvisorysARefreshing temporary credentials failed during %s refresh period.texc_infosLCredentials were refreshed, but the refreshed credentials are still expired.( Rt ExceptionR;twarningRyt_set_from_dataRRRRRRt RuntimeError(RJRRtet period_nametmsg((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRs      cCs t|S(N(R(ttime_str((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRscCsddddg}|s!|}n%g|D]}||kr(|^q(}|rzd}td|jd|dj|n|d|_|d|_|d|_t|d|_tj d |j|j dS( NRRRRns7Credential refresh failed, response did not contain: %stprovidert error_msgs, s(Retrieved credentials will expire at: %s( RRRRRRRRR;R<R(RJtdatat expected_keyst missing_keystktmessage((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyR s  %      cCs|j|jS(sReturn immutable credentials. The ``access_key``, ``secret_key``, and ``token`` properties on this class will always check and refresh credentials if needed before returning the particular credentials. This has an edge case where you can get inconsistent credentials. Imagine this: # Current creds are "t1" tmp.access_key ---> expired? no, so return t1.access_key # ---- time is now expired, creds need refreshing to "t2" ---- tmp.secret_key ---> expired? yes, refresh and return t2.secret_key This means we're using the access key from t1 with the secret key from t2. To fix this issue, you can request a frozen credential object which is guaranteed not to change. The frozen credentials returned from this method should be used immediately and then discarded. The typical usage pattern would be:: creds = RefreshableCredentials(...) some_code = SomeSignerObject() # I'm about to sign the request. # The frozen credentials are only used for the # duration of generate_presigned_url and will be # immediately thrown away. request = some_code.sign_some_request( with_credentials=creds.get_frozen_credentials()) print("Signed request:", request) (RwR(RJ((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRs" iiXN(RYRZR[RRRaRKRt classmethodRtpropertyRtsetterRRRR0RRRwRt staticmethodRRR(((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyREs(        "   ! tDeferredRefreshableCredentialscBs&eZdZedZddZRS(syRefreshable credentials that don't require initial credentials. refresh_using will be called upon first access. cCs[||_d|_d|_d|_d|_||_tj|_ ||_ d|_ dS(N( RR0RRRRRRRRRR(RJRRR((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRKJs       cCs)|jdkrtStt|j|S(N(RR0RytsuperRR(RJR((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRUsN(RYRZR[RaRKR0R(((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyREs tCachedCredentialFetchercBseeZd Zd d dZdZdZdZdZdZ dZ d Z d Z RS( i<icCsR|dkri}n||_|j|_|dkrE|j}n||_dS(N(R0RIt_create_cache_keyt _cache_keytDEFAULT_EXPIRY_WINDOW_SECONDSt_expiry_window_seconds(RJR!texpiry_window_seconds((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRK`s     cCstddS(Ns_create_cache_key()(tNotImplementedError(RJ((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRiscCs4|jddjtjjd}|jddS(Nt:t_t/(treplaceRRtsep(RJtfilename((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyt_make_file_safels$cCstddS(Ns_get_credentials()(R(RJ((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyt_get_credentialsqscCs |jS(N(t_get_cached_credentials(RJ((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pytfetch_credentialstscCs|j}|d kr4|j}|j|n tjd|d}t|ddt}i|dd6|dd6|d d 6|d 6S( sGet up-to-date credentials. This will check the cache for up-to-date credentials, calling assume role if none are available. s*Credentials for role retrieved from cache.RiRmRgRjRRkRRlRRnN(t_load_from_cacheR0Rt_write_to_cacheR;R<RhRy(RJRptcredst expiration((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRws        cCsO|j|jkrKt|j|j}|j|s;|StjdndS(Ns6Credentials were found in cache, but they are expired.(RRIRRR;R<R0(RJR((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRs cCst||j|jeZdZejdZdZdZedZ RS(scustom-processcCs(||_||_d|_||_dS(N(t _profile_namet _load_configR0t_loaded_configt_popen(RJR(R"tpopen((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRKs   c sjdkrdSj}|jddk r_tj|fdjStd|dd|dd|jddjS(NRncs jS(N(t_retrieve_credentials_using((tcredential_processRJ(s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyR%R&RRRR(t_credential_processR0R9R/RRR-Ri(RJt creds_dict((R:RJs6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRs     c CsAt|}|j|dtjdtj}|j\}}|jdkrrtd|jd|jdnt j j j |jd}|j dd}|d krtd|jdd |ny>i|d d 6|d d6|j dd6|j dd6SWn/tk r<}td|jdd|nXdS(NtstdouttstderriRRsutf-8tVersionsisOUnsupported version '%s' for credential process provider, supported versions: 1RjRRkRRlRRmRns$Missing required key in response: %s(RR7t subprocesstPIPEt communicatet returncodeRR-tdecodeRRRRR/R( RJR:t process_listtpR=R>tparsedtversionR((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyR9s2          cCsR|jdkr!|j|_n|jjdij|ji}|jdS(NtprofilesR:(R6R0R5R/R4(RJtprofile_config((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyR;s  ( RYRZR-R@tPopenRKRR9RR;(((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRPs   R3cBs&eZdZdZdZdZRS(siam-roletEc2InstanceMetadatacCs ||_dS(N(t _role_fetcher(RJR((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRKscCsX|j}|j}|sdStjd|dtj|d|jd|j}|S(Ns#Found credentials from IAM Role: %st role_nameRR(RMtretrieve_iam_role_credentialsR0R;R<RRR-(RJtfetcherRR((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRs      (RYRZR-R3RKR(((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyR3s R1cBs\eZdZdZdZdZddgZdZd d dZ dZ d Z d Z RS( tenvt EnvironmenttAWS_ACCESS_KEY_IDtAWS_SECRET_ACCESS_KEYtAWS_SECURITY_TOKENtAWS_SESSION_TOKENtAWS_CREDENTIAL_EXPIRATIONcCs7|dkrtj}n||_|j||_dS(s :param environ: The environment variables (defaults to ``os.environ`` if no value is provided). :param mapping: An optional mapping of variable names to environment variable names. Use this if you want to change the mapping of access_key->AWS_ACCESS_KEY_ID, etc. The dict can have up to 3 keys: ``access_key``, ``secret_key``, ``session_token``. N(R0Rtenviront_build_mappingt_mapping(RJRXR.((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRKs   cCsi}|dkrI|j|d<|j|d<|j|d<|j|dtdddn||d<jdd}|stdddn||deZdZdZdZdZdZdddZdZ RS(sec2-credentials-filet Ec2ConfigtAWS_CREDENTIAL_FILEtAWSAccessKeyIdt AWSSecretKeycCsC|dkrtj}n|dkr-t}n||_||_dS(N(R0RRXRt_environt_parser(RJRXtparser((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRKgs      cCsd|jkrtjj|jd}|j|}|j|krtjd||j}||j}t ||d|j SndSdS(sN Search for a credential file used by original EC2 CLI tools. Rfs)Found credentials in AWS_CREDENTIAL_FILE.RN( RiRRRRjR[R;RbR\RiR-R0(RJRRRR((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRos    N( RYRZR-R3t CRED_FILE_ENVR[R\R0RKR(((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyR8_sRScBsMeZdZdZdZdZddgZd d dZdZ dZ RS( sshared-credentials-filetSharedCredentialsRRtaws_security_tokenR cCsO||_|dkrd}n||_|dkrBtjj}n||_dS(NR(t_creds_filenameR0R4Rt configloadertraw_config_parset _ini_parser(RJRRR(t ini_parser((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRKs     cCsy|j|j}Wntk r*dSX|j|kr||j}|j|krtjd|j|j||j|j \}}|j |}t |||d|j SndS(Ns0Found credentials in shared credentials file: %sR( RrRoR R0R4R[R;RbR2R\t_get_session_tokenRiR-(RJtavailable_credsR&RRR((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRs    cCs,x%|jD]}||kr ||Sq WdS(N(R](RJR&t token_envvar((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRts N( RYRZR-R3R[R\R]R0RKRRt(((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRSs  RWcBsPeZdZdZdZdZdZddgZd dZ dZ d Z RS( s0INI based config provider with profile sections.s config-filet SharedConfigRRRnR cCs:||_||_|dkr-tjj}n||_dS(s :param config_filename: The session configuration scoped to the current profile. This is available via ``session.config``. :param profile_name: The name of the current profile. :param config_parser: A config parser callable. N(t_config_filenameR4R0RRpR"t_config_parser(RJRVR(t config_parser((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRKs   cCsy|j|j}Wntk r*dSX|j|dkr|d|j}|j|krtjd|j|j||j|j \}}|j |}t |||d|j SndSdS(sr If there is are credentials in the configuration associated with the session, use those. RIs$Credentials found in config file: %sRN( RyRxR R0R4R[R;RbR2R\RtRiR-(RJR#RJRRR((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRs    cCs,x%|jD]}||kr ||Sq WdS(N(R](RJRJt token_name((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRts N( RYRZR[R-R3R[R\R]R0RKRRt(((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRWs   R9cBsJeZdZdZdZddgZdZdZd d dZ dZ RS( s boto-configt Boto2Configt BOTO_CONFIGs /etc/boto.cfgs~/.botoRRcCsI|dkrtj}n|dkr3tjj}n||_||_dS(N(R0RRXRRpRqRiRr(RJRXRs((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRKs     cCs|j|jkr(|j|jg}n |j}x|D]}y|j|}Wntk rgq8nXd|kr8|d}|j|krtjd||j||j|j \}}t ||d|j Sq8q8WdS(s; Look for credentials in boto config file. Ris)Found credentials in boto config file: %sRN( tBOTO_CONFIG_ENVRitDEFAULT_CONFIG_FILENAMESRrR R[R;RbR2R\RiR-(RJtpotential_locationsRR&RqRR((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRs"       N( RYRZR-R3R~RR[R\R0RKR(((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyR9s R5cBseZdZdZdZdZdZejdddZ dZ dZ dZ d Z d Zd Zd Zd ZdZdZdZdZRS(s assume-roleRtweb_identity_token_filei<icCs[||_||_||_||_||_i|_||_||_|jg|_dS(s :type load_config: callable :param load_config: A function that accepts no arguments, and when called, will return the full configuration dictionary for the session (``session.full_config``). :type client_creator: callable :param client_creator: A factory function that will create a client when called. Has the same interface as ``botocore.session.Session.create_client``. :type cache: dict :param cache: An object that supports ``__getitem__``, ``__setitem__``, and ``__contains__``. An example of this is the ``JSONFileCache`` class in the CLI. :type profile_name: str :param profile_name: The name of the profile. :type prompter: callable :param prompter: A callable that returns input provided by the user (i.e raw_input, getpass.getpass, etc.). :type credential_sourcer: CanonicalNameCredentialSourcer :param credential_sourcer: A credential provider that takes a configuration, which is used to provide the source credentials for the STS call. N( R!R5RR4t _prompterR6t_credential_sourcert_profile_provider_buildert_visited_profiles(RJR"R'R!R(tprompterR)R*((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRKs$        cCs\|j|_|jjdi}|j|ji}|j|rX|j|jSdS(NRI(R5R6R/R4t_has_assume_role_config_varst_load_creds_via_assume_role(RJRIR((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRRs cCs|j|ko|j|kS(N(tROLE_CONFIG_VARtWEB_IDENTITY_TOKE_FILE_VAR(RJR((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRYsc CsA|j|}|j||}i}|jd}|dk rO||ds(R(RJRt static_keys((Rs6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRs cCsR|jd}|dk r+|j||S|d}|jj||j|S(NRR(R/R0t _resolve_credentials_from_sourceRR,t!_resolve_credentials_from_profile(RJRR(RR((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRs   cCs|jjdi}||}|j|rE|j rE|j|S|j|sd|j| r|jjd|dt}t|}|j }|dkrd}t d||n|S|j |S(NRIR(R+s.The source profile "%s" must have credentials.R( R6R/RRt(_resolve_static_credentials_from_profileRR,RyR=R]R0R R(RJR(RIRRDt profile_chainRqt error_message((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyR s$        cCsfy.td|dd|dd|jdSWn1tk ra}td|jdt|nXdS( NRRRRRR RR+(RiR/RR R-tstr(RJRR((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyR's  cCs>|jj|}|dkr:td|dd|n|S(NRRsBNo credentials found in credential_source referenced in profile %s(RRR0R(RJRR(Rq((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyR2s    Ni(RYRZR-R0R3RRtEXPIRY_WINDOW_SECONDSRRKRRRRRRRRRRRR(((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyR5 s&  5  , 2  &   RXcBsneZdZd Zidd6dd6dd6Zd ed dZdZd Z d Z d Z d Z RS(sassume-role-with-web-identitytAWS_WEB_IDENTITY_TOKEN_FILERtAWS_ROLE_SESSION_NAMERt AWS_ROLE_ARNRcCsX||_||_||_||_d|_||_|dkrKt}n||_dS(N( R!R5RR4R0t_profile_configt_disable_env_varsRt_token_loader_cls(RJR"R'R(R!R+ttoken_loader_cls((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRKJs        cCs |jS(N(t_assume_role_with_web_identity(RJ((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyR]scCsX|jdkrH|j}|jdi}|j|ji|_n|jj|S(NRI(RR0R5R/R4(RJtkeyt loaded_configRI((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyt_get_profile_config`s  cCsC|jr dS|jj|}|r?|tjkr?tj|SdS(N(RR0t_CONFIG_TO_ENV_VARR/RRX(RJRtenv_key((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyt_get_env_configgs   cCs,|j|}|dk r|S|j|S(N(RR0R(RJRt env_value((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyt _get_configos c Cs|jd}|sdS|j|}|jd}|sUd}td|ni}|jd}|dk r||deZdZdZdZdZdZdZRS(cCs ||_dS(N(t _providers(RJR,((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRKscCs#|g|jD]}|j^q kS(sLValidates a given source name. :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: bool :returns: True if the credential provider is supported, False otherwise. (RR3(RJt source_nameRF((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRs cCs2|j|}t|tr(|jS|jS(sLoads 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 (t _get_providerRbR=R]R(RJRtsource((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRs  cCs|j|}|jdkr_|jd}|dk r_|dkrL|St||gSn|dkr}td|n|S(s#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. t sharedconfigtsharedcredentialss assume-roletname(RRN(t_get_provider_by_canonical_nametlowert_get_provider_by_methodR0R=R (RJtcanonical_nameRRB((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRs    cCsCx<|jD]1}|j}|r |j|jkr |Sq WdS(sReturn a credential provider by its canonical name. This function is strict, it does not attempt to address compatibility issues. N(RR3R(RJRRR((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRs cCs+x$|jD]}|j|kr |Sq WdS(s0Return a credential provider by its METHOD name.N(RR-(RJRR((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRs(RYRZRKRRRRR(((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyR7s    & R2cBsbeZdZdZdZdZdZd d dZdZ dZ dZ d Z d Z RS( scontainer-rolet EcsContainert&AWS_CONTAINER_CREDENTIALS_RELATIVE_URIt"AWS_CONTAINER_CREDENTIALS_FULL_URIt!AWS_CONTAINER_AUTHORIZATION_TOKENcCsF|dkrtj}n|dkr0t}n||_||_dS(N(R0RRXRRit_fetcher(RJRXRP((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRKs      cCs2|j|jks$|j|jkr.|jSdS(N(tENV_VARRit ENV_VAR_FULLt_retrieve_or_fail(RJ((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRs$c Cs|jr+|jj|j|j}n|j|j}|j}|j||}|}td|dd|dd|dd|j dt |dd|S(NRRRRRnR( t_provided_relative_uriRtfull_urlRiRRt_build_headerst_create_fetcherRR-Rd(RJtfull_uritheadersRPR((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRs       cCs6i}|jj|j}|dk r2i|d6SdS(Nt Authorization(RiR/tENV_VAR_AUTH_TOKENR0(RJRt auth_token((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRs  csfd}|S(Ncsyjjd}WnGtk re}tjd|dttdjdt|nXi|dd6|dd 6|d d 6|d d 6S(NRs'Error retrieving container metadata: %sRRRRjRRkRtTokenRRmRn( Rtretrieve_full_uriRR;R<RyRR-R(RpR(RRRJ(s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyt fetch_creds!s    ((RJRRR((RRRJs6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyR scCs|j|jkS(N(RRi(RJ((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyR3sN(RYRZR-R3RRRR0RKRRRRR(((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyR2s    R=cBsGeZdZdZdZdZdZdZdZRS(cCs ||_dS(sQ :param providers: A list of ``CredentialProvider`` instances. N(R,(RJR,((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRK8scCsfy,g|jD]}|j^q j|}Wn tk rNtd|nX|jj||dS(s= Inserts a new instance of ``CredentialProvider`` into the chain that will be tried before an existing one. :param name: The short name of the credentials you'd like to insert the new credentials before. (ex. ``env`` or ``config``). Existing names & ordering can be discovered via ``self.available_methods``. :type name: string :param cred_instance: An instance of the new ``Credentials`` object you'd like to add to the chain. :type cred_instance: A subclass of ``Credentials`` RN(R,R-tindexRR tinsert(RJRtcredential_providerRFtoffset((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyt insert_before@s , cCs*|j|}|jj|d|dS(s9 Inserts a new type of ``Credentials`` instance into the chain that will be tried after an existing one. :param name: The short name of the credentials you'd like to insert the new credentials after. (ex. ``env`` or ``config``). Existing names & ordering can be discovered via ``self.available_methods``. :type name: string :param cred_instance: An instance of the new ``Credentials`` object you'd like to add to the chain. :type cred_instance: A subclass of ``Credentials`` iN(t_get_provider_offsetR,R(RJRRR((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyt insert_afterTscCsRg|jD]}|j^q }||kr/dS|j|}|jj|dS(s Removes a given ``Credentials`` instance from the chain. :param name: The short name of the credentials instance to remove. :type name: string N(R,R-Rtpop(RJRRFtavailable_methodsR((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyR:es  cCs|j|j|S(sReturn a credential provider by name. :type name: str :param name: The name of the provider. :raises UnknownCredentialError: Raised if no credential provider by the provided name is found. (R,R(RJR((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyt get_providerts cCsQy*g|jD]}|j^q j|SWn tk rLtd|nXdS(NR(R,R-RRR (RJRRF((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyRs* cCsGx@|jD]5}tjd|j|j}|dk r |Sq WdS(sw Goes through the credentials chain, returning the first ``Credentials`` that could be loaded. sLooking for credentials via: %sN(R,R;R<R-RR0(RJRR((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyR]s   ( RYRZRKRRR:RRR](((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyR=7s     (LRR_tloggingRRRRR@t collectionsRtcopyRthashlibRtdateutil.parserRt dateutil.tzRtbotocore.configloaderRtbotocore.compatRRRtbotocore.configRtbotocore.exceptionsR R R R R RRRtbotocore.utilsRRRRt getLoggerRYR;RR0RGR{R4R^RaRdR\RhRuR}R~RiRRRRR R"R*RPR3R1R8RSRWR9R5RXR7R2R=(((s6/tmp/pip-build-kBFYxq/botocore/botocore/credentials.pyts           M6      -'E1P8-Ft"*7*6YXE