summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Kanakarakis <ivan.kanak@gmail.com>2021-01-07 19:13:20 +0200
committerIvan Kanakarakis <ivan.kanak@gmail.com>2021-01-07 19:30:35 +0200
commit17f4daf48fdd36b6fcd1ad30e7641d6845b94202 (patch)
treead2ae846f0700bcb9adfe99563d6f599e478f916
parentbdc3707f2dba5b617959ccdd6d9b1633bce9577d (diff)
downloadpysaml2-17f4daf48fdd36b6fcd1ad30e7641d6845b94202.tar.gz
Load the encryption template using package resources
Signed-off-by: Ivan Kanakarakis <ivan.kanak@gmail.com>
-rw-r--r--setup.cfg1
-rw-r--r--src/saml2/data/__init__.py0
-rw-r--r--src/saml2/data/templates/__init__.py0
-rw-r--r--src/saml2/data/templates/template_enc.xml (renamed from src/saml2/xml_template/template.xml)0
-rw-r--r--src/saml2/sigver.py5
5 files changed, 4 insertions, 2 deletions
diff --git a/setup.cfg b/setup.cfg
index 9c25f6f4..fba061b7 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -53,6 +53,7 @@ install_requires =
pytz
requests >= 1.0.0
six
+ importlib_resources
[options.packages.find]
diff --git a/src/saml2/data/__init__.py b/src/saml2/data/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/saml2/data/__init__.py
diff --git a/src/saml2/data/templates/__init__.py b/src/saml2/data/templates/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/saml2/data/templates/__init__.py
diff --git a/src/saml2/xml_template/template.xml b/src/saml2/data/templates/template_enc.xml
index 0b962e55..0b962e55 100644
--- a/src/saml2/xml_template/template.xml
+++ b/src/saml2/data/templates/template_enc.xml
diff --git a/src/saml2/sigver.py b/src/saml2/sigver.py
index 15c3ebee..0e8f1942 100644
--- a/src/saml2/sigver.py
+++ b/src/saml2/sigver.py
@@ -24,6 +24,7 @@ from six.moves.urllib import parse
import saml2.cryptography.asymmetric
import saml2.cryptography.pki
import saml2.xmldsig as ds
+import saml2.data.templates as _data_template
from saml2 import samlp
from saml2 import SamlBase
from saml2 import SAMLError
@@ -1288,8 +1289,8 @@ class SecurityContext(object):
self.only_use_keys_in_metadata = only_use_keys_in_metadata
if not template:
- this_dir, this_filename = os.path.split(__file__)
- self.template = os.path.join(this_dir, 'xml_template', 'template.xml')
+ with _resource_path(_data_template, "template_enc.xml") as fp:
+ self.template = str(fp)
else:
self.template = template