Encoding the mongo credentials in install.sh script (#310)

This is to ensure that we handle special characters in the mongo url that's given to the Java server during configuration.
This commit is contained in:
Arpit Mohan 2020-08-17 11:10:01 +05:30 committed by GitHub
parent 855fc1c00a
commit 88c45118e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 3 deletions

View File

@ -34,6 +34,11 @@ mongo_host="mongo"
mongo_database="appsmith" mongo_database="appsmith"
mongo_root_user=$( generate_random_string ) mongo_root_user=$( generate_random_string )
mongo_root_password=$( generate_random_string ) mongo_root_password=$( generate_random_string )
# The encoded strings are the same as the raw strings because we are generating them and hence it'll be without special characters
encoded_mongo_root_user=mongo_root_user
encoded_mongo_root_password=mongo_root_password
user_encryption_password=$( generate_random_string ) user_encryption_password=$( generate_random_string )
user_encryption_salt=$( generate_random_string ) user_encryption_salt=$( generate_random_string )

View File

@ -152,6 +152,23 @@ wait_for_containers_start() {
done done
} }
urlencode() {
# urlencode <string>
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:i:1}"
case $c in
[a-zA-Z0-9.~_-]) printf "$c" ;;
*) printf '%%%02X' "'$c" ;;
esac
done
LC_COLLATE=$old_lc_collate
}
echo -e "\U1F44B Thank you for trying out Appsmith! " echo -e "\U1F44B Thank you for trying out Appsmith! "
echo "" echo ""
@ -236,6 +253,10 @@ elif [ $fresh_install == "Y" -o $fresh_install == "y" -o $fresh_install == "yes"
fi fi
echo "" echo ""
# urlencoding the Mongo username and password
encoded_mongo_root_user=$( urlencode $mongo_root_user )
encoded_mongo_root_password=$( urlencode $mongo_root_password )
encryptionEnv=./template/encryption.env encryptionEnv=./template/encryption.env
if test -f "$encryptionEnv"; then if test -f "$encryptionEnv"; then
echo "CAUTION : This isn't your first time installing appsmith. Encryption password and salt already exist. Do you want to override this? NOTE: Overwriting the existing salt and password would lead to you losing access to sensitive information encrypted using the same" echo "CAUTION : This isn't your first time installing appsmith. Encryption password and salt already exist. Do you want to override this? NOTE: Overwriting the existing salt and password would lead to you losing access to sensitive information encrypted using the same"
@ -345,8 +366,10 @@ else
echo "No domain found. Skipping generation of SSL certificate." echo "No domain found. Skipping generation of SSL certificate."
fi fi
echo ""
echo "Pulling the latest container images" echo "Pulling the latest container images"
sudo docker-compose pull sudo docker-compose pull
echo ""
echo "Starting the Appsmith containers" echo "Starting the Appsmith containers"
sudo docker-compose -f docker-compose.yml up -d --remove-orphans sudo docker-compose -f docker-compose.yml up -d --remove-orphans
@ -370,12 +393,13 @@ else
echo "Your installation is complete. Please run the following command to ensure that all the containers are running without errors:" echo "Your installation is complete. Please run the following command to ensure that all the containers are running without errors:"
echo "" echo ""
echo "cd $install_dir && sudo docker-compose ps -a" echo "cd $install_dir && sudo docker-compose ps -a"
echo ""
echo "Your application is running on http://localhost"
echo "+++++++++++++++++++++++++++++++++++++++++++++++++" echo "+++++++++++++++++++++++++++++++++++++++++++++++++"
echo "" echo ""
echo "Need help troubleshooting?" echo "Need help troubleshooting?"
echo "Join our Discord server https://discord.com/invite/rBTTVJp" echo "Join our Discord server https://discord.com/invite/rBTTVJp"
echo ""
echo "Your application is running on http://localhost"
fi fi
echo ""
echo -e "Peace out \U1F596" echo -e "Peace out \U1F596"

View File

@ -37,6 +37,6 @@ APPSMITH_MAIL_ENABLED=false
# ******** Database ************* # ******** Database *************
APPSMITH_REDIS_URL=redis://redis:6379 APPSMITH_REDIS_URL=redis://redis:6379
APPSMITH_MONGODB_URI=mongodb://$mongo_root_user:$mongo_root_password@$mongo_host/appsmith?retryWrites=true APPSMITH_MONGODB_URI=mongodb://$encoded_mongo_root_user:$encoded_mongo_root_password@$mongo_host/appsmith?retryWrites=true
# ******************************* # *******************************
EOF EOF