summaryrefslogtreecommitdiff
path: root/src/saml2/config.py
diff options
context:
space:
mode:
authorIvan Kanakarakis <ivan.kanak@gmail.com>2018-11-19 19:40:25 +0200
committerGitHub <noreply@github.com>2018-11-19 19:40:25 +0200
commitc3d62093af36933d11afbf6c84162e0288da8703 (patch)
tree832666b45153b7cb6490a042b4409420cfad747c /src/saml2/config.py
parent194f5ff112412e64dfad0cd0590b604dacf60ec0 (diff)
parentc79c50ad18aea97fa29f63700410e433efa2f1cc (diff)
downloadpysaml2-c3d62093af36933d11afbf6c84162e0288da8703.tar.gz
Merge pull request #562 from erakli/update_config_factory
Make config_factory to be more universal method
Diffstat (limited to 'src/saml2/config.py')
-rw-r--r--src/saml2/config.py34
1 files changed, 25 insertions, 9 deletions
diff --git a/src/saml2/config.py b/src/saml2/config.py
index e890080a..f18c34a5 100644
--- a/src/saml2/config.py
+++ b/src/saml2/config.py
@@ -563,14 +563,30 @@ class IdPConfig(Config):
Config.__init__(self)
-def config_factory(typ, filename):
- if typ == "sp":
- conf = SPConfig().load_file(filename)
- conf.context = typ
- elif typ in ["aa", "idp", "pdp", "aq"]:
- conf = IdPConfig().load_file(filename)
- conf.context = typ
+def config_factory(_type, config):
+ """
+
+ :type _type: str
+ :param _type:
+
+ :type config: str or dict
+ :param config: Name of file with pysaml2 config or CONFIG dict
+
+ :return:
+ """
+ if _type == "sp":
+ conf = SPConfig()
+ elif _type in ["aa", "idp", "pdp", "aq"]:
+ conf = IdPConfig()
else:
- conf = Config().load_file(filename)
- conf.context = typ
+ conf = Config()
+
+ if isinstance(config, dict):
+ conf.load(copy.deepcopy(config))
+ elif isinstance(config, str):
+ conf.load_file(config)
+ else:
+ raise ValueError('Unknown type of config')
+
+ conf.context = _type
return conf