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:
parent
6aadeb4683
commit
8e26c33abd
2 changed files with 24 additions and 0 deletions
|
@ -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" "$@"
|
||||
}
|
||||
|
|
|
@ -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
|
||||
#=================================================
|
||||
|
|
Loading…
Add table
Reference in a new issue