Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: jans-linux-setup scan docs/script-catalog for custom scripts #2488

Merged
merged 2 commits into from
Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions jans-linux-setup/jans_setup/setup_app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ def progress(self, service_name, msg, incr=False):
self.staticFolder = os.path.join(self.install_dir, 'static')

self.extensionFolder = os.path.join(self.staticFolder, 'extension')
self.script_catalog_dir = os.path.join(self.install_dir, 'script_catalog')

self.encoded_ldapTrustStorePass = None

Expand Down
4 changes: 4 additions & 0 deletions jans-linux-setup/jans_setup/setup_app/installers/jans.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def initialize(self):
else:
self.logIt("Key generator path was determined as {}".format(Config.non_setup_properties['key_export_path']))

self.extract_scripts()

def configureSystem(self):
self.logIt("Configuring system", 'jans')
Expand Down Expand Up @@ -522,3 +523,6 @@ def enable_scripts(self, inums, enable=True):
if inums:
for inum in inums:
self.dbUtils.enable_script(inum, enable)

def extract_scripts(self):
base.extract_from_zip(base.current_app.jans_zip, 'docs/script-catalog', Config.script_catalog_dir)
28 changes: 15 additions & 13 deletions jans-linux-setup/jans_setup/setup_app/utils/crypto64.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,19 +158,21 @@ def gen_key_cert_from_ca(self, fn_suffix, ca_suffix='ca', cn=None):

def prepare_base64_extension_scripts(self, extensions=[]):
self.logIt("Preparing scripts")
extension_path = Path(Config.extensionFolder)
for ep in extension_path.glob("**/*"):
if ep.is_file() and ep.suffix.lower() in ['.py', '.java']:
extension_type = ep.relative_to(Config.extensionFolder).parent.as_posix().lower().replace(os.path.sep, '_')
extension_name = ep.stem.lower()
extension_script_name = '{}_{}'.format(extension_type, extension_name)

if extensions and extension_script_name in extensions:
continue

# Prepare key for dictionary
base64_script_file = self.generate_base64_file(ep.as_posix(), 1)
Config.templateRenderingDict[extension_script_name] = base64_script_file
# Remove extensionFolder when all scripts are moved to script_catalog_dir
for path_ in (Config.extensionFolder, Config.script_catalog_dir):
extension_path = Path(path_)
for ep in extension_path.glob("**/*"):
if ep.is_file() and ep.suffix.lower() in ['.py', '.java']:
extension_type = ep.relative_to(path_).parent.as_posix().lower().replace(os.path.sep, '_').replace('-','_')
extension_name = ep.stem.lower()
extension_script_name = '{}_{}'.format(extension_type, extension_name)

if extensions and extension_script_name in extensions:
continue

# Prepare key for dictionary
base64_script_file = self.generate_base64_file(ep.as_posix(), 1)
Config.templateRenderingDict[extension_script_name] = base64_script_file


def generate_base64_file(self, fn, num_spaces):
Expand Down
2 changes: 1 addition & 1 deletion jans-linux-setup/jans_setup/templates/scripts.ldif
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ jansLevel: 50
jansModuleProperty: {"value1":"usage_type","value2":"interactive","description":""}
jansModuleProperty: {"value1":"location_type","value2":"ldap","description":""}
jansRevision: 1
jansScr::%(person_authentication_duoexternalauthenticator)s
jansScr::%(person_authentication_duo_external_authenticator_duoexternalauthenticator)s
jansScrTyp: person_authentication
objectClass: top
objectClass: jansCustomScr
Expand Down