diff --git a/.gitignore b/.gitignore index 69de59258f867a8400a850f2561ca47ff1b73f59..78460282dbda11654349c43ece5625ee9084a326 100644 --- a/.gitignore +++ b/.gitignore @@ -8,5 +8,7 @@ node_modules terraform/.holi-terraform.key dist .envrc.local +.env +.env.local coverage/ *.zip diff --git a/create-matrix-admin.sh b/create-matrix-admin.sh new file mode 100755 index 0000000000000000000000000000000000000000..72e63c655a34eaeb7a986164bf32b774a72a734c --- /dev/null +++ b/create-matrix-admin.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# This file contains shell commands that are needed to create an admin for Matrix Chat +# which is needed to set up a working local dev environment for this project. + +URL="http://127.0.0.1:8008/_synapse/admin/v1/register" +username="admin" +password="admin" +admin=true +secret=MATRIX_ADMIN_SECRET + +# 1. Get Nonce +response=$(curl -s $URL) +nonce=$(jq -r ".nonce" <<<"$response") +echo "Nonce: $nonce" + +# 2. Generate HMAC +hmac=$( + echo "$nonce" "$username" "$password" "$admin" | + openssl sha1 -hmac "$secret" | + awk '{print $2}' +) +echo "HMAC: $hmac" + +# 2. Create Matrix Admin +res=$( + curl -s $URL -X POST \ + -H "Content-Type: application/json" \ + -d "{ \"nonce\": \"$nonce\", \"username\": \"$username\", \"password\": \"$password\", \"admin\": \"$admin\", \"mac\": \"$hmac\" }" +) +echo $res diff --git a/src/config.ts b/src/config.ts index 6483eeda899d30c2fc7569979d5e87b5ff6b56c6..d972408e4d014980ee70d10b46d1895eccb70244 100644 --- a/src/config.ts +++ b/src/config.ts @@ -3,3 +3,6 @@ export const ENVIRONMENT = process.env.ENVIRONMENT // The issuer URL for the OpenID Connect provider used by the chat instance. export const CHAT_OIDC_ISSUER = process.env.CHAT_OIDC_ISSUER + +// The secret for generating the hmac hash to register a Matrix admin user. +export const MATRIX_ADMIN_SECRET = process.env.MATRIX_ADMIN_SECRET