summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2018-08-09 10:38:34 +0100
committerRichard van der Hoff <richard@matrix.org>2018-08-09 10:38:34 +0100
commit9ac9a9ab1020ec4bf395ccf3e07ba6192f6ac558 (patch)
treebb95bcef8f38a23f9b53f5e9707035c628229ab2 /docs
parentef2188c1bfd532ddc2e4c1acb533b422afde6c57 (diff)
Imported Upstream version 0.33.2
Diffstat (limited to 'docs')
-rw-r--r--docs/admin_api/register_api.rst63
-rw-r--r--docs/workers.rst4
2 files changed, 67 insertions, 0 deletions
diff --git a/docs/admin_api/register_api.rst b/docs/admin_api/register_api.rst
new file mode 100644
index 00000000..209cd140
--- /dev/null
+++ b/docs/admin_api/register_api.rst
@@ -0,0 +1,63 @@
+Shared-Secret Registration
+==========================
+
+This API allows for the creation of users in an administrative and
+non-interactive way. This is generally used for bootstrapping a Synapse
+instance with administrator accounts.
+
+To authenticate yourself to the server, you will need both the shared secret
+(``registration_shared_secret`` in the homeserver configuration), and a
+one-time nonce. If the registration shared secret is not configured, this API
+is not enabled.
+
+To fetch the nonce, you need to request one from the API::
+
+ > GET /_matrix/client/r0/admin/register
+
+ < {"nonce": "thisisanonce"}
+
+Once you have the nonce, you can make a ``POST`` to the same URL with a JSON
+body containing the nonce, username, password, whether they are an admin
+(optional, False by default), and a HMAC digest of the content.
+
+As an example::
+
+ > POST /_matrix/client/r0/admin/register
+ > {
+ "nonce": "thisisanonce",
+ "username": "pepper_roni",
+ "password": "pizza",
+ "admin": true,
+ "mac": "mac_digest_here"
+ }
+
+ < {
+ "access_token": "token_here",
+ "user_id": "@pepper_roni@test",
+ "home_server": "test",
+ "device_id": "device_id_here"
+ }
+
+The MAC is the hex digest output of the HMAC-SHA1 algorithm, with the key being
+the shared secret and the content being the nonce, user, password, and either
+the string "admin" or "notadmin", each separated by NULs. For an example of
+generation in Python::
+
+ import hmac, hashlib
+
+ def generate_mac(nonce, user, password, admin=False):
+
+ mac = hmac.new(
+ key=shared_secret,
+ digestmod=hashlib.sha1,
+ )
+
+ mac.update(nonce.encode('utf8'))
+ mac.update(b"\x00")
+ mac.update(user.encode('utf8'))
+ mac.update(b"\x00")
+ mac.update(password.encode('utf8'))
+ mac.update(b"\x00")
+ mac.update(b"admin" if admin else b"notadmin")
+
+ return mac.hexdigest()
diff --git a/docs/workers.rst b/docs/workers.rst
index 1d521b9e..c5b37c3d 100644
--- a/docs/workers.rst
+++ b/docs/workers.rst
@@ -206,6 +206,10 @@ Handles client API endpoints. It can handle REST endpoints matching the
following regular expressions::
^/_matrix/client/(api/v1|r0|unstable)/publicRooms$
+ ^/_matrix/client/(api/v1|r0|unstable)/rooms/.*/joined_members$
+ ^/_matrix/client/(api/v1|r0|unstable)/rooms/.*/context/.*$
+ ^/_matrix/client/(api/v1|r0|unstable)/rooms/.*/members$
+ ^/_matrix/client/(api/v1|r0|unstable)/rooms/.*/state$
``synapse.app.user_dir``
~~~~~~~~~~~~~~~~~~~~~~~~