Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

/search_users admin API is undocumented #16443

Open
clokep opened this issue Oct 6, 2023 · 0 comments
Open

/search_users admin API is undocumented #16443

clokep opened this issue Oct 6, 2023 · 0 comments
Labels
A-Admin-API A-Docs things relating to the documentation T-Task Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks.

Comments

@clokep
Copy link
Member

clokep commented Oct 6, 2023

I'm not sure if this was done on purpose, but if so we should note that and deprecate it:

class SearchUsersRestServlet(RestServlet):
"""Get request to search user table for specific users according to
search term.
This needs user to have administrator access in Synapse.
Example:
http://localhost:8008/_synapse/admin/v1/search_users/
@admin:user?access_token=admin_access_token&term=alice
Returns:
200 OK with json object {list[dict[str, Any]], count} or empty object.
"""
PATTERNS = admin_patterns("/search_users/(?P<target_user_id>[^/]*)$")
def __init__(self, hs: "HomeServer"):
self.store = hs.get_datastores().main
self.auth = hs.get_auth()
self.is_mine = hs.is_mine
async def on_GET(
self, request: SynapseRequest, target_user_id: str
) -> Tuple[int, Optional[List[JsonDict]]]:
"""Get request to search user table for specific users according to
search term.
This needs user to have a administrator access in Synapse.
"""
await assert_requester_is_admin(self.auth, request)
target_user = UserID.from_string(target_user_id)
# To allow all users to get the users list
# if not is_admin and target_user != auth_user:
# raise AuthError(HTTPStatus.FORBIDDEN, "You are not a server admin")
if not self.is_mine(target_user):
raise SynapseError(HTTPStatus.BAD_REQUEST, "Can only users a local user")
term = parse_string(request, "term", required=True)
logger.info("term: %s ", term)
ret = await self.store.search_users(term)
results = [
{
"name": name,
"password_hash": password_hash,
"is_guest": is_guest,
"admin": admin,
"user_type": user_type,
}
for name, password_hash, is_guest, admin, user_type in ret
]
return HTTPStatus.OK, results

@clokep clokep added A-Docs things relating to the documentation A-Admin-API T-Task Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks. labels Oct 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Admin-API A-Docs things relating to the documentation T-Task Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks.
Projects
None yet
Development

No branches or pull requests

1 participant