-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cbfd6a1
commit dac8b70
Showing
3 changed files
with
227 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
authserver.clientId=%(role_based_client_id)s | ||
authserver.clientSecret=%(role_based_client_pw)s | ||
authserver.authzBaseUrl=https://%(hostname)s/jans-auth/authorize.htm | ||
authserver.scope=openid+profile+email+user_name | ||
authserver.redirectUrl=https://%(hostname)s/admin | ||
authserver.frontChannelLogoutUrl=https://%(hostname)s/admin/logout | ||
authserver.postLogoutRedirectUri=https://%(hostname)s/admin | ||
authserver.tokenEndpoint=https://%(hostname)s/jans-auth/restv1/token | ||
authserver.introspectionEndpoint=https://%(hostname)s/jans-auth/restv1/introspection | ||
authserver.userInfoEndpoint=https://%(hostname)s/jans-auth/restv1/userinfo | ||
authserver.endSessionEndpoint=https://%(hostname)s/jans-auth/restv1/end_session | ||
|
||
tokenServer.clientId=%(role_based_client_id)s | ||
tokenServer.clientSecret=%(role_based_client_pw)s | ||
tokenServer.authzBaseUrl=https://%(hostname)s/jans-auth/authorize.htm | ||
tokenServer.scope=openid+profile+email+user_name | ||
tokenServer.redirectUrl=https://%(hostname)s/admin | ||
tokenServer.logoutUrl=https://%(hostname)s/admin | ||
tokenServer.tokenEndpoint=https://%(hostname)s/jans-auth/restv1/token | ||
tokenServer.introspectionEndpoint=https://%(hostname)s/jans-auth/restv1/introspection | ||
tokenServer.userInfoEndpoint=https://%(hostname)s/jans-auth/restv1/userinfo | ||
|
||
|
||
## licenseSpring details | ||
|
||
licenseSpring.apiKey= | ||
licenseSpring.productCode= | ||
licenseSpring.sharedKey= | ||
licenseSpring.managementKey= | ||
licenseSpring.enabled=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import sys | ||
import os | ||
import time | ||
import glob | ||
import json | ||
import shutil | ||
import readline | ||
from collections import OrderedDict | ||
|
||
mydir = os.getcwd() | ||
dirs = glob.glob('/opt/jans/jans-setup/output/gluu-admin-ui*') | ||
run_cmd = '/bin/su node -c "PATH=$PATH:/opt/jre/bin:/opt/node/bin {}"' | ||
|
||
for d in dirs: | ||
if os.path.exists(os.path.join(d, '.env')): | ||
uid_admin_dir = d | ||
break | ||
else: | ||
print("Admin UI installation directory not found.") | ||
sys.exit() | ||
|
||
os.chdir(uid_admin_dir) | ||
plugin_json_fn = os.path.join(uid_admin_dir, 'plugins.config.json') | ||
|
||
def read_plugins(): | ||
with open(plugin_json_fn) as f: | ||
plugins = json.load(f, object_pairs_hook=OrderedDict) | ||
return plugins | ||
|
||
plugins = read_plugins() | ||
|
||
def print_plugins(): | ||
print("Available Plugins") | ||
for i, p in enumerate(plugins): | ||
e = '\033[92m*\033[0m' if p.get('enabled') else ' ' | ||
print('{} {} {}'.format(e, i+1, p.get('title') or p.get('key'))) | ||
print() | ||
|
||
|
||
def exec_command(cmd): | ||
print("\033[1mExecuting {}\033[0m".format(cmd)) | ||
os.system(run_cmd.format(cmd)) | ||
|
||
|
||
def build_copy(): | ||
exec_command('npm run build:prod') | ||
admin_dir = '/var/www/html/admin' | ||
if os.path.exists(admin_dir): | ||
os.rename(admin_dir, admin_dir + '.' + time.ctime()) | ||
|
||
print("Copying admin ui files to apache directory") | ||
shutil.copytree(os.path.join(uid_admin_dir, 'dist'), admin_dir) | ||
|
||
|
||
while True: | ||
print_plugins() | ||
user_input = input('Add/Remove/Finish/Quit [a/r/f/q]: ') | ||
if user_input: | ||
choice = user_input.lower()[0] | ||
if choice == 'q': | ||
print("Exiting without modification.") | ||
break | ||
|
||
elif choice == 'f': | ||
build_copy() | ||
break | ||
|
||
elif choice == 'r': | ||
plugin_number = input('Enter plugin number to remove :') | ||
if plugin_number.isdigit() and int(plugin_number) <= len(plugins): | ||
pn = int(plugin_number) - 1 | ||
for i, p in enumerate(plugins): | ||
if i == pn: | ||
exec_command('npm run plugin:remove {}'.format(p['key'])) | ||
plugins = read_plugins() | ||
break | ||
elif choice == 'a': | ||
plugin_fn = input('Enter path of plugin: ') | ||
if plugin_fn.lower().endswith('.zip'): | ||
exec_command('npm run plugin:add {}'.format(plugin_fn)) | ||
plugins = read_plugins() | ||
else: | ||
print("Can't find \033[31m{}\033[0m".format(plugin_metadata_fn)) | ||
print() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
#!/usr/bin/python3 | ||
|
||
import sys | ||
import os | ||
import zipfile | ||
import argparse | ||
from urllib.parse import urljoin | ||
|
||
jans_setup_dir = '/opt/jans/jans-setup' | ||
sys.path.append(jans_setup_dir) | ||
|
||
if not (os.path.join(jans_setup_dir) and ('/etc/jans/conf/jans.properties')): | ||
print("Please install Jans server then execute this script.") | ||
sys.exit() | ||
|
||
|
||
from setup_app import paths | ||
paths.LOG_FILE = os.path.join(jans_setup_dir, 'logs/flex-setup.log') | ||
paths.LOG_ERROR_FILE = os.path.join(jans_setup_dir, 'logs/flex-setup-error.log') | ||
from setup_app import static | ||
from setup_app.utils import base | ||
|
||
from setup_app.utils.package_utils import packageUtils | ||
from setup_app.config import Config | ||
from setup_app.utils.collect_properties import CollectProperties | ||
from setup_app.installers.node import NodeInstaller | ||
from setup_app.installers.httpd import HttpdInstaller | ||
from setup_app.installers.config_api import ConfigApiInstaller | ||
|
||
parser = argparse.ArgumentParser(description="This script downloads Gluu Admin UI components and installs") | ||
parser.add_argument('--setup-branch', help="Jannsen setup github branch", default='main') | ||
argsp = parser.parse_args() | ||
|
||
# initialize config object | ||
Config.init(paths.INSTALL_DIR) | ||
Config.determine_version() | ||
|
||
collectProperties = CollectProperties() | ||
collectProperties.collect() | ||
|
||
maven_base_url = 'https://maven.jans.io/maven/io/jans/' | ||
app_versions = { | ||
"SETUP_BRANCH": argsp.setup_branch, | ||
"JANS_APP_VERSION": "1.0.0", | ||
"JANS_BUILD": "-SNAPSHOT", | ||
"ADMIN_UI_FRONTEND_BRANCH": "main", | ||
"NODE_VERSION": "v14.18.2" | ||
} | ||
|
||
node_installer = NodeInstaller() | ||
httpdInstaller = HttpdInstaller() | ||
configApiInstaller = ConfigApiInstaller() | ||
|
||
if not node_installer.installed(): | ||
node_fn = 'node-{0}-linux-x64.tar.xz'.format(app_versions['NODE_VERSION']) | ||
node_path = os.path.join(Config.distAppFolder, node_fn) | ||
if not os.path.exists(node_path): | ||
print("Downloading", node_fn) | ||
base.download('https://nodejs.org/dist/{0}/node-{0}-linux-x64.tar.xz'.format(app_versions['NODE_VERSION']), node_path) | ||
print("Installing node") | ||
node_installer.install() | ||
|
||
|
||
gluu_admin_ui_source_path = os.path.join(Config.distJansFolder, 'gluu-admin-ui.zip') | ||
log4j2_adminui_path = os.path.join(Config.distJansFolder, 'log4j2-adminui.xml') | ||
log4j2_path = os.path.join(Config.distJansFolder, 'log4j2.xml') | ||
admin_ui_plugin_source_path = os.path.join(Config.distJansFolder, 'admin-ui-plugin-distribution.jar') | ||
admin_ui_config_properties_path = os.path.join(Config.distJansFolder, 'auiConfiguration.properties') | ||
|
||
print("Downloading components") | ||
base.download(urljoin(maven_base_url, 'admin-ui-plugin/{0}{1}/admin-ui-plugin-{0}{1}-distribution.jar'.format(app_versions['JANS_APP_VERSION'], app_versions['JANS_BUILD'])), admin_ui_plugin_source_path) | ||
base.download('https://raw.githubusercontent.com/JanssenProject/jans-config-api/master/server/src/main/resources/log4j2.xml', log4j2_path) | ||
base.download('https://raw.githubusercontent.com/JanssenProject/jans-config-api/master/plugins/admin-ui-plugin/config/log4j2-adminui.xml', log4j2_adminui_path) | ||
base.download('https://github.com/GluuFederation/gluu-admin-ui/archive/refs/heads/{}.zip'.format(app_versions['ADMIN_UI_FRONTEND_BRANCH']), gluu_admin_ui_source_path) | ||
base.download('https://raw.githubusercontent.com/JanssenProject/jans/{}/flex-linux-setup/auiConfiguration.properties'.format(app_versions['SETUP_BRANCH']), admin_ui_config_properties_path) | ||
|
||
|
||
print("Installing Gluu Admin UI Frontend") | ||
package_zip = zipfile.ZipFile(gluu_admin_ui_source_path, "r") | ||
package_par_dir = package_zip.namelist()[0] | ||
source_dir = os.path.join(Config.outputFolder, package_par_dir) | ||
|
||
print("Extracting", gluu_admin_ui_source_path) | ||
package_zip.extractall(Config.outputFolder) | ||
|
||
configApiInstaller.renderTemplateInOut(os.path.join(source_dir, '.env.tmp'), source_dir, source_dir) | ||
configApiInstaller.copyFile(os.path.join(source_dir, '.env.tmp'), os.path.join(source_dir, '.env')) | ||
configApiInstaller.run([paths.cmd_chown, '-R', 'node:node', source_dir]) | ||
cmd_path = 'PATH=$PATH:{}/bin:{}/bin'.format(Config.jre_home, Config.node_home) | ||
|
||
for cmd in ('npm install @openapitools/openapi-generator-cli', 'npm run api', 'npm install', 'npm run build:prod'): | ||
print("Executing `{}`".format(cmd)) | ||
run_cmd = '{} {}'.format(cmd_path, cmd) | ||
configApiInstaller.run(['/bin/su', 'node','-c', run_cmd], source_dir) | ||
|
||
target_dir = os.path.join(httpdInstaller.server_root, 'admin') | ||
print("Copying files to", target_dir) | ||
configApiInstaller.copyTree(os.path.join(source_dir, 'dist'), target_dir) | ||
|
||
configApiInstaller.check_clients([('role_based_client_id', '2000.')]) | ||
configApiInstaller.renderTemplateInOut(admin_ui_config_properties_path, Config.distJansFolder, configApiInstaller.custom_config_dir) | ||
admin_ui_plugin_path = os.path.join(configApiInstaller.libDir, os.path.basename(admin_ui_plugin_source_path)) | ||
configApiInstaller.web_app_xml_fn = os.path.join(configApiInstaller.jetty_base, configApiInstaller.service_name, 'webapps/jans-config-api.xml') | ||
configApiInstaller.copyFile(admin_ui_plugin_source_path, configApiInstaller.libDir) | ||
configApiInstaller.add_extra_class(admin_ui_plugin_path) | ||
|
||
for logfn in (log4j2_adminui_path, log4j2_path): | ||
configApiInstaller.copyFile(logfn, configApiInstaller.custom_config_dir) | ||
|
||
print("Restarting Janssen Config Api") | ||
configApiInstaller.restart() | ||
|
||
print("Installation was completed. Browse https://{}/admin".format(Config.hostname)) |