A Campgrounds Synapse module that generates an n-digit verification code when signing up through email.
Project description
Request Digit Token
A Campgrounds Synapse module that generates an n-digit verification code when signing up through email.
Installation
From the virtual environment that you use for Synapse, install this module with:
pip install path/to/synapse-request-digit-token
(If you run into issues, you may need to upgrade pip first, e.g. by running
pip install --upgrade pip)
Config
Add the following to your homeserver configuration under modules:
modules:
- module: request_digit_token.RequestDigitToken
config:
# The length of the digit token.
token_length: 6
# How long before the digit token expires.
token_lifetime: "1h"
Routes
This module exposes two HTTP routes for requesting and validating a digit token:
Request Token
Sends an n-digit token to the specified email.
URL
POST /_synapse/client/register/email/requestToken
Data Params
email- The signup email.client_secret- The client secret.send_attempt- The number of request attempts.
{
"email": "test@mailer.com",
"client_secret": "test_secret",
"send_attempt": 1
}
Response
Status: 200 OK
{
"sid": "wcgdeXSQmlODwfDB"
}
Status: 400 Bad Request, 500 Server Error
{
"errcode": "",
"error": ""
}
Validate Token
Validates the token from the client.
URL
GET /_synapse/client/register/email/validateToken
Query Params
token- The digit token.client_secret- The client secret.sid- The session id.
?token=123456&client_secret=test_secret&sid=wcgdeXSQmlODwfDB
Response
Status: 200 OK
{}
Status: 400 Bad Request, 500 Server Error
{
"errcode": "",
"error": ""
}
Development
In a virtual environment with pip ≥ 21.1, run
pip install -e .[dev]
To run the unit tests, you can either use:
tox -e py
or
trial tests
To run the linters and mypy type checker, use ./scripts-dev/lint.sh.
Releasing
The exact steps for releasing will vary; but this is an approach taken by the Synapse developers (assuming a Unix-like shell):
-
Set a shell variable to the version you are releasing (this just makes subsequent steps easier):
version=X.Y.Z
-
Update
setup.cfgso that theversionis correct. -
Stage the changed files and commit.
git add -u git commit -m v$version -n
-
Push your changes.
git push -
When ready, create a signed tag for the release:
git tag -s v$version
Base the tag message on the changelog.
-
Push the tag.
git push origin tag v$version
-
If applicable: Create a release, based on the tag you just pushed, on GitHub or GitLab.
-
If applicable: Create a source distribution and upload it to PyPI:
python -m build twine upload dist/request_digit_token-$version*
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file synapse_request_digit_token-1.0.0.tar.gz.
File metadata
- Download URL: synapse_request_digit_token-1.0.0.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da5a5c1f6ce43476f33b8b88efa13ed3e9a27ff6b43445bf6538bca53352e26b
|
|
| MD5 |
98275197d178abbe2dfa19a84506fc9e
|
|
| BLAKE2b-256 |
7aa033ba492b01f9e31a2cc76ef41ef0e4d63a1e51f2d4a0065c96c528a4b9b1
|