Skip to content

Commit 9af7555

Browse files
author
Roland Hedberg
committed
Merge branch 'master' of github.com:rohe/pysaml2
2 parents 6d71aa8 + d14411a commit 9af7555

File tree

5 files changed

+33
-20
lines changed

5 files changed

+33
-20
lines changed

doc/howto/config.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,8 @@ There are two options common to all services: 'name' and 'endpoints'.
230230
The remaining options are specific to one or the other of the service types.
231231
Which one is specified along side the name of the option.
232232

233-
timeslack
234-
^^^^^^^^^
233+
accepted_time_diff
234+
^^^^^^^^^^^^^^^^^^
235235

236236
If your computer and another computer that you are communicating with are not
237237
in synch regarding the computer clock, then here you can state how big a

doc/install.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ Hints
6262
RHEL/CentOS installation issues
6363
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6464

65-
A number of packages may not install from pypi. Instead, you may wand to use packages supplies with the OS:
65+
A number of packages may not install from pypi. Instead, you may want to use packages supplied with the OS:
6666

6767
yum -y install swig openssl-devel m2crypto xmlsec1 pyOpenSSL libffi-devel
6868

6969
OS X installation issues
7070
^^^^^^^^^^^^^^^^^^^^^^^^
7171

72-
A number of packages may not install from pypi. Instead, you may wand to use macports:
72+
A number of packages may not install from pypi. Instead, you may want to use macports:
7373

7474
sudo port install swig xmlsec py27-m2crypto py27-crypto db53
7575

src/saml2/entity.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -588,10 +588,10 @@ def srv2typ(service):
588588
else:
589589
return typ
590590

591-
def _parse_request(self, xmlstr, request_cls, service, binding):
591+
def _parse_request(self, enc_request, request_cls, service, binding):
592592
"""Parse a Request
593593
594-
:param xmlstr: The request in its transport format
594+
:param enc_request: The request in its transport format
595595
:param request_cls: The type of requests I expect
596596
:param service:
597597
:param binding: Which binding that was used to transport the message
@@ -625,16 +625,15 @@ def _parse_request(self, xmlstr, request_cls, service, binding):
625625
self.config.attribute_converters,
626626
timeslack=timeslack)
627627

628-
origdoc = xmlstr
629-
xmlstr = self.unravel(xmlstr, binding, request_cls.msgtype)
628+
xmlstr = self.unravel(enc_request, binding, request_cls.msgtype)
630629
must = self.config.getattr("want_authn_requests_signed", "idp")
631630
only_valid_cert = self.config.getattr(
632631
"want_authn_requests_only_with_valid_cert", "idp")
633632
if only_valid_cert is None:
634633
only_valid_cert = False
635634
if only_valid_cert:
636635
must = True
637-
_request = _request.loads(xmlstr, binding, origdoc=origdoc, must=must,
636+
_request = _request.loads(xmlstr, binding, origdoc=enc_request, must=must,
638637
only_valid_cert=only_valid_cert)
639638

640639
_log_debug("Loaded request")

src/saml2/saml.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,7 @@ class AttributeType_(SamlBase):
10401040
def __init__(self,
10411041
attribute_value=None,
10421042
name=None,
1043-
name_format=None,
1043+
name_format=NAME_FORMAT_URI,
10441044
friendly_name=None,
10451045
text=None,
10461046
extension_elements=None,

src/saml2/sigver.py

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ def validate_signature(self, enctext, cert_file, cert_type, node_name,
721721

722722
class CryptoBackendXmlSec1(CryptoBackend):
723723
"""
724-
CryptoBackend implementation using external binary xmlsec1 to sign
724+
CryptoBackend implementation using external binary 1 to sign
725725
and verify XML documents.
726726
"""
727727

@@ -731,6 +731,10 @@ def __init__(self, xmlsec_binary, **kwargs):
731731
CryptoBackend.__init__(self, **kwargs)
732732
assert (isinstance(xmlsec_binary, basestring))
733733
self.xmlsec = xmlsec_binary
734+
if os.environ.get('PYSAML2_KEEP_XMLSEC_TMP', None):
735+
self._xmlsec_delete_tmpfiles = False
736+
else:
737+
self._xmlsec_delete_tmpfiles = True
734738

735739
def version(self):
736740
com_list = [self.xmlsec, "--version"]
@@ -832,7 +836,8 @@ def sign_statement(self, statement, node_name, key_file, node_id,
832836
:return: The signed statement
833837
"""
834838

