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

Commit 2341032

Browse files
jejo86DMRobertson
andauthored
Document advising against publicly exposing the Admin API and provide a usage example (#13231)
* Admin API request explanation improved Pointed out, that the Admin API is not accessible by default from any remote computer, but only from the PC `matrix-synapse` is running on. Added a full, working example, making sure to include the cURL flag `-X`, which needs to be prepended to `GET`, `POST`, `PUT` etc. and listing the full query string including protocol, IP address and port. * Admin API request explanation improved * Apply suggestions from code review Update changelog. Reword prose. Co-authored-by: David Robertson <[email protected]>
1 parent 982fe29 commit 2341032

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

changelog.d/13231.doc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Provide an example of using the Admin API. Contributed by @jejo86.

docs/usage/administration/admin_api/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,29 @@ already on your `$PATH` depending on how Synapse was installed.
1818
Finding your user's `access_token` is client-dependent, but will usually be shown in the client's settings.
1919

2020
## Making an Admin API request
21+
For security reasons, we [recommend](reverse_proxy.md#synapse-administration-endpoints)
22+
that the Admin API (`/_synapse/admin/...`) should be hidden from public view using a
23+
reverse proxy. This means you should typically query the Admin API from a terminal on
24+
the machine which runs Synapse.
25+
2126
Once you have your `access_token`, you will need to authenticate each request to an Admin API endpoint by
2227
providing the token as either a query parameter or a request header. To add it as a request header in cURL:
2328

2429
```sh
2530
curl --header "Authorization: Bearer <access_token>" <the_rest_of_your_API_request>
2631
```
2732

33+
For example, suppose we want to
34+
[query the account](user_admin_api.md#query-user-account) of the user
35+
`@foo:bar.com`. We need an admin access token (e.g.
36+
`syt_AjfVef2_L33JNpafeif_0feKJfeaf0CQpoZk`), and we need to know which port
37+
Synapse's [`client` listener](config_documentation.md#listeners) is listening
38+
on (e.g. `8008`). Then we can use the following command to request the account
39+
information from the Admin API.
40+
41+
```sh
42+
curl --header "Authorization: Bearer syt_AjfVef2_L33JNpafeif_0feKJfeaf0CQpoZk" -X GET http://127.0.0.1:8008/_synapse/admin/v2/users/@foo:bar.com
43+
```
44+
2845
For more details on access tokens in Matrix, please refer to the complete
2946
[matrix spec documentation](https://matrix.org/docs/spec/client_server/r0.6.1#using-access-tokens).

0 commit comments

Comments
 (0)