Fixed Docker image entrypoint.sh email validation. #8410

Introduces a GLOBALLY_DELIVERABLE variable so that it can be passed to the email validator library
and ultimately allowing the email admin@localhost to be valid, as long as False is passed in.

Also:
* Adjusted the indentation of a command above it in the entrypoint.sh
* Added printing out the output of the validation library so that we can better find what the actual issue is
This commit is contained in:
Igor Serko
2025-02-07 07:04:23 +00:00
committed by GitHub
parent 0b46bdf901
commit ae76ea3585
2 changed files with 12 additions and 2 deletions

View File

@@ -87,11 +87,16 @@ if [ ! -f /var/lib/pgadmin/pgadmin4.db ] && [ "${external_config_db_exists}" = "
if [ -n "${PGADMIN_CONFIG_ALLOW_SPECIAL_EMAIL_DOMAINS}" ]; then
ALLOW_SPECIAL_EMAIL_DOMAINS=${PGADMIN_CONFIG_ALLOW_SPECIAL_EMAIL_DOMAINS}
fi
email_config="{'CHECK_EMAIL_DELIVERABILITY': ${CHECK_EMAIL_DELIVERABILITY}, 'ALLOW_SPECIAL_EMAIL_DOMAINS': ${ALLOW_SPECIAL_EMAIL_DOMAINS}}"
echo "email config is ${email_config}"
GLOBALLY_DELIVERABLE="True"
if [ -n "${PGADMIN_CONFIG_GLOBALLY_DELIVERABLE}" ]; then
GLOBALLY_DELIVERABLE=${PGADMIN_CONFIG_GLOBALLY_DELIVERABLE}
fi
email_config="{'CHECK_EMAIL_DELIVERABILITY': ${CHECK_EMAIL_DELIVERABILITY}, 'ALLOW_SPECIAL_EMAIL_DOMAINS': ${ALLOW_SPECIAL_EMAIL_DOMAINS}, 'GLOBALLY_DELIVERABLE': ${GLOBALLY_DELIVERABLE}}"
echo "email config is ${email_config}"
is_valid_email=$(cd /pgadmin4/pgadmin/utils && /venv/bin/python3 -c "from validation_utils import validate_email; val = validate_email('${PGADMIN_DEFAULT_EMAIL}', ${email_config}); print(val)")
if echo "${is_valid_email}" | grep "False" > /dev/null; then
echo "'${PGADMIN_DEFAULT_EMAIL}' does not appear to be a valid email address. Please reset the PGADMIN_DEFAULT_EMAIL environment variable and try again."
echo "Validation output: ${is_valid_email}"
exit 1
fi
# Switch back to root directory for further process

View File

@@ -21,6 +21,8 @@ def validate_email(email, email_config=None):
config.CHECK_EMAIL_DELIVERABILITY
email_config['ALLOW_SPECIAL_EMAIL_DOMAINS'] = \
config.ALLOW_SPECIAL_EMAIL_DOMAINS
email_config["GLOBALLY_DELIVERABLE"] = \
config.GLOBALLY_DELIVERABLE
# Allow special email domains
if isinstance(email_config['ALLOW_SPECIAL_EMAIL_DOMAINS'], str):
@@ -35,6 +37,9 @@ def validate_email(email, email_config=None):
except Exception:
pass
email_validator.GLOBALLY_DELIVERABLE = \
email_config["GLOBALLY_DELIVERABLE"]
# Validate.
_ = email_validate(
email,