Skip to content

Commit 177892d

Browse files
author
Roland Hedberg
committed
Useful when debugging 'after the fact'.
1 parent e41a593 commit 177892d

File tree

2 files changed

+14
-22
lines changed

2 files changed

+14
-22
lines changed

src/saml2/response.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ def __init__(self, sec_context, return_addrs=None, timeslack=0,
265265
self.require_response_signature = False
266266
self.not_signed = False
267267
self.asynchop = asynchop
268+
self.do_not_verify = False
268269

269270
def _clear(self):
270271
self.xmlstr = ""
@@ -316,10 +317,16 @@ def _loads(self, xmldata, decode=True, origxml=None):
316317
else:
317318
self.origxml = self.xmlstr
318319

320+
if self.do_not_verify:
321+
args = {"do_not_verify": True}
322+
else:
323+
args = {}
324+
319325
try:
320326
self.response = self.signature_check(
321327
xmldata, origdoc=origxml, must=self.require_signature,
322-
require_response_signature=self.require_response_signature)
328+
require_response_signature=self.require_response_signature,
329+
**args)
323330

324331
except TypeError:
325332
raise
@@ -759,7 +766,7 @@ def _assertion(self, assertion, verified=False):
759766
raise SignatureError("Signature missing for assertion")
760767
else:
761768
logger.debug("signed")
762-
if not verified:
769+
if not verified and self.do_not_verify is False:
763770
try:
764771
self.sec.check_signature(assertion, class_name(assertion),self.xmlstr)
765772
except Exception as exc:

src/saml2/sigver.py

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,29 +1678,14 @@ def correctly_signed_response(self, decoded_xml, must=False, origdoc=None,
16781678
raise TypeError("Not a Response")
16791679

16801680
if response.signature:
1681-
self._check_signature(decoded_xml, response, class_name(response),
1682-
origdoc)
1681+
if "do_not_verify" in kwargs:
1682+
pass
1683+
else:
1684+
self._check_signature(decoded_xml, response,
1685+
class_name(response), origdoc)
16831686
elif require_response_signature:
16841687
raise SignatureError("Signature missing for response")
16851688

1686-
# if isinstance(response, Response) and response.assertion:
1687-
# # Try to find the signing cert in the assertion
1688-
# for assertion in response.assertion:
1689-
# if not hasattr(assertion, 'signature') or not assertion.signature:
1690-
# logger.debug("unsigned")
1691-
# if must:
1692-
# raise SignatureError("Signature missing for assertion")
1693-
# continue
1694-
# else:
1695-
# logger.debug("signed")
1696-
#
1697-
# try:
1698-
# self._check_signature(decoded_xml, assertion,
1699-
# class_name(assertion), origdoc)
1700-
# except Exception as exc:
1701-
# logger.error("correctly_signed_response: %s" % exc)
1702-
# raise
1703-
17041689
return response
17051690

17061691
#--------------------------------------------------------------------------

0 commit comments

Comments
 (0)