forked from MirrorHub/synapse
Merge pull request #4435 from matrix-org/neilj/fix_threepid_auth_check
Neilj/fix threepid auth check
This commit is contained in:
commit
10b89d5c2e
5 changed files with 16 additions and 9 deletions
1
changelog.d/4435.bugfix
Normal file
1
changelog.d/4435.bugfix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Fix None guard in calling config.server.is_threepid_reserved
|
|
@ -819,7 +819,9 @@ class Auth(object):
|
||||||
elif threepid:
|
elif threepid:
|
||||||
# If the user does not exist yet, but is signing up with a
|
# If the user does not exist yet, but is signing up with a
|
||||||
# reserved threepid then pass auth check
|
# reserved threepid then pass auth check
|
||||||
if is_threepid_reserved(self.hs.config, threepid):
|
if is_threepid_reserved(
|
||||||
|
self.hs.config.mau_limits_reserved_threepids, threepid
|
||||||
|
):
|
||||||
return
|
return
|
||||||
# Else if there is no room in the MAU bucket, bail
|
# Else if there is no room in the MAU bucket, bail
|
||||||
current_mau = yield self.store.get_monthly_active_count()
|
current_mau = yield self.store.get_monthly_active_count()
|
||||||
|
|
|
@ -424,19 +424,18 @@ class ServerConfig(Config):
|
||||||
" service on the given port.")
|
" service on the given port.")
|
||||||
|
|
||||||
|
|
||||||
def is_threepid_reserved(config, threepid):
|
def is_threepid_reserved(reserved_threepids, threepid):
|
||||||
"""Check the threepid against the reserved threepid config
|
"""Check the threepid against the reserved threepid config
|
||||||
Args:
|
Args:
|
||||||
config(ServerConfig) - to access server config attributes
|
reserved_threepids([dict]) - list of reserved threepids
|
||||||
threepid(dict) - The threepid to test for
|
threepid(dict) - The threepid to test for
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
boolean Is the threepid undertest reserved_user
|
boolean Is the threepid undertest reserved_user
|
||||||
"""
|
"""
|
||||||
|
|
||||||
for tp in config.mau_limits_reserved_threepids:
|
for tp in reserved_threepids:
|
||||||
if (threepid['medium'] == tp['medium']
|
if (threepid['medium'] == tp['medium'] and threepid['address'] == tp['address']):
|
||||||
and threepid['address'] == tp['address']):
|
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -416,8 +416,11 @@ class RegisterRestServlet(RestServlet):
|
||||||
)
|
)
|
||||||
# Necessary due to auth checks prior to the threepid being
|
# Necessary due to auth checks prior to the threepid being
|
||||||
# written to the db
|
# written to the db
|
||||||
if is_threepid_reserved(self.hs.config, threepid):
|
if threepid:
|
||||||
yield self.store.upsert_monthly_active_user(registered_user_id)
|
if is_threepid_reserved(
|
||||||
|
self.hs.config.mau_limits_reserved_threepids, threepid
|
||||||
|
):
|
||||||
|
yield self.store.upsert_monthly_active_user(registered_user_id)
|
||||||
|
|
||||||
# remember that we've now registered that user account, and with
|
# remember that we've now registered that user account, and with
|
||||||
# what user ID (since the user may not have specified)
|
# what user ID (since the user may not have specified)
|
||||||
|
|
|
@ -154,7 +154,9 @@ def default_config(name):
|
||||||
config.update_user_directory = False
|
config.update_user_directory = False
|
||||||
|
|
||||||
def is_threepid_reserved(threepid):
|
def is_threepid_reserved(threepid):
|
||||||
return ServerConfig.is_threepid_reserved(config, threepid)
|
return ServerConfig.is_threepid_reserved(
|
||||||
|
config.mau_limits_reserved_threepids, threepid
|
||||||
|
)
|
||||||
|
|
||||||
config.is_threepid_reserved.side_effect = is_threepid_reserved
|
config.is_threepid_reserved.side_effect = is_threepid_reserved
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue