Admin API: worker support for Query User Account (#19281)
This commit is contained in:
committed by
GitHub
parent
3989d22a37
commit
f4320b5a49
1
changelog.d/19281.feature
Normal file
1
changelog.d/19281.feature
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Admin API: add worker support to `GET /_synapse/admin/v2/users/<user_id>`.
|
||||||
@@ -255,6 +255,8 @@ information.
|
|||||||
^/_matrix/client/(api/v1|r0|v3|unstable)/directory/room/.*$
|
^/_matrix/client/(api/v1|r0|v3|unstable)/directory/room/.*$
|
||||||
^/_matrix/client/(r0|v3|unstable)/capabilities$
|
^/_matrix/client/(r0|v3|unstable)/capabilities$
|
||||||
^/_matrix/client/(r0|v3|unstable)/notifications$
|
^/_matrix/client/(r0|v3|unstable)/notifications$
|
||||||
|
|
||||||
|
# Admin API requests
|
||||||
^/_synapse/admin/v1/rooms/[^/]+$
|
^/_synapse/admin/v1/rooms/[^/]+$
|
||||||
|
|
||||||
# Encryption requests
|
# Encryption requests
|
||||||
@@ -300,6 +302,9 @@ Additionally, the following REST endpoints can be handled for GET requests:
|
|||||||
# Presence requests
|
# Presence requests
|
||||||
^/_matrix/client/(api/v1|r0|v3|unstable)/presence/
|
^/_matrix/client/(api/v1|r0|v3|unstable)/presence/
|
||||||
|
|
||||||
|
# Admin API requests
|
||||||
|
^/_synapse/admin/v2/users/[^/]+$
|
||||||
|
|
||||||
Pagination requests can also be handled, but all requests for a given
|
Pagination requests can also be handled, but all requests for a given
|
||||||
room must be routed to the same instance. Additionally, care must be taken to
|
room must be routed to the same instance. Additionally, care must be taken to
|
||||||
ensure that the purge history admin API is not used while pagination requests
|
ensure that the purge history admin API is not used while pagination requests
|
||||||
|
|||||||
@@ -119,6 +119,7 @@ from synapse.rest.admin.users import (
|
|||||||
UserRegisterServlet,
|
UserRegisterServlet,
|
||||||
UserReplaceMasterCrossSigningKeyRestServlet,
|
UserReplaceMasterCrossSigningKeyRestServlet,
|
||||||
UserRestServletV2,
|
UserRestServletV2,
|
||||||
|
UserRestServletV2Get,
|
||||||
UsersRestServletV2,
|
UsersRestServletV2,
|
||||||
UsersRestServletV3,
|
UsersRestServletV3,
|
||||||
UserTokenRestServlet,
|
UserTokenRestServlet,
|
||||||
@@ -281,6 +282,8 @@ def register_servlets(hs: "HomeServer", http_server: HttpServer) -> None:
|
|||||||
# matrix_authentication_service integration uses the dedicated MAS API.
|
# matrix_authentication_service integration uses the dedicated MAS API.
|
||||||
if hs.config.experimental.msc3861.enabled:
|
if hs.config.experimental.msc3861.enabled:
|
||||||
register_servlets_for_msc3861_delegation(hs, http_server)
|
register_servlets_for_msc3861_delegation(hs, http_server)
|
||||||
|
else:
|
||||||
|
UserRestServletV2Get(hs).register(http_server)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ class UsersRestServletV3(UsersRestServletV2):
|
|||||||
return parse_boolean(request, "deactivated")
|
return parse_boolean(request, "deactivated")
|
||||||
|
|
||||||
|
|
||||||
class UserRestServletV2(RestServlet):
|
class UserRestServletV2Get(RestServlet):
|
||||||
PATTERNS = admin_patterns("/users/(?P<user_id>[^/]*)$", "v2")
|
PATTERNS = admin_patterns("/users/(?P<user_id>[^/]*)$", "v2")
|
||||||
|
|
||||||
"""Get request to list user details.
|
"""Get request to list user details.
|
||||||
@@ -220,22 +220,6 @@ class UserRestServletV2(RestServlet):
|
|||||||
|
|
||||||
returns:
|
returns:
|
||||||
200 OK with user details if success otherwise an error.
|
200 OK with user details if success otherwise an error.
|
||||||
|
|
||||||
Put request to allow an administrator to add or modify a user.
|
|
||||||
This needs user to have administrator access in Synapse.
|
|
||||||
We use PUT instead of POST since we already know the id of the user
|
|
||||||
object to create. POST could be used to create guests.
|
|
||||||
|
|
||||||
PUT /_synapse/admin/v2/users/<user_id>
|
|
||||||
{
|
|
||||||
"password": "secret",
|
|
||||||
"displayname": "User"
|
|
||||||
}
|
|
||||||
|
|
||||||
returns:
|
|
||||||
201 OK with new user object if user was created or
|
|
||||||
200 OK with modified user object if user was modified
|
|
||||||
otherwise an error.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, hs: "HomeServer"):
|
def __init__(self, hs: "HomeServer"):
|
||||||
@@ -267,6 +251,28 @@ class UserRestServletV2(RestServlet):
|
|||||||
|
|
||||||
return HTTPStatus.OK, user_info_dict
|
return HTTPStatus.OK, user_info_dict
|
||||||
|
|
||||||
|
|
||||||
|
class UserRestServletV2(UserRestServletV2Get):
|
||||||
|
"""
|
||||||
|
Put request to allow an administrator to add or modify a user.
|
||||||
|
This needs user to have administrator access in Synapse.
|
||||||
|
We use PUT instead of POST since we already know the id of the user
|
||||||
|
object to create. POST could be used to create guests.
|
||||||
|
|
||||||
|
Note: This inherits from `UserRestServletV2Get`, so also supports the `GET` route.
|
||||||
|
|
||||||
|
PUT /_synapse/admin/v2/users/<user_id>
|
||||||
|
{
|
||||||
|
"password": "secret",
|
||||||
|
"displayname": "User"
|
||||||
|
}
|
||||||
|
|
||||||
|
returns:
|
||||||
|
201 OK with new user object if user was created or
|
||||||
|
200 OK with modified user object if user was modified
|
||||||
|
otherwise an error.
|
||||||
|
"""
|
||||||
|
|
||||||
async def on_PUT(
|
async def on_PUT(
|
||||||
self, request: SynapseRequest, user_id: str
|
self, request: SynapseRequest, user_id: str
|
||||||
) -> tuple[int, JsonMapping]:
|
) -> tuple[int, JsonMapping]:
|
||||||
|
|||||||
Reference in New Issue
Block a user