835-
_, fil = make_temp("%s" % statement, decode=False)
839+
_, fil = make_temp("%s" % statement, suffix=".xml", decode=False,
840+
delete=self._xmlsec_delete_tmpfiles)
836841

837842
com_list = [self.xmlsec, "--sign",
838843
"--privkey-pem", key_file,
@@ -867,7 +872,8 @@ def validate_signature(self, signedtext, cert_file, cert_type, node_name,
867872
:param id_attr: Should normally be one of "id", "Id" or "ID"
868873
:return: Boolean True if the signature was correct otherwise False.
869874
"""
870-
_, fil = make_temp(signedtext, decode=False)
875+
_, fil = make_temp(signedtext, suffix=".xml",
876+
decode=False, delete=self._xmlsec_delete_tmpfiles)
871877

872878
com_list = [self.xmlsec, "--verify",
873879
"--pubkey-cert-%s" % cert_type, cert_file,
@@ -906,7 +912,7 @@ def _run_xmlsec(self, com_list, extra_args, validate_output=True,
906912
:param exception: The exception class to raise on errors
907913
:result: Whatever xmlsec wrote to an --output temporary file
908914
"""
909-
ntf = NamedTemporaryFile()
915+
ntf = NamedTemporaryFile(suffix=".xml", delete=self._xmlsec_delete_tmpfiles)
910916
com_list.extend(["--output", ntf.name])
911917
com_list += extra_args
912918

@@ -1243,6 +1249,11 @@ def __init__(self, crypto, key_file="", key_type="pem",
12431249
self.template = template
12441250

12451251
self.encrypt_key_type = encrypt_key_type
1252+
# keep certificate files to debug xmlsec invocations
1253+
if os.environ.get('PYSAML2_KEEP_XMLSEC_TMP', None):
1254+
self._xmlsec_delete_tmpfiles = False
1255+
else:
1256+
self._xmlsec_delete_tmpfiles = True
12461257

12471258
def correctly_signed(self, xml, must=False):
12481259
logger.debug("verify correct signature")
@@ -1334,16 +1345,19 @@ def _check_signature(self, decoded_xml, item, node_name=NODE_NAME,
13341345
certs = []
13351346
for cert in _certs:
13361347
if isinstance(cert, basestring):
1337-
certs.append(make_temp(pem_format(cert), ".pem", False))
1348+
certs.append(make_temp(pem_format(cert), suffix=".pem",
1349+
decode=False,
1350+
delete=self._xmlsec_delete_tmpfiles))
13381351
else:
13391352
certs.append(cert)
13401353
else:
13411354
certs = []
13421355

13431356
if not certs and not self.only_use_keys_in_metadata:
13441357
logger.debug("==== Certs from instance ====")
1345-
certs = [make_temp(pem_format(cert), ".pem",
1346-
False) for cert in cert_from_instance(item)]
1358+
certs = [make_temp(pem_format(cert), suffix=".pem",
1359+
decode=False, delete=self._xmlsec_delete_tmpfiles)
1360+
for cert in cert_from_instance(item)]
13471361
else:
13481362
logger.debug("==== Certs from metadata ==== %s: %s ====" % (issuer,
13491363
certs))
@@ -1417,8 +1431,8 @@ def correctly_signed_message(self, decoded_xml, msgtype, must=False,
14171431
the entity that sent the info use that, if not use the key that are in
14181432
the message if any.
14191433
1420-
:param decoded_xml: The SAML message as a XML string
1421-
:param msgtype:
1434+
:param decoded_xml: The SAML message as an XML infoset (a string)
1435+
:param msgtype: SAML protocol message type
14221436
:param must: Whether there must be a signature
14231437
:param origdoc:
14241438
:return:
@@ -1435,7 +1449,7 @@ def correctly_signed_message(self, decoded_xml, msgtype, must=False,
14351449

14361450
if not msg.signature:
14371451
if must:
1438-
raise SignatureError("Missing must signature")
1452+
raise SignatureError("Required signature missing on %s" % msgtype)
14391453
else:
14401454
return msg
14411455

0 commit comments

Comments
 (0)