diff options
author | John Paraskevopoulos <jpr@dialectics.space> | 2019-09-30 13:22:44 +0300 |
---|---|---|
committer | Ivan Kanakarakis <ivan.kanak@gmail.com> | 2019-11-26 14:02:27 +0200 |
commit | cc4526867734e40f3e413f309c450bb9033a871b (patch) | |
tree | a6caa568dd8138a3b818bedcf89b97fcc20955f1 /src/saml2/entity.py | |
parent | 2109a65b1a233d42da84cc2aad982bf8a4b49816 (diff) | |
download | pysaml2-cc4526867734e40f3e413f309c450bb9033a871b.tar.gz |
Extract `PYSAML2_DELETE_TMPFILES` option to config.py
- Moves parsing PYSAML2_DELETE_TMPFILES option to config.py and uses the
value as a Config class property (`delete_tmpfiles`). This attribute is
part of the configuration so its place is in the config.py and the
corresponding class. This may add the config object dependency to
classes/functions that are calling the `make_temp` function, but at the
same time keeps a more layered approach since this config option is now
processed and set up in the correct layer; that is the Config class and
the config module. Scripts that (in)directly use classes that have
methods that use the `make_temp` functions were not changed since
those methods are not called when these scripts run and they are out of
the scripts' scope (that is, the script functionality does not create
any temp file). Those scripts are `verify_metadata`, `merge_metadata`
and `mdexport`
Diffstat (limited to 'src/saml2/entity.py')
-rw-r--r-- | src/saml2/entity.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/saml2/entity.py b/src/saml2/entity.py index f76ae67d..2ab1995b 100644 --- a/src/saml2/entity.py +++ b/src/saml2/entity.py @@ -144,7 +144,7 @@ class Entity(HTTPBase): if _val.startswith("http"): r = requests.request("GET", _val) if r.status_code == 200: - tmp = make_temp(r.text, ".pem", False) + tmp = make_temp(r.text, ".pem", False, self.config.delete_tmpfiles) setattr(self.config, item, tmp.name) else: raise Exception( @@ -560,7 +560,9 @@ class Entity(HTTPBase): _cert = "%s%s" % (begin_cert, _cert) if end_cert not in _cert: _cert = "%s%s" % (_cert, end_cert) - tmp = make_temp(_cert.encode('ascii'), decode=False) + tmp = make_temp(_cert.encode('ascii'), + decode=False, + delete_tmpfiles=self.config.delete_tmpfiles) response = self.sec.encrypt_assertion(response, tmp.name, pre_encryption_part(), node_xpath=node_xpath) |