From 6e6d7b38b178bf0a4f6e531f5ae13201cf741bef Mon Sep 17 00:00:00 2001 From: 0xMattijs Date: Thu, 3 Mar 2022 19:22:22 +0100 Subject: [PATCH 1/6] Fix variable substitution in config --- example/flask_rp/wsgi.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/example/flask_rp/wsgi.py b/example/flask_rp/wsgi.py index 5377046..a1d08e2 100755 --- a/example/flask_rp/wsgi.py +++ b/example/flask_rp/wsgi.py @@ -24,6 +24,8 @@ _config = create_from_config_file(Configuration, entity_conf=[{"class": RPConfiguration, "attr": "rp"}], filename=conf) + + _config.format(_config, dir_path, domain=_config.domain, port=_config.port) app = application.oidc_provider_init_app(_config.rp, name, template_folder=template_dir) _web_conf = _config.web_conf From 2f7ee49d3d95fc71357a827b98dc9903239471c4 Mon Sep 17 00:00:00 2001 From: 0xMattijs Date: Fri, 4 Mar 2022 12:01:59 +0100 Subject: [PATCH 2/6] Add testcase demonstrating incorrect variable substitution --- tests/test_22_config.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_22_config.py b/tests/test_22_config.py index bc29a52..c8464e9 100644 --- a/tests/test_22_config.py +++ b/tests/test_22_config.py @@ -22,6 +22,10 @@ def test_yaml_config(): assert set(rp_config.services.keys()) == {'discovery', 'registration', 'authorization', 'accesstoken', 'userinfo', 'end_session'} assert set(rp_config.clients.keys()) == {'', 'bobcat', 'flop'} + assert rp_config.clients['flop'] + assert rp_config.clients['flop']['redirect_uris'] + assert set(rp_config.clients['flop']['redirect_uris']) == {'https://127.0.0.1:8090/authz_cb/flop'} + def test_dict(): From 2d0364178621acdc6f7a3acf5d34c76ac802e4c6 Mon Sep 17 00:00:00 2001 From: NubiaNetworks <100761423+NubiaNetworks@users.noreply.github.com> Date: Fri, 4 Mar 2022 12:08:56 +0100 Subject: [PATCH 3/6] Update wsgi.py --- example/flask_rp/wsgi.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/example/flask_rp/wsgi.py b/example/flask_rp/wsgi.py index a1d08e2..76d8848 100755 --- a/example/flask_rp/wsgi.py +++ b/example/flask_rp/wsgi.py @@ -24,8 +24,7 @@ _config = create_from_config_file(Configuration, entity_conf=[{"class": RPConfiguration, "attr": "rp"}], filename=conf) - - _config.format(_config, dir_path, domain=_config.domain, port=_config.port) + app = application.oidc_provider_init_app(_config.rp, name, template_folder=template_dir) _web_conf = _config.web_conf From 2fbb1a6786315a9520b804bdcff5a08d08e9709b Mon Sep 17 00:00:00 2001 From: NubiaNetworks <100761423+NubiaNetworks@users.noreply.github.com> Date: Fri, 4 Mar 2022 12:09:13 +0100 Subject: [PATCH 4/6] Update wsgi.py --- example/flask_rp/wsgi.py | 1 - 1 file changed, 1 deletion(-) diff --git a/example/flask_rp/wsgi.py b/example/flask_rp/wsgi.py index 76d8848..5377046 100755 --- a/example/flask_rp/wsgi.py +++ b/example/flask_rp/wsgi.py @@ -25,7 +25,6 @@ entity_conf=[{"class": RPConfiguration, "attr": "rp"}], filename=conf) - app = application.oidc_provider_init_app(_config.rp, name, template_folder=template_dir) _web_conf = _config.web_conf context = create_context(dir_path, _web_conf) From beba0e2b29e93b60f4992ea0bacb0b11b302cb9f Mon Sep 17 00:00:00 2001 From: 0xMattijs Date: Fri, 4 Mar 2022 13:48:29 +0100 Subject: [PATCH 5/6] Fixed bug in initialization of uris considered for variable substitution in configs --- src/oidcrp/configure.py | 4 ++++ tests/test_22_config.py | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/oidcrp/configure.py b/src/oidcrp/configure.py index 800d24f..5e33fb7 100755 --- a/src/oidcrp/configure.py +++ b/src/oidcrp/configure.py @@ -24,6 +24,9 @@ class RPConfiguration(Base): + + uris = URIS + def __init__(self, conf: Dict, base_path: Optional[str] = '', @@ -52,6 +55,7 @@ def __init__(self, self.services = lower_or_upper(conf, "services") self.base_url = lower_or_upper(conf, "base_url") self.httpc_params = lower_or_upper(conf, "httpc_params", {"verify": True}) + self.clients = lower_or_upper(conf, "clients") if entity_conf: self.extend(entity_conf=entity_conf, conf=conf, base_path=base_path, diff --git a/tests/test_22_config.py b/tests/test_22_config.py index c8464e9..8c77bbd 100644 --- a/tests/test_22_config.py +++ b/tests/test_22_config.py @@ -25,7 +25,6 @@ def test_yaml_config(): assert rp_config.clients['flop'] assert rp_config.clients['flop']['redirect_uris'] assert set(rp_config.clients['flop']['redirect_uris']) == {'https://127.0.0.1:8090/authz_cb/flop'} - def test_dict(): From 3c934362c465e76da46ceea672ee0e9722766a0f Mon Sep 17 00:00:00 2001 From: 0xMattijs Date: Thu, 3 Mar 2022 19:22:22 +0100 Subject: [PATCH 6/6] Fixed bug in initialization of uris considered for variable substitution in configs --- src/oidcrp/configure.py | 4 ++++ tests/test_22_config.py | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/oidcrp/configure.py b/src/oidcrp/configure.py index 800d24f..5e33fb7 100755 --- a/src/oidcrp/configure.py +++ b/src/oidcrp/configure.py @@ -24,6 +24,9 @@ class RPConfiguration(Base): + + uris = URIS + def __init__(self, conf: Dict, base_path: Optional[str] = '', @@ -52,6 +55,7 @@ def __init__(self, self.services = lower_or_upper(conf, "services") self.base_url = lower_or_upper(conf, "base_url") self.httpc_params = lower_or_upper(conf, "httpc_params", {"verify": True}) + self.clients = lower_or_upper(conf, "clients") if entity_conf: self.extend(entity_conf=entity_conf, conf=conf, base_path=base_path, diff --git a/tests/test_22_config.py b/tests/test_22_config.py index bc29a52..8c77bbd 100644 --- a/tests/test_22_config.py +++ b/tests/test_22_config.py @@ -22,6 +22,9 @@ def test_yaml_config(): assert set(rp_config.services.keys()) == {'discovery', 'registration', 'authorization', 'accesstoken', 'userinfo', 'end_session'} assert set(rp_config.clients.keys()) == {'', 'bobcat', 'flop'} + assert rp_config.clients['flop'] + assert rp_config.clients['flop']['redirect_uris'] + assert set(rp_config.clients['flop']['redirect_uris']) == {'https://127.0.0.1:8090/authz_cb/flop'} def test_dict():