3PID checker for Synapse
A module that checks whether a 3PID (email address, phone number) can be allowed to be registered on the local homeserver by querying a remote backend.
Installation
From the virtual environment that you use for Synapse, install this module with:
pip install path/to/synapse-3pid-checker
(If you run into issues, you may need to upgrade pip first, e.g. by running
pip install --upgrade pip)
Then alter your homeserver configuration, adding to your modules configuration:
modules:
- module: threepid_checker.ThreepidChecker
config:
# The URL to send requests to when checking if a 3PID can be associated to an account.
# See below for more information.
# Required.
url: https://foo/bar
# If true, the module will only send requests to the URL as part of registering a
# new user. This means no request will be sent to the URL when associating a 3PID with
# an already existing account.
# Optional, defaults to false.
only_check_at_registration: false
The configured URL will be hit by a GET HTTP request. Note that this is not subject to Synapse's IP blacklist, with 2 parameters to qualify the 3PID:
medium: The 3PID's medium (emailfor an email address,msisdnfor a phone number)address: The 3PID's address
The server at that URL is expected to respond with a JSON object that contains the following keys:
hs(string): Required. The name of the homeserver the 3PID is allowed to be associated on. This is theserver_namevariable in Synapse's configuration file. The 3PID will be denied if this is absent from the response's body.requires_invite(bool): Optional. Whether an invite is required for this 3PID to be associated with an account on this homeserver. What qualifies as an invite is left to the server serving the configured URL to define. Defaults tofalse.invited(bool): Optional. Whether there is a pending invite for the 3PID. Defaults tofalse.
The module will deny the 3PID's association based on the response if:
hsdoes not match the homeserver's configured server name, or is missing, orrequires_inviteistrueandinvitedisfalseor missing
The 3PID will be allowed to be associated with a local user otherwise.
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
-
Create a source distribution and upload it to PyPI:
python -m build twine upload dist/threepid_checker-$version*
Release files for threepid-checker 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| threepid_checker-1.0.1.tar.gz | 7.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| threepid_checker-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.9 kB
Release files / threepid_checker-1.0.1.tar.gz
| Download URL | threepid_checker-1.0.1.tar.gz |
|---|---|
| Size | 7.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8a0e95ed229010baa320f19266a6783bbfa1e36c07ba806b1d207d54a7636f6d
|
|
BLAKE2b-256 checksum How to use checksums |
11be46635232adf26f7261cff7fde9cd2ca59c081f8a459aafee5d2b1da78a1c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10
|
Release files / threepid_checker-1.0.1-py3-none-any.whl
| Download URL | threepid_checker-1.0.1-py3-none-any.whl |
|---|---|
| Size | 8.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
720aab00fc9e7709945d5b25da9944e660dc260b50ccb888c9b51d687d9db131
|
|
BLAKE2b-256 checksum How to use checksums |
f9410a2372b5a9c4926edbb06e4d6d5ba7f38cb220329e87fd163c3d3549ba58
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10
|