Requests
ASP.NET Core minimal APIs, one Map… extension per spec area in Endpoints/. Each endpoint reads the request, calls a service and returns JSON.
MatrixHttp.HandleAsyncwraps every request: CORS headers, and standard errors from exceptions. AMatrixExceptionbecomes its status anderrcode;MatrixErrorExceptionadds fields such ascurrent_version;AuthenticationRequiredExceptionanswers 401 with the user-interactive auth flows; bad JSON becomesM_BAD_JSONorM_NOT_JSON; unknown pathsM_UNRECOGNIZED.RequireAccessToken()on a route group checks the token from theAuthorizationheader (or the deprecatedaccess_tokenquery parameter); handlers get the user withhttp.GetRequester(), orhttp.GetOwnRequester(userId)for endpoints that take a user ID and must refuse other users.- The
Requestercarries the account's admin, suspended and locked flags. A locked account is refused withM_USER_LOCKEDandsoft_logouton every request but logging out.RejectSuspended()refuses suspended accounts withM_USER_SUSPENDEDon sending, joining, inviting, creating rooms, profile changes and uploads.RequireAdmin()guardsAdminEndpoints, which serve the spec's whois, suspend and lock and a subset of Synapse's admin API at its paths. - Requests through the local admin socket need no access token:
AdminSocketmarks the socket's connections, and they act as an admin without an account. File permissions decide who may open the socket.ManagementEndpointsanswer only there, foruniform-chat-server manage: the status with the counters and the server's files, and the settings, read with their sources, applied live and saved by the server. They take known options that are not secret, with valid values; elsewhere they answer as unknown. - Access tokens are stored as SHA-256 hashes, so a leaked database does not leak sessions.