def _retrieve_login_form_from_endpoint(self, endpoint): response = self._requests_session.get(endpoint, verify=True) self._assert_non_error_response(response) login_form_html_node = self._parse_form_from_html(response.text) if login_form_html_node is None: raise SAMLError(self._ERROR_NO_FORM % endpoint) form_action = urljoin(endpoint, login_form_html_node.attrib.get('action', '')) if not form_action.lower().startswith('https://'): raise SAMLError('Your SAML IdP must use HTTPS connection') payload = dict((tag.attrib['name'], tag.attrib.get('value', '')) for tag in login_form_html_node.findall(".//input")) return form_action, payload
def _create_request_object(self, operation, params): user_agent = self.session.user_agent() params["headers"]["User-Agent"] = user_agent uri = self.build_uri(operation, params) uri = urljoin(self.host, uri) payload = None if params["payload"]: payload = params["payload"].getvalue() if payload is None: request = AWSRequest(method=operation.http["method"], url=uri, headers=params["headers"]) else: request = AWSRequest(method=operation.http["method"], url=uri, headers=params["headers"], data=payload) return request
def _create_request_object(self, request_dict): r = request_dict user_agent = self._user_agent headers = r['headers'] headers['User-Agent'] = user_agent url = urljoin(self.host, r['url_path']) if r['query_string']: encoded_query_string = percent_encode_sequence(r['query_string']) if '?' not in url: url += '?%s' % encoded_query_string else: url += '&%s' % encoded_query_string request = AWSRequest(method=r['method'], url=url, data=r['body'], headers=headers) return request
def _create_request_object(self, operation, params): user_agent = self.session.user_agent() params['headers']['User-Agent'] = user_agent uri = self.build_uri(operation, params) uri = urljoin(self.host, uri) payload = None if params['payload']: payload = params['payload'].getvalue() if payload is None: request = AWSRequest(method=operation.http['method'], url=uri, headers=params['headers']) else: request = AWSRequest(method=operation.http['method'], url=uri, headers=params['headers'], data=payload) return request