-
Notifications
You must be signed in to change notification settings - Fork 493
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ct): introduce runtime password changing
A new init script allows to set passwords at boot time of the container. If the passwords are not changed, there will be warnings logged about the default in use. Slightly modifying the startInForeground.sh script to avoid keeping password files or sensitive passwords around after starting the server.
- Loading branch information
1 parent
db802f8
commit 4073d6c
Showing
2 changed files
with
59 additions
and
14 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
modules/container-base/src/main/docker/scripts/init_1_change_passwords.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
# NOTE: ALL PASSWORD ENV VARS WILL BE SCRAMBLED IN startInForeground.sh FOR SECURITY! | ||
# This is to avoid possible attack vectors where someone could extract the sensitive information | ||
# from within an env var dump inside an application! | ||
|
||
# Someone set the env var for passwords - get the new password in. Otherwise print warning. | ||
# https://docs.openshift.com/container-platform/4.14/openshift_images/create-images.html#avoid-default-passwords | ||
if [ "$LINUX_USER_PASSWORD" != "payara" ]; then | ||
echo -e "payara\n$LINUX_USER_PASSWORD\n$LINUX_USER_PASSWORD" | passwd | ||
else | ||
echo "IMPORTANT: THIS CONTAINER USES THE DEFAULT PASSWORD FOR USER payara! ('payara')" | ||
echo " To change the password, set the LINUX_USER_PASSWORD env var." | ||
fi | ||
|
||
# Change the domain admin password if necessary | ||
if [ "$ADMIN_PASSWORD" != "admin" ]; then | ||
PASSWORD_FILE=$(mktemp) | ||
echo "AS_ADMIN_PASSWORD=admin" > "$PASSWORD_FILE" | ||
echo "AS_ADMIN_NEWPASSWORD=${ADMIN_PASSWORD}" >> "$PASSWORD_FILE" | ||
asadmin --user="${ADMIN_USER}" --passwordfile="$PASSWORD_FILE" change-admin-password --domain_name="${DOMAIN_NAME}" | ||
rm "$PASSWORD_FILE" | ||
else | ||
echo "IMPORTANT: THIS CONTAINER USES THE DEFAULT PASSWORD FOR PAYARA ASADMIN! ('admin')" | ||
echo " To change the password, set the ADMIN_PASSWORD env var." | ||
fi | ||
|
||
# Change the domain master password if necessary | ||
# > The master password is not tied to a user account, and it is not used for authentication. | ||
# > Instead, Payara Server strictly uses the master password to ONLY encrypt the keystore and truststore used to store keys and certificates for the DAS and instances usage. | ||
# It will be requested when booting the application server! | ||
# https://docs.payara.fish/community/docs/Technical%20Documentation/Payara%20Server%20Documentation/Security%20Guide/Administering%20System%20Security.html#to-change-the-master-password | ||
if [ "$DOMAIN_MASTER_PASSWORD" != "changeit" ]; then | ||
PASSWORD_FILE=$(mktemp) | ||
echo "AS_ADMIN_MASTERPASSWORD=changeit" >> "$PASSWORD_FILE" | ||
echo "AS_ADMIN_NEWMASTERPASSWORD=${DOMAIN_MASTER_PASSWORD}" >> "$PASSWORD_FILE" | ||
asadmin --user="${ADMIN_USER}" --passwordfile="$PASSWORD_FILE" change-master-password --savemasterpassword false "${DOMAIN_NAME}" | ||
rm "$PASSWORD_FILE" | ||
else | ||
echo "IMPORTANT: THIS CONTAINER USES THE DEFAULT MASTER PASSWORD FOR THE DOMAIN! ('changeit')" | ||
echo " To change the password, set the DOMAIN_MASTER_PASSWORD env var." | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters