diff options
author | James Barton <james@neodon.com> | 2022-08-11 15:10:10 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-11 21:10:10 +0100 |
commit | e825f7366b589f61977f63d4fdc598abe052e6a0 (patch) | |
tree | 4e8e66d6c15bb12457c33482ff0c9aec1208d554 /docs | |
parent | Add note to `redaction_retention_period` documentation mentioning that event ... (diff) | |
download | synapse-e825f7366b589f61977f63d4fdc598abe052e6a0.tar.xz |
Add `openssl` example for registration HMAC (#13472)
Signed-off-by: James Barton <james@neodon.com>
Diffstat (limited to 'docs')
-rw-r--r-- | docs/admin_api/register_api.md | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/docs/admin_api/register_api.md b/docs/admin_api/register_api.md index c346090bb1..d7b7cf6a76 100644 --- a/docs/admin_api/register_api.md +++ b/docs/admin_api/register_api.md @@ -46,7 +46,24 @@ As an example: 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, either the string "admin" or "notadmin", and optionally the user_type -each separated by NULs. For an example of generation in Python: +each separated by NULs. + +Here is an easy way to generate the HMAC digest if you have Bash and OpenSSL: + +```bash +# Update these values and then paste this code block into a bash terminal +nonce='thisisanonce' +username='pepper_roni' +password='pizza' +admin='admin' +secret='shared_secret' + +printf '%s\0%s\0%s\0%s' "$nonce" "$username" "$password" "$admin" | + openssl sha1 -hmac "$secret" | + awk '{print $2}' +``` + +For an example of generation in Python: ```python import hmac, hashlib @@ -70,4 +87,4 @@ def generate_mac(nonce, user, password, admin=False, user_type=None): mac.update(user_type.encode('utf8')) return mac.hexdigest() -``` \ No newline at end of file +``` |