Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit 921b7d7

Browse files
committed
Refactored configuration.
1 parent 066fb69 commit 921b7d7

1 file changed

Lines changed: 22 additions & 11 deletions

File tree

src/oidcrp/configure.py

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ def add_base_path(conf: dict, base_path: str, file_attributes: List[str]):
3838
def set_domain_and_port(conf: dict, uris: List[str], domain: str, port: int):
3939
for key, val in conf.items():
4040
if key in uris:
41+
if not val:
42+
continue
43+
4144
if isinstance(val, list):
4245
_new = [v.format(domain=domain, port=port) for v in val]
4346
else:
@@ -82,6 +85,19 @@ def items(self):
8285
continue
8386
yield key, getattr(self, key)
8487

88+
def extend(self, entity_conf, conf, base_path, file_attributes, domain, port):
89+
for econf in entity_conf:
90+
_path = econf.get("path")
91+
_cnf = conf
92+
if _path:
93+
for step in _path:
94+
_cnf = _cnf[step]
95+
_attr = econf["attr"]
96+
_cls = econf["class"]
97+
setattr(self, _attr,
98+
_cls(_cnf, base_path=base_path, file_attributes=file_attributes,
99+
domain=domain, port=port))
100+
85101

86102
URIS = [
87103
"redirect_uris", 'post_logout_redirect_uris', 'frontchannel_logout_uri',
@@ -124,6 +140,10 @@ def __init__(self,
124140
self.base_url = lower_or_upper(conf, "base_url")
125141
self.httpc_params = lower_or_upper(conf, "httpc_params", {"verify": True})
126142

143+
if entity_conf:
144+
self.extend(entity_conf=entity_conf, conf=conf, base_path=base_path,
145+
file_attributes=file_attributes, domain=domain, port=port)
146+
127147

128148
class Configuration(Base):
129149
"""RP Configuration"""
@@ -154,17 +174,8 @@ def __init__(self,
154174
port = conf.get("port", 80)
155175

156176
if entity_conf:
157-
for econf in entity_conf:
158-
_path = econf.get("path")
159-
_cnf = conf
160-
if _path:
161-
for step in _path:
162-
_cnf = _cnf[step]
163-
_attr = econf["attr"]
164-
_cls = econf["class"]
165-
setattr(self, _attr,
166-
_cls(_cnf, base_path=base_path, file_attributes=file_attributes,
167-
domain=domain, port=port))
177+
self.extend(entity_conf=entity_conf, conf=conf, base_path=base_path,
178+
file_attributes=file_attributes, domain=domain, port=port)
168179

169180

170181
def create_from_config_file(cls,

0 commit comments

Comments
 (0)