def _parse_authorization(self): if 'AWSAccessKeyId' in self.params: try: self.headers['Date'] = self.params['Expires'] self.headers['Authorization'] = \ 'AWS %(AWSAccessKeyId)s:%(Signature)s' % self.params except KeyError: raise AccessDenied() if 'Authorization' not in self.headers: raise NotS3Request() try: keyword, info = self.headers['Authorization'].split(' ', 1) except Exception: raise AccessDenied() if keyword != 'AWS': raise NotS3Request() try: access_key, signature = info.rsplit(':', 1) except Exception: err_msg = 'AWS authorization header is invalid. ' \ 'Expected AwsAccessKeyId:signature' raise InvalidArgument('Authorization', self.headers['Authorization'], err_msg) return access_key, signature
def _parse_auth_info(self): """Extract the access key identifier and signature. :returns: a tuple of access_key and signature :raises: NotS3Request """ if self._is_query_auth: return self._parse_query_authentication() elif self._is_header_auth: return self._parse_header_authentication() else: # if this request is neither query auth nor header auth # swift3 regard this as not s3 request raise NotS3Request()