From e406587f6987901b8ef0f0be2b8a457ff95e32ee Mon Sep 17 00:00:00 2001 From: Mustafa Baser Date: Mon, 26 Dec 2022 20:39:54 +0300 Subject: [PATCH] fix: jans-linux-setup remove dependency to removed dependency yaml --- .../jans_setup/setup_app/installers/config_api.py | 14 +++++--------- .../jans_setup/setup_app/installers/jans_auth.py | 15 ++++++++------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/jans-linux-setup/jans_setup/setup_app/installers/config_api.py b/jans-linux-setup/jans_setup/setup_app/installers/config_api.py index 0904179da7a..32bbca2e838 100644 --- a/jans-linux-setup/jans_setup/setup_app/installers/config_api.py +++ b/jans-linux-setup/jans_setup/setup_app/installers/config_api.py @@ -87,18 +87,14 @@ def create_folders(self): self.run([paths.cmd_chown, '-R', 'jetty:jetty', os.path.join(Config.jetty_base, self.service_name)]) - def read_config_api_swagger(self): - config_api_swagger_yaml_fn = os.path.join(Config.data_dir, 'jans-config-api-swagger.yaml') - yml_str = self.readFile(config_api_swagger_yaml_fn) - yml_str = yml_str.replace('\t', ' ') - cfg_yml = ruamel.yaml.load(yml_str, ruamel.yaml.RoundTripLoader) - return cfg_yml - + def get_scope_defs(self): + config_api_rs_protect_fn = os.path.join(Config.data_dir, 'config-api-rs-protect.json') + scopes_def = base.readJsonFile(config_api_rs_protect_fn) + return scopes_def def generate_configuration(self): - config_api_rs_protect_fn = os.path.join(Config.data_dir, 'config-api-rs-protect.json') - scopes_def = base.readJsonFile(config_api_rs_protect_fn) + scopes_def = self.get_scope_defs() scope_type = 'oauth' self.check_clients([('jca_client_id', '1800.')]) diff --git a/jans-linux-setup/jans_setup/setup_app/installers/jans_auth.py b/jans-linux-setup/jans_setup/setup_app/installers/jans_auth.py index ea5d5de09e9..714fa2a5f15 100644 --- a/jans-linux-setup/jans_setup/setup_app/installers/jans_auth.py +++ b/jans-linux-setup/jans_setup/setup_app/installers/jans_auth.py @@ -77,15 +77,16 @@ def generate_configuration(self): def get_config_api_scopes(self): - data = base.current_app.ConfigApiInstaller.read_config_api_swagger() + scopes_def = base.current_app.ConfigApiInstaller.get_scope_defs() scope_list = [] - for epath in data['paths']: - for m in data['paths'][epath]: - if 'security' in data['paths'][epath][m]: - scope_items = [item['oauth2'] for item in data['paths'][epath][m]['security']] - for scopes in scope_items: - scope_list += scopes + for resource in scopes_def['resources']: + + for condition in resource.get('conditions', []): + + for scope in condition.get('scopes', []): + if scope.get('inum') and scope.get('name'): + scope_list.append(scope['name']) return scope_list