Add a new config variable - ALLOW_SPECIAL_EMAIL_DOMAINS to allow special domains for pgAdmin user emails. #6222

This commit is contained in:
Aditya Toshniwal 2024-09-19 10:51:06 +05:30
parent 38d4728333
commit 53cdc80df2
3 changed files with 12 additions and 0 deletions

View File

@ -21,6 +21,7 @@ New features
************
| `Issue #1900 <https://github.com/pgadmin-org/pgadmin4/issues/1900>`_ - Added feature to restore preferences to their default values.
| `Issue #6222 <https://github.com/pgadmin-org/pgadmin4/issues/6222>`_ - Add a new config variable - ALLOW_SPECIAL_EMAIL_DOMAINS to allow special domains for pgAdmin user emails.
| `Issue #7293 <https://github.com/pgadmin-org/pgadmin4/issues/7293>`_ - Allow running non-continuous selected SQL code blocks in the query tool.
Housekeeping

View File

@ -400,6 +400,7 @@ SECURITY_EMAIL_SUBJECT_PASSWORD_CHANGE_NOTICE = \
CHECK_EMAIL_DELIVERABILITY = False
SECURITY_EMAIL_VALIDATOR_ARGS = \
{"check_deliverability": CHECK_EMAIL_DELIVERABILITY}
ALLOW_SPECIAL_EMAIL_DOMAINS = []
##########################################################################
# Upgrade checks

View File

@ -10,6 +10,7 @@
import os
import sys
import keyring
import email_validator
# User configs loaded from config_local, config_distro etc.
custom_config_settings = {}
@ -136,4 +137,13 @@ def evaluate_and_patch_config(config: dict) -> dict:
'SESSION_COOKIE_PATH': os.environ["SCRIPT_NAME"],
}))
# Allow special email domains
try:
email_validator.SPECIAL_USE_DOMAIN_NAMES = [
d for d in email_validator.SPECIAL_USE_DOMAIN_NAMES
if d not in config.get('ALLOW_SPECIAL_EMAIL_DOMAINS', [])
]
except Exception:
pass
return config