1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/fab-manager_ynh.git synced 2024-09-03 18:36:16 +02:00

Check for password policy at the beginning of the app install

This commit is contained in:
Salamandar 2024-06-30 16:00:21 +02:00
parent 496b9dccbf
commit 691425f5e8
2 changed files with 24 additions and 0 deletions

View file

@ -25,6 +25,28 @@ fi
# PERSONAL HELPERS
#=================================================
check_password_policy() {
password="$1"
# 12 caractères minimum, au moins une lettre majuscule, une lettre minuscule, un chiffre et un caractère spécial
msg=""
if (( ${#password} < 10 )); then
msg="is too short"
elif [[ $password != *[[:digit:]]* ]]; then
msg="does not contain any digit"
elif [[ $password != *[[:lower:]]* ]]; then
msg="does not contain any lower case letter"
elif [[ $password != *[[:upper:]]* ]]; then
msg="does not contain any upper case letter"
elif [[ "$password" =~ ^[0-9a-zA-Z]*$ ]]; then
msg="does not contain any special character"
fi
if [ -n "$msg" ]; then
ynh_die "Password should have min 12 chars, at least one lowercase, one uppercase, one digit and one special character, but it $msg."
fi
}
env_ruby() {
ynh_exec_as "$app" "$ynh_ruby_load_path" "$@"
}

View file

@ -16,6 +16,8 @@ admin_mail=$(ynh_user_get_info --username="$admin" --key=mail)
secret_key_base=$(ynh_string_random --length=30)
ynh_app_setting_set --app="$app" --key="secret_key_base" --value="$secret_key_base"
check_password_policy "$password"
#=================================================
# INSTALL DEPENDENCIES
#=================================================