@@ -101,14 +101,13 @@ def is_valid(self, request_data, request_id=None, raise_exceptions=False):
101101
102102 security = self .__settings .get_security_data ()
103103
104+ in_response_to = self .get_in_response_to ()
104105 # Check if the InResponseTo of the Logout Response matches the ID of the Logout Request (requestId) if provided
105- if request_id is not None and self .document .documentElement .hasAttribute ('InResponseTo' ):
106- in_response_to = self .document .documentElement .getAttribute ('InResponseTo' )
107- if request_id != in_response_to :
108- raise OneLogin_Saml2_ValidationError (
109- 'The InResponseTo of the Logout Response: %s, does not match the ID of the Logout request sent by the SP: %s' % (in_response_to , request_id ),
110- OneLogin_Saml2_ValidationError .WRONG_INRESPONSETO
111- )
106+ if request_id is not None and in_response_to and in_response_to != request_id :
107+ raise OneLogin_Saml2_ValidationError (
108+ 'The InResponseTo of the Logout Response: %s, does not match the ID of the Logout request sent by the SP: %s' % (in_response_to , request_id ),
109+ OneLogin_Saml2_ValidationError .WRONG_INRESPONSETO
110+ )
112111
113112 # Check issuer
114113 issuer = self .get_issuer ()
@@ -237,6 +236,14 @@ def build(self, in_response_to):
237236
238237 self .__logout_response = logout_response
239238
239+ def get_in_response_to (self ):
240+ """
241+ Gets the ID of the LogoutRequest which this response is in response to
242+ :returns: ID of LogoutRequest this LogoutResponse is in response to or None if it is not present
243+ :rtype: str
244+ """
245+ return self .document .documentElement .getAttribute ('InResponseTo' )
246+
240247 def get_response (self , deflate = True ):
241248 """
242249 Returns the Logout Response defated, base64encoded
0 commit comments