Replace also_allow_user with a global config option

Basically reverts 088977f676.

This way is more suitable for self-hosting where there's no gateway to
manage the query parameter.
This commit is contained in:
Tulir Asokan 2021-10-30 14:06:15 +03:00
parent cf45cfd314
commit dbafb7c906
7 changed files with 20 additions and 27 deletions

View file

@ -244,7 +244,7 @@ class Auth:
raise MissingClientTokenError()
async def validate_appservice_can_control_user_id(
self, app_service: ApplicationService, user_id: str, also_allow_user: Optional[str] = None
self, app_service: ApplicationService, user_id: str, allow_any: bool = False
) -> None:
"""Validates that the app service is allowed to control
the given user.
@ -252,7 +252,7 @@ class Auth:
Args:
app_service: The app service that controls the user
user_id: The author MXID that the app service is controlling
also_allow_user: An additional user ID that the appservice can temporarily control
allow_any: Allow the appservice to control any local user
Raises:
AuthError: If the application service is not allowed to control the user
@ -264,7 +264,7 @@ class Auth:
if app_service.sender == user_id:
pass
# Check to make sure the app service is allowed to control the user
elif not app_service.is_interested_in_user(user_id) and user_id != also_allow_user:
elif not app_service.is_interested_in_user(user_id) and not allow_any:
raise AuthError(
403,
"Application service cannot masquerade as this user (%s)." % user_id,