-
Notifications
You must be signed in to change notification settings - Fork 963
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: check MX records against prohibited domains #16596
feat: check MX records against prohibited domains #16596
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm worried that this is going to have unintended side effects in combination with #16586.
For instance:
$ dig microsoft.com MX +short
10 microsoft-com.mail.protection.outlook.com.
And we have outlook.com
on our prohibited domains list, which I think means we will bar @microsoft.com and other domains with outlook hosted mail from registering?
Yeah, it seems applying: diff --git a/tests/unit/manage/test_forms.py b/tests/unit/manage/test_forms.py
index 6250fbb6e..22bfd934d 100644
--- a/tests/unit/manage/test_forms.py
+++ b/tests/unit/manage/test_forms.py
@@ -247,7 +247,7 @@ class TestAddEmailForm:
Simulate that `mail.net` handles emails sent to `wutang.net`.
"""
- mock_deliverability_info = {"mx": [(10, "mail.net")]}
+ mock_deliverability_info = {"mx": [(10, "microsoft-com.mail.protection.outlook.com.")]}
def mock_function(*args, **kwargs):
return mock_deliverability_info
@@ -257,12 +257,12 @@ class TestAddEmailForm:
mock_function,
)
- prohibited_mx_domain = ProhibitedEmailDomain(domain="mail.net")
+ prohibited_mx_domain = ProhibitedEmailDomain(domain="outlook.com")
db_request.db.add(prohibited_mx_domain)
form = forms.AddEmailForm(
request=db_request,
- formdata=MultiDict({"email": "foo@wutang.net"}),
+ formdata=MultiDict({"email": "foo@microsoft.com"}),
user_service=pretend.stub(find_userid_by_email=lambda _: None),
user_id=pretend.stub(),
) still passes test (aka blocks the address). |
Thanks for poking at it! |
8859b6f
to
3afbd37
Compare
We get `email-validator` from `wtforms`, but use it explicitly in our own code, so declare it a direct dependency in case `wtforms` ever drops it. Refs: pypi#15631 Signed-off-by: Mike Fiedler <miketheman@gmail.com>
3afbd37
to
14daa50
Compare
Using the `email-validator` package, which is already part of `wtforms`'s dependencies, check if the domain is actually deliverable prior to accepting the address. Deliverability check produces the MX records in the response. Use them to check against the Prohibited Domains lists. Signed-off-by: Mike Fiedler <miketheman@gmail.com>
Signed-off-by: Mike Fiedler <miketheman@gmail.com>
14daa50
to
777b356
Compare
Signed-off-by: Mike Fiedler <miketheman@gmail.com>
Signed-off-by: Mike Fiedler <miketheman@gmail.com>
Using the
email-validator
package, which is already part ofwtforms
's dependencies, check if the domain is actually deliverable prior to accepting the address.Deliverability check produces the MX records in the response.
Use them to check against the Prohibited Domains lists.
Resolves: #16136