(self, region, url_to_sign)
| 154 | return self._session.get_config_variable('region') |
| 155 | |
| 156 | def sign_request(self, region, url_to_sign): |
| 157 | credentials = self._session.get_credentials() |
| 158 | signer = SigV4Auth(credentials, 'codecommit', region) |
| 159 | request = AWSRequest() |
| 160 | request.url = url_to_sign |
| 161 | request.method = 'GIT' |
| 162 | now = datetime.datetime.utcnow() |
| 163 | request.context['timestamp'] = now.strftime('%Y%m%dT%H%M%S') |
| 164 | split = urlsplit(request.url) |
| 165 | # we don't want to include the port number in the signature |
| 166 | hostname = split.netloc.split(':')[0] |
| 167 | canonical_request = ( |
| 168 | f'{request.method}\n{split.path}\n\nhost:{hostname}\n\nhost\n' |
| 169 | ) |
| 170 | logger.debug("Calculating signature using v4 auth.") |
| 171 | logger.debug('CanonicalRequest:\n%s', canonical_request) |
| 172 | string_to_sign = signer.string_to_sign(request, canonical_request) |
| 173 | logger.debug('StringToSign:\n%s', string_to_sign) |
| 174 | signature = signer.signature(string_to_sign, request) |
| 175 | logger.debug('Signature:\n%s', signature) |
| 176 | return '{0}Z{1}'.format(request.context['timestamp'], signature) |
| 177 | |
| 178 | |
| 179 | class CodeCommitCommand(BasicCommand): |
no test coverage detected