Skip to content

Commit 948b752

Browse files
author
Roland Hedberg
committed
Added new method: 'verify_attesting_entity'
1 parent dcf5b53 commit 948b752

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/saml2/response.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,7 @@ def _bearer_confirmed(self, data):
596596
if data.address:
597597
if not valid_address(data.address):
598598
return False
599+
# verify that I got it from the correct sender
599600

600601
# These two will raise exception if untrue
601602
validate_on_or_after(data.not_on_or_after, self.timeslack)
@@ -824,6 +825,28 @@ def session_info(self):
824825
def __str__(self):
825826
return "%s" % self.xmlstr
826827

828+
def verify_attesting_entity(self, address):
829+
"""
830+
Assumes one assertion. At least one address specification has to be
831+
correct.
832+
833+
:param address: IP address of attesting entity
834+
:return: True/False
835+
"""
836+
837+
correct = 0
838+
for subject_conf in self.assertion.subject.subject_confirmation:
839+
if subject_conf.subject_confirmation_data.address:
840+
if subject_conf.subject_confirmation_data.address == address:
841+
correct += 1
842+
else:
843+
correct += 1
844+
845+
if correct:
846+
return True
847+
else:
848+
return False
849+
827850

828851
class AuthnQueryResponse(AuthnResponse):
829852
msgtype = "authn_query_response"
@@ -982,3 +1005,4 @@ def _postamble(self):
9821005
logger.debug("response: %s" % (self.response,))
9831006

9841007
return self
1008+

0 commit comments

Comments
 (0)