Skip to content
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

[DINSIC] Use internal-info for identity server #4681

Merged
merged 4 commits into from Feb 28, 2019
Merged
Diff settings

Always

Just for now

@@ -55,7 +55,7 @@ def on_POST(self, request):
if not (yield check_3pid_allowed(self.hs, "email", body['email'])):
raise SynapseError(
403,
"Your email domain is not authorized on this server",
"Your email is not authorized on this server",
Codes.THREEPID_DENIED,
)

@@ -271,7 +271,7 @@ def on_POST(self, request):
if not (yield check_3pid_allowed(self.hs, "email", body['email'])):
raise SynapseError(
403,
"Your email domain is not authorized on this server",
"Your email is not authorized on this server",
Codes.THREEPID_DENIED,
)

@@ -78,7 +78,7 @@ def on_POST(self, request):
if not (yield check_3pid_allowed(self.hs, "email", body['email'])):
raise SynapseError(
403,
"Your email domain is not authorized to register on this server",
"Your email is not authorized to register on this server",
Codes.THREEPID_DENIED,
)

Copy path View file
@@ -23,7 +23,7 @@

@defer.inlineCallbacks
def check_3pid_allowed(hs, medium, address):
"""Checks whether a given format of 3PID is allowed to be used on this HS
"""Checks whether a given 3PID is allowed to be used on this HS
Args:
hs (synapse.server.HomeServer): server
@@ -38,10 +38,18 @@ def check_3pid_allowed(hs, medium, address):
data = yield hs.get_simple_http_client().get_json(
"https://%s%s" % (
hs.config.check_is_for_allowed_local_3pids,
"/_matrix/identity/api/v1/info"
"/_matrix/identity/api/v1/internal-info"
),
{'medium': medium, 'address': address}
)

# Assume false if invalid response
if 'hs' not in data:
defer.returnValue(False)

if data.get('requires_invite', False) and data.get('invited', False) == False:
This conversation was marked as resolved by anoadragon453

This comment has been minimized.

Copy link
@richvdh

richvdh Feb 25, 2019

Member

This is not very idiomatic, and is a bit confusing.

Suggested change
if data.get('requires_invite', False) and data.get('invited', False) == False:
if data.get('requires_invite', False) and not data.get('invited', False):
# Requires an invite but hasn't been invited
defer.returnValue(False)
if hs.config.allow_invited_3pids and data.get('invited'):
defer.returnValue(True)
else:
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.