From a4f913262f8b204c33284df4373c437416d06afd Mon Sep 17 00:00:00 2001 From: Mustafa Baser Date: Wed, 1 Jun 2022 10:41:32 +0300 Subject: [PATCH 1/2] feat: jans-linux-setup agama --- jans-linux-setup/jans_setup/setup_app/config.py | 4 ++++ .../jans_setup/setup_app/installers/jans_auth.py | 16 ++++++++++++---- .../jans_setup/setup_app/utils/base.py | 3 ++- jans-linux-setup/jans_setup/templates/agama.ldif | 14 ++++++++++++++ .../jans_setup/templates/scripts.ldif | 16 ++++++++++++++++ 5 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 jans-linux-setup/jans_setup/templates/agama.ldif diff --git a/jans-linux-setup/jans_setup/setup_app/config.py b/jans-linux-setup/jans_setup/setup_app/config.py index f5f07e0b01b..8bb0fea1792 100644 --- a/jans-linux-setup/jans_setup/setup_app/config.py +++ b/jans-linux-setup/jans_setup/setup_app/config.py @@ -286,6 +286,7 @@ def progress(self, service_name, msg, incr=False): self.ldif_base = os.path.join(self.output_dir, 'base.ldif') self.ldif_attributes = os.path.join(self.output_dir, 'attributes.ldif') self.ldif_scopes = os.path.join(self.output_dir, 'scopes.ldif') + self.ldif_agama = os.path.join(self.output_dir, 'agama.ldif') self.ldif_metric = os.path.join(self.staticFolder, 'metric/o_metric.ldif') self.ldif_site = os.path.join(self.install_dir, 'static/cache-refresh/o_site.ldif') @@ -316,6 +317,7 @@ def progress(self, service_name, msg, incr=False): self.ldif_site, self.ldif_metric, self.ldif_configuration, + self.ldif_agama, ] @@ -327,6 +329,7 @@ def progress(self, service_name, msg, incr=False): self.ldif_base: False, self.ldif_attributes: False, self.ldif_scopes: False, + self.ldif_agama: False, } if self.profile != OPENBANKING_PROFILE: @@ -360,6 +363,7 @@ def progress(self, service_name, msg, incr=False): self.ldif_scopes, self.ldif_configuration, self.ldif_metric, + self.ldif_agama, ], 'memory_allocation': 100, 'mapping': '', 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 aec8d2fdb96..74ba6cb9e04 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 @@ -30,6 +30,7 @@ def __init__(self): (os.path.join(Config.dist_jans_dir, 'jans-auth-client-jar-with-dependencies.jar'), os.path.join(base.current_app.app_info['JANS_MAVEN'], 'maven/io/jans/jans-auth-client/{0}/jans-auth-client-{0}-jar-with-dependencies.jar'.format(base.current_app.app_info['ox_version']))), ] + self.jetty_service_webapps = os.path.join(self.jetty_base, self.service_name, 'webapps') self.templates_folder = os.path.join(Config.templateFolder, self.service_name) self.output_folder = os.path.join(Config.output_dir, self.service_name) @@ -51,10 +52,8 @@ def install(self): self.logIt("Copying auth.war into jetty webapps folder...") self.installJettyService(self.jetty_app_configuration[self.service_name], True) - - jettyServiceWebapps = os.path.join(self.jetty_base, self.service_name, 'webapps') - self.copyFile(self.source_files[0][0], jettyServiceWebapps) - + self.copyFile(self.source_files[0][0], self.jetty_service_webapps) + self.setup_agama() self.enable() def generate_configuration(self): @@ -184,3 +183,12 @@ def import_openbanking_key(self): if os.path.isfile(Config.ob_key_fn) and os.path.isfile(Config.ob_cert_fn): self.import_key_cert_into_keystore('obsigning', self.oxauth_openid_jks_fn, Config.oxauth_openid_jks_pass, Config.ob_key_fn, Config.ob_cert_fn, Config.ob_alias) + + def setup_agama(self): + agama_root = os.path.join(self.jetty_base, self.service_name, 'agama') + self.createDirs(agama_root) + for adir in ('fl', 'ftl', 'scripts'): + self.createDirs(os.path.join(agama_root, adir)) + base.extract_from_zip(base.current_app.jans_zip, 'agama/misc', agama_root) + src_xml = os.path.join(Config.templateFolder, 'jetty/agama_web_resources.xml') + self.copyFile(src_xml, self.jetty_service_webapps) diff --git a/jans-linux-setup/jans_setup/setup_app/utils/base.py b/jans-linux-setup/jans_setup/setup_app/utils/base.py index 8f91fdd020e..139bc0f088b 100644 --- a/jans-linux-setup/jans_setup/setup_app/utils/base.py +++ b/jans-linux-setup/jans_setup/setup_app/utils/base.py @@ -353,7 +353,8 @@ def extract_from_zip(zip_file, sub_dir, target_dir, remove_target_dir=False): if remove_target_dir and target_dir_path.exists(): shutil.rmtree(target_dir_path) - target_dir_path.mkdir(parents=True) + if not target_dir_path.exists(): + target_dir_path.mkdir(parents=True) for member in zipobj.infolist(): if member.filename.startswith(parent_sub_dir): diff --git a/jans-linux-setup/jans_setup/templates/agama.ldif b/jans-linux-setup/jans_setup/templates/agama.ldif new file mode 100644 index 00000000000..a872c4137b9 --- /dev/null +++ b/jans-linux-setup/jans_setup/templates/agama.ldif @@ -0,0 +1,14 @@ +dn: ou=agama,o=jans +objectClass: organizationalUnit +objectClass: top +ou: agama + +dn: ou=runs,ou=agama,o=jans +objectClass: organizationalUnit +objectClass: top +ou: runs + +dn: ou=flows,ou=agama,o=jans +objectClass: organizationalUnit +objectClass: top +ou: flows diff --git a/jans-linux-setup/jans_setup/templates/scripts.ldif b/jans-linux-setup/jans_setup/templates/scripts.ldif index e3f6efc1386..3260dd92f06 100644 --- a/jans-linux-setup/jans_setup/templates/scripts.ldif +++ b/jans-linux-setup/jans_setup/templates/scripts.ldif @@ -530,3 +530,19 @@ jansProgLng: java jansRevision: 11 jansScr::%(discovery_discovery)s jansScrTyp: discovery + +dn: inum=BADA-BADA,ou=scripts,o=jans +objectClass: jansCustomScr +objectClass: top +description: Agama Script +displayName: agama +inum: BADA-BADA +jansConfProperty: {"value1":"cust_param_name","value2":"customParam1","hide":false,"description":""} +jansEnabled: false +jansLevel: 10 +jansModuleProperty: {"value1":"usage_type","value2":"interactive","description":""} +jansModuleProperty: {"value1":"location_type","value2":"ldap","description": ""} +jansProgLng: python +jansRevision: 1 +jansScr::%(person_authentication_agamabridge)s +jansScrTyp: person_authentication From eab3867cd078c29ceff889692a55c62a7244ae37 Mon Sep 17 00:00:00 2001 From: Mustafa Baser Date: Wed, 1 Jun 2022 15:51:33 +0300 Subject: [PATCH 2/2] fix: render agema template and chown to jetty --- .../jans_setup/setup_app/installers/jans_auth.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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 74ba6cb9e04..240a3b2c9f9 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 @@ -190,5 +190,11 @@ def setup_agama(self): for adir in ('fl', 'ftl', 'scripts'): self.createDirs(os.path.join(agama_root, adir)) base.extract_from_zip(base.current_app.jans_zip, 'agama/misc', agama_root) - src_xml = os.path.join(Config.templateFolder, 'jetty/agama_web_resources.xml') - self.copyFile(src_xml, self.jetty_service_webapps) + self.chown(agama_root, Config.jetty_user, Config.jetty_group, recursive=True) + + tmp_dir = os.path.join(Config.templateFolder, 'jetty') + src_xml = os.path.join(tmp_dir, 'agama_web_resources.xml') + self.renderTemplateInOut(src_xml, tmp_dir, self.jetty_service_webapps) + self.chown(os.path.join(self.jetty_service_webapps, os.path.basename(src_xml)), Config.jetty_user, Config.jetty_group) + +