@@ -111,13 +111,16 @@ def store_valid_response(self, response):
111111 self ._last_response_in_response_to = response .get_in_response_to ()
112112 self ._last_assertion_not_on_or_after = response .get_assertion_not_on_or_after ()
113113
114- def process_response (self , request_id = None ):
114+ def process_response (self , request_id = None , raise_exceptions = False ):
115115 """
116116 Process the SAML Response sent by the IdP.
117117
118118 :param request_id: Is an optional argument. Is the ID of the AuthNRequest sent by this SP to the IdP.
119119 :type request_id: string
120120
121+ :param raise_exceptions: Whether to return raise an exception during is_valid check
122+ :type raise_exceptions: Boolean
123+
121124 :raises: OneLogin_Saml2_Error.SAML_RESPONSE_NOT_FOUND, when a POST with a SAMLResponse is not found
122125 """
123126 self ._errors = []
@@ -128,7 +131,7 @@ def process_response(self, request_id=None):
128131 response = self .response_class (self ._settings , self ._request_data ['post_data' ]['SAMLResponse' ])
129132 self ._last_response = response .get_xml_document ()
130133
131- if response .is_valid (self ._request_data , request_id ):
134+ if response .is_valid (self ._request_data , request_id , raise_exceptions = raise_exceptions ):
132135 self .store_valid_response (response )
133136 else :
134137 self ._errors .append ('invalid_response' )
@@ -141,7 +144,7 @@ def process_response(self, request_id=None):
141144 OneLogin_Saml2_Error .SAML_RESPONSE_NOT_FOUND
142145 )
143146
144- def process_slo (self , keep_local_session = False , request_id = None , delete_session_cb = None ):
147+ def process_slo (self , keep_local_session = False , request_id = None , delete_session_cb = None , raise_exceptions = False ):
145148 """
146149 Process the SAML Logout Response / Logout Request sent by the IdP.
147150
@@ -151,6 +154,9 @@ def process_slo(self, keep_local_session=False, request_id=None, delete_session_
151154 :param request_id: The ID of the LogoutRequest sent by this SP to the IdP
152155 :type request_id: string
153156
157+ :param raise_exceptions: Whether to return raise an exception during is_valid check
158+ :type raise_exceptions: Boolean
159+
154160 :returns: Redirection url
155161 """
156162 self ._errors = []
@@ -163,7 +169,7 @@ def process_slo(self, keep_local_session=False, request_id=None, delete_session_
163169 if not self .validate_response_signature (get_data ):
164170 self ._errors .append ('invalid_logout_response_signature' )
165171 self ._errors .append ('Signature validation failed. Logout Response rejected' )
166- elif not logout_response .is_valid (self ._request_data , request_id ):
172+ elif not logout_response .is_valid (self ._request_data , request_id , raise_exceptions = raise_exceptions ):
167173 self ._errors .append ('invalid_logout_response' )
168174 elif logout_response .get_status () != OneLogin_Saml2_Constants .STATUS_SUCCESS :
169175 self ._errors .append ('logout_not_success' )
@@ -178,7 +184,7 @@ def process_slo(self, keep_local_session=False, request_id=None, delete_session_
178184 if not self .validate_request_signature (get_data ):
179185 self ._errors .append ("invalid_logout_request_signature" )
180186 self ._errors .append ('Signature validation failed. Logout Request rejected' )
181- elif not logout_request .is_valid (self ._request_data ):
187+ elif not logout_request .is_valid (self ._request_data , raise_exceptions = raise_exceptions ):
182188 self ._errors .append ('invalid_logout_request' )
183189 else :
184190 if not keep_local_session :
0 commit comments