o .&a?@sddlZddlZddlZddlZddlZddlZddlmZddlm Z ddl m Z ddl m Z ddlmZedZdd Zd d ZGd d d e ZGddde ZGddde ZGddde ZdS)N) SigV4Auth) AWSRequest)urlsplit) BasicCommand)NonTranslatedStdoutzbotocore.credentialscCs|dtdS)z3 The entry point for the credential helper z!building-command-table.codecommitN)registerinject_commands)clir B/usr/lib/python3/dist-packages/awscli/customizations/codecommit.py initializer cKst||d<dS)z> Injects new commands into the codecommit subcommand. credential-helperN)CodeCommitCommand) command_tablesessionkwargsr r r r%r rc@(eZdZdZdZdZdZdZddZdS) CodeCommitNoOpStoreCommandstorezAThis operation does nothing, credentials are calculated each timez&aws codecommit credential-helper storeTcCdSNrr selfargsparsed_globalsr r r _run_main4z$CodeCommitNoOpStoreCommand._run_mainN __name__ __module__ __qualname__NAME DESCRIPTIONSYNOPSISEXAMPLES _UNDOCUMENTEDrr r r r r, rc@r) CodeCommitNoOpEraseCommanderasez;This operation does nothing, no credentials are ever storedz&aws codecommit credential-helper eraserTcCrrr rr r r r@rz$CodeCommitNoOpEraseCommand._run_mainNrr r r r r)8r(r)csneZdZdZdZdZdZdddddd gZfd d Zd d Z ddZ ddZ ddZ ddZ ddZZS)CodeCommitGetCommandgetzget a username SigV4 credential pair based on protocol, host and path provided from standard in. This is primarily called by git to generate credentials to authenticate against AWS CodeCommitz$aws codecommit credential-helper getzecho -e "protocol=https\\npath=/v1/repos/myrepo\\nhost=git-codecommit.us-east-1.amazonaws.com" | aws codecommit credential-helper getzignore-host-check store_trueFzTOptional. Generate credentials regardless of whether the domain is an Amazon domain.)nameactiondefault group_name help_textcstt||dS)N)superr+__init__)rr __class__r r r4]szCodeCommitGetCommand.__init__cCsV|}d|dvsd|dvs|jr)||}|||}|||}||dS)Nz amazon.comhostz amazonaws.comr)read_git_parametersignore_host_check extract_urlextract_region sign_requestwrite_git_parameters)rrrgit_parameterstheUrlregion signaturer r r r`s      zCodeCommitGetCommand._run_maincCs|jj}|jjdur|d|jj7}t)}|d|td||d|| td|WddS1sGwYdS)N%z username={0} z username %sz password={0} z signature %s) _sessionget_credentials access_keytokenrwriteformatloggerdebugflush)rrAusername binary_stdoutr r r r=ks  "z)CodeCommitGetCommand.write_git_parameterscCs8i}tjD]}|}|r|dd\}}|||<q|S)N=)sysstdinstripsplit)rparsedlinekeyvaluer r r r8zs z(CodeCommitGetCommand.read_git_parameterscCsd|d|d|d}|S)Nz {0}://{1}/{2}protocolr7path)rH)r parametersurlr r r r:s z CodeCommitGetCommand.extract_urlcCs>td|d}|dur|dS|jdur|jS|jdS)NzD(vpce-.+\.)?git-codecommit(-fips)?\.([^.]+)\.(vpce\.)?amazonaws\.comr7r@)rematchgroupr@rCget_config_variable)rrZrr^r r r r;s   z#CodeCommitGetCommand.extract_regionc Cs|j}t|d|}t}||_d|_tj}|d|j d<t |j}|j dd}d |j|j|} tdtd | ||| } td | || |} td | d |j d| S) N codecommitGITz %Y%m%dT%H%M%S timestamp:rz{0} {1} host:{2} host z$Calculating signature using v4 auth.zCanonicalRequest: %szStringToSign: %sz Signature: %sz{0}Z{1})rCrDrrr[methoddatetimeutcnowstrftimecontextrnetlocrSrHrYrIrJstring_to_signrA) rr@ url_to_sign credentialssignerrequestnowrShostnamecanonical_requestrkrAr r r r<s*          z!CodeCommitGetCommand.sign_request)r r!r"r#r$r%r& ARG_TABLEr4rr=r8r:r;r< __classcell__r r r5r r+Ds&    r+c@s@eZdZdZdZdZdeddeddedgZ dZ d d Z d S) rrz aws codecommit credential-helperrr,)r. command_classrr*a#Provide a SigV4 compatible user name and password for git smart HTTP These commands are consumed by git and should not used directly. Erase and Store are no-ops. Get is operation to generate credentials to authenticate AWS CodeCommit. Run "aws codecommit credential-helper help" for detailscCstd)Nziusage: aws [options] codecommit credential-helper [parameters] aws: error: too few arguments) ValueErrorrr r r rszCodeCommitCommand._run_mainN) r r!r"r#r%r&r+rr) SUBCOMMANDSr$rr r r r rs r)osr]rPlogging fileinputrf botocore.authrbotocore.awsrequestrbotocore.compatrawscli.customizations.commandsr awscli.compatr getLoggerrIr rrr)r+rr r r r s$         g