diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index c17b3107..33ecf13e 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -18,7 +18,6 @@ jobs: fail-fast: false matrix: python-version: - - "3.7" - "3.8" - "3.9" - "3.10" diff --git a/pyproject.toml b/pyproject.toml index eee84f5b..7ead2b1d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,6 @@ keywords = [ "identity", ] classifiers = [ - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", @@ -32,11 +31,11 @@ classifiers = [ "Topic :: Software Development :: Libraries :: Python Modules", ] dependencies = [ - "lxml>=4.6.5,!=4.7.0", - "xmlsec>=1.3.9", + "lxml>=6.0.0", + "xmlsec>=1.3.14", "isodate>=0.6.1", ] -requires-python = ">=3.7" +requires-python = ">=3.8" [project.urls] Homepage = "https://saml.info" @@ -119,4 +118,4 @@ ignore_errors = true [tool.coverage.html] -directory = "coverage_html_report" \ No newline at end of file +directory = "coverage_html_report" diff --git a/src/onelogin/saml2/auth.py b/src/onelogin/saml2/auth.py index a55f7f8e..7e6c1b71 100644 --- a/src/onelogin/saml2/auth.py +++ b/src/onelogin/saml2/auth.py @@ -111,13 +111,16 @@ def store_valid_response(self, response): self._last_response_in_response_to = response.get_in_response_to() self._last_assertion_not_on_or_after = response.get_assertion_not_on_or_after() - def process_response(self, request_id=None): + def process_response(self, request_id=None, raise_exceptions=False): """ Process the SAML Response sent by the IdP. :param request_id: Is an optional argument. Is the ID of the AuthNRequest sent by this SP to the IdP. :type request_id: string + :param raise_exceptions: Whether to return raise an exception during is_valid check + :type raise_exceptions: Boolean + :raises: OneLogin_Saml2_Error.SAML_RESPONSE_NOT_FOUND, when a POST with a SAMLResponse is not found """ self._errors = [] @@ -128,7 +131,7 @@ def process_response(self, request_id=None): response = self.response_class(self._settings, self._request_data["post_data"]["SAMLResponse"]) self._last_response = response.get_xml_document() - if response.is_valid(self._request_data, request_id): + if response.is_valid(self._request_data, request_id, raise_exceptions=raise_exceptions): self.store_valid_response(response) else: self._errors.append("invalid_response") @@ -138,7 +141,7 @@ def process_response(self, request_id=None): self._errors.append("invalid_binding") raise OneLogin_Saml2_Error("SAML Response not found, Only supported HTTP_POST Binding", OneLogin_Saml2_Error.SAML_RESPONSE_NOT_FOUND) - def process_slo(self, keep_local_session=False, request_id=None, delete_session_cb=None): + def process_slo(self, keep_local_session=False, request_id=None, delete_session_cb=None, raise_exceptions=False): """ Process the SAML Logout Response / Logout Request sent by the IdP. @@ -148,6 +151,9 @@ def process_slo(self, keep_local_session=False, request_id=None, delete_session_ :param request_id: The ID of the LogoutRequest sent by this SP to the IdP :type request_id: string + :param raise_exceptions: Whether to return raise an exception during is_valid check + :type raise_exceptions: Boolean + :returns: Redirection url """ self._errors = [] @@ -160,7 +166,7 @@ def process_slo(self, keep_local_session=False, request_id=None, delete_session_ if not self.validate_response_signature(get_data): self._errors.append("invalid_logout_response_signature") self._errors.append("Signature validation failed. Logout Response rejected") - elif not logout_response.is_valid(self._request_data, request_id): + elif not logout_response.is_valid(self._request_data, request_id, raise_exceptions=raise_exceptions): self._errors.append("invalid_logout_response") elif logout_response.get_status() != OneLogin_Saml2_Constants.STATUS_SUCCESS: self._errors.append("logout_not_success") @@ -175,7 +181,7 @@ def process_slo(self, keep_local_session=False, request_id=None, delete_session_ if not self.validate_request_signature(get_data): self._errors.append("invalid_logout_request_signature") self._errors.append("Signature validation failed. Logout Request rejected") - elif not logout_request.is_valid(self._request_data): + elif not logout_request.is_valid(self._request_data, raise_exceptions=raise_exceptions): self._errors.append("invalid_logout_request") else: if not keep_local_session: