A Synapse module to derive usernames from third party identifiers (i.e. email addresses and phone numbers) when registering users.
  • Python 96.8%
  • Shell 3.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Brendan Abolivier 8bfe6b5205
Fix import of Final (#2)
We were importing from typing instead of typing_extensions, which broke compatibility with Python 3.7
2022-06-10 13:40:42 +02:00
.github Cookiecutter generation 2022-01-21 18:23:44 +00:00
scripts-dev Cookiecutter generation 2022-01-21 18:23:44 +00:00
tests Fix import of Final (#2) 2022-06-10 13:40:42 +02:00
username_from_threepid Fix import of Final (#2) 2022-06-10 13:40:42 +02:00
.gitignore Cookiecutter generation 2022-01-21 18:23:44 +00:00
.gitlab-ci.yml Cookiecutter generation 2022-01-21 18:23:44 +00:00
LICENSE Cookiecutter generation 2022-01-21 18:23:44 +00:00
mypy.ini Cookiecutter generation 2022-01-21 18:23:44 +00:00
pyproject.toml Cookiecutter generation 2022-01-21 18:23:44 +00:00
README.md First cut of the a module to derive usernames from 3PIDs (#1) 2022-01-26 12:19:50 +01:00
setup.cfg Fix import of Final (#2) 2022-06-10 13:40:42 +02:00
tox.ini Cookiecutter generation 2022-01-21 18:23:44 +00:00

Synapse module to set usernames from third-party identifiers

This Synapse module derives usernames from third party identifiers (i.e. email addresses and phone numbers) when registering users.

Installation

From the virtual environment that you use for Synapse, install this module with:

pip install synapse-username-from-threepid

(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: username_from_threepid.UsernameFromThreepid
    config:
      # Which third-party identifier to look for. Can either be "email" (for email
      # addresses), or "msisdn" (for phone numbers).
      # Required.
      threepid_to_use: "email"

      # Whether to fail the registration if no third-party identifier was provided during
      # the registration process.
      # Optional, defaults to false.
      fail_if_not_found: true

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):

  1. Set a shell variable to the version you are releasing (this just makes subsequent steps easier):

    version=X.Y.Z
    
  2. Update setup.cfg so that the version is correct.

  3. Stage the changed files and commit.

    git add -u
    git commit -m v$version -n
    
  4. Push your changes.

    git push
    
  5. When ready, create a signed tag for the release:

    git tag -s v$version
    

    Base the tag message on the changelog.

  6. Push the tag.

    git push origin tag v$version
    
  7. If applicable: Create a source distribution and upload it to PyPI:

    python -m build
    twine upload dist/username_from_threepid-$version*