summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Koranda <skoranda@gmail.com>2019-05-07 06:53:22 -0500
committerScott Koranda <skoranda@gmail.com>2019-05-07 06:53:22 -0500
commit3f1ce6bf9605f13a203d9fa52a2b94026adfedf9 (patch)
tree92be923ee0fe6f2682584a8d058d30c5b9559de5
parentd3aa78eeb7d37c12688f783cb4db1c7263a14ad6 (diff)
downloadpysaml2-3f1ce6bf9605f13a203d9fa52a2b94026adfedf9.tar.gz
Enable entity category import from module search path
This enhancement causes an entity category import to first be tried from the general module search path, and if that fails then to fall back to the current default of importing saml2.entity_category.<module>. This allows deployers to overlay their own customized versions of entity category modules like edugain.py that contain CoCo. This is helpful since the list of attributes to be included as part of the entity category may not be globally the same for all deployments. Such is the case with CoCo where the list of attributes changes from federation to federation and deployment to deployment.
-rw-r--r--src/saml2/assertion.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/saml2/assertion.py b/src/saml2/assertion.py
index 8984db59..ed043d9a 100644
--- a/src/saml2/assertion.py
+++ b/src/saml2/assertion.py
@@ -353,8 +353,11 @@ class Policy(object):
else:
ecs = []
for cat in items:
- _mod = importlib.import_module(
- "saml2.entity_category.%s" % cat)
+ try:
+ _mod = importlib.import_module(cat)
+ except ImportError:
+ _mod = importlib.import_module(
+ "saml2.entity_category.%s" % cat)
_ec = {}
for key, items in _mod.RELEASE.items():
alist = [k.lower() for k in items]