From 525553e750ec2cd77803c32fe6176b8d26c5b3ef Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 22 Mar 2022 23:38:41 +0100 Subject: [PATCH] Adding secret --- conf/configuration.php | 2 +- scripts/install | 2 ++ scripts/upgrade | 7 +++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/conf/configuration.php b/conf/configuration.php index c9b1ab1..7328567 100644 --- a/conf/configuration.php +++ b/conf/configuration.php @@ -52,7 +52,7 @@ class JConfig public $dbsslcipher = ''; /* Server Settings */ - public $secret = ''; // Use something very secure. For example on linux the following command `cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w ${1:-16} | head -n 1` + public $secret = '__SECRET__'; // Use something very secure. For example on linux the following command `cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w ${1:-16} | head -n 1` public $gzip = false; public $error_reporting = 'default'; public $helpurl = 'https://help.joomla.org/proxy?keyref=Help{major}{minor}:{keyref}&lang={langcode}'; diff --git a/scripts/install b/scripts/install index e66b421..f678de3 100644 --- a/scripts/install +++ b/scripts/install @@ -30,6 +30,7 @@ app=$YNH_APP_INSTANCE_NAME admin_email=$(ynh_user_get_info --username="$admin" --key="mail") db_prefix="$(ynh_string_random --length="4")_" +secret=$(ynh_string_random --length="16") #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS @@ -51,6 +52,7 @@ ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=admin --value=$admin ynh_app_setting_set --app=$app --key=db_prefix --value=$db_prefix +ynh_app_setting_set --app=$app --key=secret --value=$secret #================================================= # STANDARD MODIFICATIONS diff --git a/scripts/upgrade b/scripts/upgrade index 7cc1c94..e2c64ee 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -24,6 +24,7 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) db_prefix=$(ynh_app_setting_get --app=$app --key=db_prefix) +secret=$(ynh_app_setting_get --app=$app --key=secret) #================================================= # CHECK VERSION @@ -59,6 +60,12 @@ if [ -z "$db_prefix" ]; then ynh_app_setting_set --app=$app --key=db_prefix --value=$db_prefix fi +# If secret doesn't exist, create it +if [ -z "$secret" ]; then + secret="" + ynh_app_setting_set --app=$app --key=secret --value=$secret +fi + #================================================= # CREATE DEDICATED USER #=================================================