Skip to content

Commit 1bdc478

Browse files
author
Roland Hedberg
committed
Allow extension schemas to be specified in the configuration file.
1 parent 948b752 commit 1bdc478

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

src/saml2/config.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@
6161
"referred_binding",
6262
"session_storage",
6363
"entity_category",
64-
"xmlsec_path"
64+
"xmlsec_path",
65+
"extension_schemas"
6566
]
6667

6768
SP_ARGS = [
@@ -197,6 +198,7 @@ def __init__(self, homedir="."):
197198
self.crypto_backend = 'xmlsec1'
198199
self.scope = ""
199200
self.allow_unknown_attributes = False
201+
self.extension_schema = {}
200202

201203
def setattr(self, context, attr, val):
202204
if context == "":
@@ -291,6 +293,11 @@ def load(self, cnf, metadata_construction=False):
291293
for key, val in cnf["virtual_organization"].items():
292294
self.vorg[key] = VirtualOrg(None, key, val)
293295
continue
296+
elif arg == "extension_schemas":
297+
# List of filename of modules representing the schemas
298+
for mod_file in cnf["extension_schemas"]:
299+
_mod = self._load(mod_file)
300+
self.extension_schema[_mod.NAMESPACE] = _mod
294301

295302
try:
296303
setattr(self, arg, _uc(cnf[arg]))
@@ -314,18 +321,21 @@ def load(self, cnf, metadata_construction=False):
314321

315322
return self
316323

317-
def load_file(self, config_file, metadata_construction=False):
318-
if config_file.endswith(".py"):
319-
config_file = config_file[:-3]
320-
321-
head, tail = os.path.split(config_file)
324+
def _load(self, fil):
325+
head, tail = os.path.split(fil)
322326
if head == "":
323327
if sys.path[0] != ".":
324328
sys.path.insert(0, ".")
325329
else:
326330
sys.path.insert(0, head)
327331

328-
mod = import_module(tail)
332+
return import_module(tail)
333+
334+
def load_file(self, config_file, metadata_construction=False):
335+
if config_file.endswith(".py"):
336+
config_file = config_file[:-3]
337+
338+
mod = self._load(config_file)
329339
#return self.load(eval(open(config_file).read()))
330340
return self.load(mod.CONFIG, metadata_construction)
331341

0 commit comments

Comments
 (0)