From 7d31df1cc4ee9dd4b2f58e64cdb8908c7caf2eb6 Mon Sep 17 00:00:00 2001 From: anmol26s Date: Sat, 9 Jun 2018 16:59:14 +0530 Subject: [PATCH] Removed the LDAP support --- check_process | 2 +- conf/activate_plugins.sql | 2 +- conf/config.php | 7 ++++++- manifest.json | 8 +++++++- scripts/install | 19 ++++++++++++------- scripts/restore | 8 ++++++++ scripts/upgrade | 6 +----- sources/patches/yourls-ldap-plugin | 1 + sources/patches/yunohost_auth/plugin.php | 21 --------------------- 9 files changed, 37 insertions(+), 37 deletions(-) create mode 160000 sources/patches/yourls-ldap-plugin delete mode 100644 sources/patches/yunohost_auth/plugin.php diff --git a/check_process b/check_process index 60d5646..400d1bc 100644 --- a/check_process +++ b/check_process @@ -25,7 +25,7 @@ Level 1=auto Level 2=auto Level 3=auto -# Level 4: +# Level 4: Level 4=0 # Level 5: Level 5=auto diff --git a/conf/activate_plugins.sql b/conf/activate_plugins.sql index 19ea0da..93ea301 100644 --- a/conf/activate_plugins.sql +++ b/conf/activate_plugins.sql @@ -1,3 +1,3 @@ INSERT INTO `yourls_options` ( `option_name`, `option_value`) VALUES -('active_plugins', 'a:1:{i:0;s:24:"yunohost_auth/plugin.php";}'); +('active_plugins', 'a:1:{i:0;s:29:"yourls-ldap-plugin/plugin.php";}'); diff --git a/conf/config.php b/conf/config.php index cff3e71..024d42c 100644 --- a/conf/config.php +++ b/conf/config.php @@ -57,6 +57,7 @@ define( 'YOURLS_COOKIEKEY', 'modify this text with something random' ); ** YOURLS will auto encrypt plain text passwords in this file ** Read http://yourls.org/userpassword for more information */ $yourls_user_passwords = array( +'yourlsuser' => 'yourpassword', ); /** Debug mode to output some internal information @@ -87,4 +88,8 @@ $yourls_reserved_URL = array( ** Personal settings would go after here. */ -define( 'YOURLS_YUNOHOST_AUTH_ADMIN', 'yourlsuser' ); +//define( 'LDAPAUTH_HOST', 'localhost' ); +//define( 'LDAPAUTH_PORT', '389' ); +//define( 'LDAPAUTH_BASE', 'dc=yunohost,dc=org' ); +//define( 'LDAPAUTH_USERNAME_FIELD', 'uid'); + diff --git a/manifest.json b/manifest.json index 24a4932..55b8670 100644 --- a/manifest.json +++ b/manifest.json @@ -56,7 +56,13 @@ "fr": "Administrateur du site Yourls (doit ĂȘtre un utilisateur Yunohost existant)" }, "example": "yoda" - } + }, + { + "name": "pass", + "type": "password", + "ask": { + "en": "Password for the admin account (At least 6 characters long)" + } ] } diff --git a/scripts/install b/scripts/install index 35b2c6c..2c40b7f 100644 --- a/scripts/install +++ b/scripts/install @@ -23,6 +23,7 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH admin=$YNH_APP_ARG_ADMIN +pass=$YNH_APP_ARG_PASS # This is a multi-instance app, meaning it can be installed several times independently # The id of the app as stated in the manifest is available as $YNH_APP_ID @@ -50,6 +51,10 @@ ynh_webpath_register $app $domain $path_url final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" +# Check password strength +[[ ${#pass} -gt 6 ]] || ynh_die \ +"The password is too weak, it must be longer than 6 characters" + #================================================= # STORE SETTINGS FROM MANIFEST #================================================= @@ -97,9 +102,6 @@ ynh_system_user_create $app # Create a dedicated php-fpm config ynh_add_fpm_config -sudo cp ../conf/index.php $final_path/ -sudo cp -r ../sources/patches/yunohost_auth $final_path/user/plugins - # Change variable in yourls configuration sudo cp ../conf/config.php $final_path/user/config.php @@ -107,9 +109,10 @@ ynh_replace_string "yunouser" "$db_name" "$final_path/user/config.php" ynh_replace_string "yunopass" "$db_pwd" "$final_path/user/config.php" ynh_replace_string "yunobase" "$db_name" "$final_path/user/config.php" ynh_replace_string "yunodomain" "$domain" "$final_path/user/config.php" -ynh_replace_string "yourlsuser" "$admin" "$final_path/user/config.php" ynh_replace_string "_yourlspath" "${path_url%/}" "$final_path/user/config.php" -ynh_replace_string "modify this text with something randomr" "$(ynh_string_random 24)$(ynh_string_random 24)" "$final_path/user/config.php" +ynh_replace_string "yourlsuser" "$admin" "$final_path/user/config.php" +ynh_replace_string "yourpassword" "$pass" "$final_path/user/config.php" +ynh_replace_string "modify this text with something random" "$(ynh_string_random 24)$(ynh_string_random 24)" "$final_path/user/config.php" # Set permissions sudo chown -R $app: $final_path @@ -125,11 +128,13 @@ systemctl reload nginx # Start Yourls install (database table creation) ynh_local_curl "/admin/install.php" "install=dummy" -# Activate auth plugin -ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" < "../conf/activate_plugins.sql" # Calculate and store the config file checksum into the app settings ynh_store_file_checksum "$final_path/user/config.php" +#================================================= +# SETUP SSOWAT +#================================================= + sudo service nginx reload sudo yunohost app ssowatconf diff --git a/scripts/restore b/scripts/restore index c284192..1bab6e8 100644 --- a/scripts/restore +++ b/scripts/restore @@ -31,6 +31,7 @@ domain=$(ynh_app_setting_get $app domain) path_url=$(ynh_app_setting_get $app path) final_path=$(ynh_app_setting_get $app final_path) db_name=$(ynh_app_setting_get $app db_name) +admin=$(ynh_app_setting_get $app admin) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -92,6 +93,13 @@ ynh_restore_file "/etc/php5/fpm/conf.d/20-$app.ini" #================================================= sudo yunohost app setting $app unprotected_uris -v "/" +#================================================= +# SETUP SSOWAT +#================================================= + +# Restrict access to admin only +yunohost app addaccess --users=$admin $app + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 224533b..37583a8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -62,11 +62,9 @@ path_url=$(ynh_normalize_url_path $path_url) # Download, check integrity, uncompress and patch the source from app.src # Create a temporary directory along with /user/plugin sub directory in it tmpdir="$(mktemp -d)" -mkdir -p "$tmpdir/user/plugins" +mkdir -p "$tmpdir/user" # Backup the app files in the temp dir -sudo cp -a "$final_path/index.php" "$tmpdir" -sudo cp -a "$final_path/user/plugins/yunohost_auth" "$tmpdir/user/plugins" sudo cp -a "$final_path/.htaccess" "$tmpdir" sudo cp -a "$final_path/user/config.php" "$tmpdir/user" @@ -77,8 +75,6 @@ ynh_secure_remove "$final_path" ynh_setup_source "$final_path" # Copy the app files from tmp to final_path -sudo cp -a "$tmpdir/index.php" "$final_path" -sudo cp -a "$tmpdir/user/plugins/yunohost_auth" "$final_path/user/plugins" sudo cp -a "$tmpdir/.htaccess" "$final_path" sudo cp -a "$tmpdir/user/config.php" "$final_path/user" diff --git a/sources/patches/yourls-ldap-plugin b/sources/patches/yourls-ldap-plugin new file mode 160000 index 0000000..f562a09 --- /dev/null +++ b/sources/patches/yourls-ldap-plugin @@ -0,0 +1 @@ +Subproject commit f562a093f85081a6c9c0ec4a352456f7da3aabb2 diff --git a/sources/patches/yunohost_auth/plugin.php b/sources/patches/yunohost_auth/plugin.php deleted file mode 100644 index e684c9d..0000000 --- a/sources/patches/yunohost_auth/plugin.php +++ /dev/null @@ -1,21 +0,0 @@ -