1 files changed, 12 insertions, 1 deletions
diff --git a/synapse/util/threepids.py b/synapse/util/threepids.py
index 389adf00f6..1e9c2faa64 100644
--- a/synapse/util/threepids.py
+++ b/synapse/util/threepids.py
@@ -32,7 +32,12 @@ logger = logging.getLogger(__name__)
MAX_EMAIL_ADDRESS_LENGTH = 500
-def check_3pid_allowed(hs: "HomeServer", medium: str, address: str) -> bool:
+async def check_3pid_allowed(
+ hs: "HomeServer",
+ medium: str,
+ address: str,
+ registration: bool = False,
+) -> bool:
"""Checks whether a given format of 3PID is allowed to be used on this HS
Args:
@@ -40,9 +45,15 @@ def check_3pid_allowed(hs: "HomeServer", medium: str, address: str) -> bool:
medium: 3pid medium - e.g. email, msisdn
address: address within that medium (e.g. "wotan@matrix.org")
msisdns need to first have been canonicalised
+ registration: whether we want to bind the 3PID as part of registering a new user.
+
Returns:
bool: whether the 3PID medium/address is allowed to be added to this HS
"""
+ if not await hs.get_password_auth_provider().is_3pid_allowed(
+ medium, address, registration
+ ):
+ return False
if hs.config.registration.allowed_local_3pids:
for constraint in hs.config.registration.allowed_local_3pids:
|