summary refs log tree commit diff
path: root/scripts
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-07-05 17:18:19 +0100
committerErik Johnston <erik@matrix.org>2016-07-05 17:18:19 +0100
commitcaf33b2d9be1b992098a00ee61cf4b4009ee3a09 (patch)
tree4f72f239e27c548ff704b4f120cf629192e4b70f /scripts
parentMerge pull request #904 from matrix-org/dbkr/register_email_no_untrusted_id_s... (diff)
downloadsynapse-caf33b2d9be1b992098a00ee61cf4b4009ee3a09.tar.xz
Protect password when registering using shared secret
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/register_new_matrix_user11
1 files changed, 8 insertions, 3 deletions
diff --git a/scripts/register_new_matrix_user b/scripts/register_new_matrix_user
index 27a6250b14..6d055fd012 100755
--- a/scripts/register_new_matrix_user
+++ b/scripts/register_new_matrix_user
@@ -25,12 +25,17 @@ import urllib2
 import yaml
 
 
-def request_registration(user, password, server_location, shared_secret):
+def request_registration(user, password, server_location, shared_secret, admin=False):
     mac = hmac.new(
         key=shared_secret,
-        msg=user,
         digestmod=hashlib.sha1,
-    ).hexdigest()
+    )
+
+    mac.update(user)
+    mac.update(password)
+    mac.update("admin" if admin else "notadmin")
+
+    mac = mac.hexdigest()
 
     data = {
         "user": user,