Skip to main content

Synapse email account validity

A Synapse plugin module to manage account validity using validation emails.

This module requires:

  • Synapse >= 1.34.0
  • sqlite3 >= 3.24.0 (if using SQLite with Synapse)

Installation

Thi plugin can be installed via PyPI:

pip install synapse-email-account-validity

Config

Add the following in your Synapse config under account_validity:

  - module: email_account_validity.EmailAccountValidity
    config:
      # The maximum amount of time an account can stay valid for without being renewed.
      period: 6w
      # How long before an account expires should Synapse send it a renewal email.
      renew_at: 1w

Also under the HTTP client listener, configure an additional_resource as per below:

    additional_resources:
      "/_synapse/client/email_account_validity":
        module: email_account_validity.EmailAccountValidityServlet
        config:
          # The maximum amount of time an account can stay valid for without being
          # renewed.
          period: 6w

The syntax for durations is the same as in the rest of Synapse's configuration file.

If they are not already there, copy the templates into Synapse's templates directory.

Routes

This plugin exposes three HTTP routes to manage account validity:

  • POST /_synapse/client/email_account_validity/send_mail, which any registered user can hit with an access token to request a renewal email to be sent to their email addresses.
  • GET /_synapse/client/email_account_validity/renew, which requires a token query parameter containing the latest token sent via email to the user, which renews the account associated with the token.
  • POST /_synapse/client/email_account_validity/admin, which any server admin can use to manage the account validity of any registered user. It takes a JSON body with the following keys:
    • user_id (string, required): The Matrix ID of the user to update.
    • expiration_ts (integer, optional): The new expiration timestamp for this user, in milliseconds. If no token is provided, a value corresponding to now + period is used.
    • enable_renewal_emails (boolean, optional): Whether to allow renewal emails to be sent to this user.

The two first routes need to be reachable by the end users for this feature to work as intended.

Development and Testing

This repository uses tox to run tests.

Tests

This repository uses unittest to run the tests located in the tests directory. They can be ran with tox -e tests.

Making a release

git tag vX.Y
python3 setup.py sdist
twine upload dist/synapse-email-account-validity-X.Y.tar.gz
git push origin vX.Y

Metadata

Release files for synapse-email-account-validity 0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for synapse-email-account-validity 0.3
File Size Uploaded
synapse-email-account-validity-0.3.tar.gz 20.3 kB Details

Release files / synapse-email-account-validity-0.3.tar.gz

Download URL synapse-email-account-validity-0.3.tar.gz
Size 20.3 kB
Tags Source
SHA-256 checksum
How to use checksums
5f5cee0c7e4230a12365855a541309b65c96abecce8ec9069f65f1e279217439
BLAKE2b-256 checksum
How to use checksums
aff91a535d2726cbac2f5e873f075ce8ff3cfba88bb9ee0eb18486d2d90dc755
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2

Release history Release notifications | RSS feed

This release

0.3 This release

1 release file

0.2

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page