Skip to content

Commit 7e52def

Browse files
author
Roland Hedberg
committed
Seprated signature verification of response and assertions. Can not be done at the same time.
1 parent 54cc04b commit 7e52def

File tree

1 file changed

+28
-19
lines changed

1 file changed

+28
-19
lines changed

src/saml2/sigver.py

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,6 +1369,15 @@ def _check_signature(self, decoded_xml, item, node_name=NODE_NAME,
13691369

13701370
def check_signature(self, item, node_name=NODE_NAME, origdoc=None,
13711371
id_attr="", must=False):
1372+
"""
1373+
1374+
:param item: Parsed entity
1375+
:param node_name:
1376+
:param origdoc: The original XML string
1377+
:param id_attr:
1378+
:param must:
1379+
:return:
1380+
"""
13721381
return self._check_signature(origdoc, item, node_name, origdoc,
13731382
id_attr=id_attr, must=must)
13741383

@@ -1521,6 +1530,8 @@ def correctly_signed_response(self, decoded_xml, must=False, origdoc=None,
15211530
:param decoded_xml: The SAML message as a XML string
15221531
:param must: Whether there must be a signature
15231532
:param origdoc:
1533+
:param only_valid_cert:
1534+
:param require_response_signature:
15241535
:return: None if the signature can not be verified otherwise an instance
15251536
"""
15261537

@@ -1534,25 +1545,23 @@ def correctly_signed_response(self, decoded_xml, must=False, origdoc=None,
15341545
elif require_response_signature:
15351546
raise SignatureError("Signature missing for response")
15361547

1537-
if isinstance(response, Response) and (response.assertion or
1538-
response.encrypted_assertion):
1539-
# Try to find the signing cert in the assertion
1540-
for assertion in (
1541-
response.assertion or response.encrypted_assertion):
1542-
if not hasattr(assertion, 'signature') or not assertion.signature:
1543-
logger.debug("unsigned")
1544-
if must:
1545-
raise SignatureError("Signature missing for assertion")
1546-
continue
1547-
else:
1548-
logger.debug("signed")
1549-
1550-
try:
1551-
self._check_signature(decoded_xml, assertion,
1552-
class_name(assertion), origdoc)
1553-
except Exception, exc:
1554-
logger.error("correctly_signed_response: %s" % exc)
1555-
raise
1548+
# if isinstance(response, Response) and response.assertion:
1549+
# # Try to find the signing cert in the assertion
1550+
# for assertion in response.assertion:
1551+
# if not hasattr(assertion, 'signature') or not assertion.signature:
1552+
# logger.debug("unsigned")
1553+
# if must:
1554+
# raise SignatureError("Signature missing for assertion")
1555+
# continue
1556+
# else:
1557+
# logger.debug("signed")
1558+
#
1559+
# try:
1560+
# self._check_signature(decoded_xml, assertion,
1561+
# class_name(assertion), origdoc)
1562+
# except Exception, exc:
1563+
# logger.error("correctly_signed_response: %s" % exc)
1564+
# raise
15561565

15571566
return response
15581567

0 commit comments

Comments
 (0)