Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Password validation check #703

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions scripts/includes/common.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@

###This will ask user to create strong password containing one Upper case alphabet, one lower case alphabet, one digut and if it matches the criteria then only user will be given access to the installation.
set_password(){
typeset PASSWORD
regex="^(?=[a-zA-Z0-9#@!\-&+=\$\/?]{8,120}$)(?=.*?[a-z])(?=.*?[A-Z])(?=.*?[0-9])(?=.*?[#@!\-&+=\$\/]).*"
#echo $regex
echo "******Please Note: Password should be at least 8 characters long with one digit, one Upper case Alphabet, one lower case alphabet and one special character ******"
echo "Please enter password for User to be created: "
read PASSWORD
if [ "${PASSWORD}" = '' ]; then
echo "Password cannot be empty."
exit 1
fi
while ! echo "$PASSWORD" | grep -P "$regex"
do
echo "Enter password to match criteria"
read PASSWORD
done
}

function configure_proxy() {
# Allow bypassing 'proxy' env vars via sudo
local sudoers_proxy='Defaults env_keep += "http_proxy https_proxy no_proxy proxy_ca_bundle_path DEBIAN_FRONTEND"'
Expand Down
28 changes: 22 additions & 6 deletions scripts/st2bootstrap-deb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ if [[ "$SUBTYPE" != 'xenial' && "$SUBTYPE" != 'focal' && "$SUBTYPE" != 'bionic'
exit 2
fi


setup_args() {
for i in "$@"
do
Expand Down Expand Up @@ -111,12 +112,7 @@ setup_args() {
echo "You can also use \"--user\" and \"--password\" for unattended installation."
echo "Press \"ENTER\" to continue or \"CTRL+C\" to exit/abort"
read -e -p "Admin username: " -i "st2admin" USERNAME
read -e -s -p "Password: " PASSWORD

if [ "${PASSWORD}" = '' ]; then
echo "Password cannot be empty."
exit 1
fi
set_password
fi

# Python 3.6 package is not available in Ubuntu Xenial
Expand Down Expand Up @@ -147,6 +143,26 @@ setup_args() {
}



###This will ask user to create strong password containing one Upper case alphabet, one lower case alphabet, one digut and if it matches the criteria then only user will be given access to the installation.
set_password(){
typeset PASSWORD
regex="^(?=[a-zA-Z0-9#@!\-&+=\$\/?]{8,120}$)(?=.*?[a-z])(?=.*?[A-Z])(?=.*?[0-9])(?=.*?[#@!\-&+=\$\/]).*"
#echo $regex
echo "******Please Note: Password should be at least 8 characters long with one digit, one Upper case Alphabet, one lower case alphabet and one special character ******"
echo "Please enter password for User to be created: "
read PASSWORD
if [ "${PASSWORD}" = '' ]; then
echo "Password cannot be empty."
exit 1
fi
while ! echo "$PASSWORD" | grep -P "$regex"
do
echo "Enter password to match criteria"
read PASSWORD
done
}

function configure_proxy() {
# Allow bypassing 'proxy' env vars via sudo
local sudoers_proxy='Defaults env_keep += "http_proxy https_proxy no_proxy proxy_ca_bundle_path DEBIAN_FRONTEND"'
Expand Down
8 changes: 2 additions & 6 deletions scripts/st2bootstrap-deb.template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ if [[ "$SUBTYPE" != 'xenial' && "$SUBTYPE" != 'focal' && "$SUBTYPE" != 'bionic'
exit 2
fi


setup_args() {
for i in "$@"
do
Expand Down Expand Up @@ -103,12 +104,7 @@ setup_args() {
echo "You can also use \"--user\" and \"--password\" for unattended installation."
echo "Press \"ENTER\" to continue or \"CTRL+C\" to exit/abort"
read -e -p "Admin username: " -i "st2admin" USERNAME
read -e -s -p "Password: " PASSWORD

if [ "${PASSWORD}" = '' ]; then
echo "Password cannot be empty."
exit 1
fi
set_password
fi

# Python 3.6 package is not available in Ubuntu Xenial
Expand Down
28 changes: 22 additions & 6 deletions scripts/st2bootstrap-el7.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ ST2_PKG='st2'
ST2WEB_PKG='st2web'
ST2CHATOPS_PKG='st2chatops'


setup_args() {
for i in "$@"
do
Expand Down Expand Up @@ -99,16 +100,31 @@ setup_args() {
echo "You can also use \"--user\" and \"--password\" for unattended installation."
echo "Press \"ENTER\" to continue or \"CTRL+C\" to exit/abort"
read -e -p "Admin username: " -i "st2admin" USERNAME
read -e -s -p "Password: " PASSWORD

if [ "${PASSWORD}" = '' ]; then
echo "Password cannot be empty."
exit 1
fi
set_password
fi
}



###This will ask user to create strong password containing one Upper case alphabet, one lower case alphabet, one digut and if it matches the criteria then only user will be given access to the installation.
set_password(){
typeset PASSWORD
regex="^(?=[a-zA-Z0-9#@!\-&+=\$\/?]{8,120}$)(?=.*?[a-z])(?=.*?[A-Z])(?=.*?[0-9])(?=.*?[#@!\-&+=\$\/]).*"
#echo $regex
echo "******Please Note: Password should be at least 8 characters long with one digit, one Upper case Alphabet, one lower case alphabet and one special character ******"
echo "Please enter password for User to be created: "
read PASSWORD
if [ "${PASSWORD}" = '' ]; then
echo "Password cannot be empty."
exit 1
fi
while ! echo "$PASSWORD" | grep -P "$regex"
do
echo "Enter password to match criteria"
read PASSWORD
done
}

function configure_proxy() {
# Allow bypassing 'proxy' env vars via sudo
local sudoers_proxy='Defaults env_keep += "http_proxy https_proxy no_proxy proxy_ca_bundle_path DEBIAN_FRONTEND"'
Expand Down
8 changes: 2 additions & 6 deletions scripts/st2bootstrap-el7.template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ ST2_PKG='st2'
ST2WEB_PKG='st2web'
ST2CHATOPS_PKG='st2chatops'


setup_args() {
for i in "$@"
do
Expand Down Expand Up @@ -91,12 +92,7 @@ setup_args() {
echo "You can also use \"--user\" and \"--password\" for unattended installation."
echo "Press \"ENTER\" to continue or \"CTRL+C\" to exit/abort"
read -e -p "Admin username: " -i "st2admin" USERNAME
read -e -s -p "Password: " PASSWORD

if [ "${PASSWORD}" = '' ]; then
echo "Password cannot be empty."
exit 1
fi
set_password
fi
}

Expand Down
28 changes: 22 additions & 6 deletions scripts/st2bootstrap-el8.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ is_rhel() {
return $(cat /etc/os-release | grep 'ID="rhel"')
}


setup_args() {
for i in "$@"
do
Expand Down Expand Up @@ -103,16 +104,31 @@ setup_args() {
echo "You can also use \"--user\" and \"--password\" for unattended installation."
echo "Press \"ENTER\" to continue or \"CTRL+C\" to exit/abort"
read -e -p "Admin username: " -i "st2admin" USERNAME
read -e -s -p "Password: " PASSWORD

if [[ "${PASSWORD}" = '' ]]; then
echo "Password cannot be empty."
exit 1
fi
set_password
fi
}



###This will ask user to create strong password containing one Upper case alphabet, one lower case alphabet, one digut and if it matches the criteria then only user will be given access to the installation.
set_password(){
typeset PASSWORD
regex="^(?=[a-zA-Z0-9#@!\-&+=\$\/?]{8,120}$)(?=.*?[a-z])(?=.*?[A-Z])(?=.*?[0-9])(?=.*?[#@!\-&+=\$\/]).*"
#echo $regex
echo "******Please Note: Password should be at least 8 characters long with one digit, one Upper case Alphabet, one lower case alphabet and one special character ******"
echo "Please enter password for User to be created: "
read PASSWORD
if [ "${PASSWORD}" = '' ]; then
echo "Password cannot be empty."
exit 1
fi
while ! echo "$PASSWORD" | grep -P "$regex"
do
echo "Enter password to match criteria"
read PASSWORD
done
}

function configure_proxy() {
# Allow bypassing 'proxy' env vars via sudo
local sudoers_proxy='Defaults env_keep += "http_proxy https_proxy no_proxy proxy_ca_bundle_path DEBIAN_FRONTEND"'
Expand Down
8 changes: 2 additions & 6 deletions scripts/st2bootstrap-el8.template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ is_rhel() {
return $(cat /etc/os-release | grep 'ID="rhel"')
}


setup_args() {
for i in "$@"
do
Expand Down Expand Up @@ -95,12 +96,7 @@ setup_args() {
echo "You can also use \"--user\" and \"--password\" for unattended installation."
echo "Press \"ENTER\" to continue or \"CTRL+C\" to exit/abort"
read -e -p "Admin username: " -i "st2admin" USERNAME
read -e -s -p "Password: " PASSWORD

if [[ "${PASSWORD}" = '' ]]; then
echo "Password cannot be empty."
exit 1
fi
set_password
fi
}

Expand Down