{"id":20217916,"url":"https://github.com/matrix-org/synapse-email-account-validity","last_synced_at":"2025-04-10T15:44:15.666Z","repository":{"id":43031482,"uuid":"361783571","full_name":"matrix-org/synapse-email-account-validity","owner":"matrix-org","description":"Account validity plugin for Synapse using email","archived":false,"fork":false,"pushed_at":"2024-05-07T15:57:08.000Z","size":51,"stargazers_count":12,"open_issues_count":1,"forks_count":3,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-03-24T13:36:10.296Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/matrix-org.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-26T14:37:52.000Z","updated_at":"2025-03-15T15:15:06.000Z","dependencies_parsed_at":"2024-11-14T06:46:57.608Z","dependency_job_id":null,"html_url":"https://github.com/matrix-org/synapse-email-account-validity","commit_stats":{"total_commits":19,"total_committers":3,"mean_commits":6.333333333333333,"dds":"0.10526315789473684","last_synced_commit":"b9cd3afbf56138756d72e2c27aaa4fa3f7753b86"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matrix-org%2Fsynapse-email-account-validity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matrix-org%2Fsynapse-email-account-validity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matrix-org%2Fsynapse-email-account-validity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matrix-org%2Fsynapse-email-account-validity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matrix-org","download_url":"https://codeload.github.com/matrix-org/synapse-email-account-validity/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248243500,"owners_count":21071054,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T06:36:22.891Z","updated_at":"2025-04-10T15:44:15.645Z","avatar_url":"https://github.com/matrix-org.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Synapse email account validity\n\nA Synapse plugin module to manage account validity using validation emails.\n\nAfter a configured time, this module automatically expires user accounts. When a user is\nexpired, Synapse will respond to any request authenticated by the user's access token\nwith a 403 error containing the `ORG_MATRIX_EXPIRED_ACCOUNT` error code. Some time before\nan account expires (defined by the module's configuration), an email is sent to the user\nwith instructions to renew the validity of their account.\n\nThis module requires:\n\n* Synapse \u003e= 1.39.0\n* sqlite3 \u003e= 3.24.0 (if using SQLite with Synapse (not recommended))\n\n## Installation\n\nThi plugin can be installed via PyPI:\n\n```\npip install synapse-email-account-validity\n```\n\n## Config\n\nAdd the following in your Synapse config:\n\n```yaml\nmodules:\n  - module: email_account_validity.EmailAccountValidity\n    config:\n      # The maximum amount of time an account can stay valid for without being renewed.\n      period: 6w\n      # How long before an account expires should Synapse send it a renewal email.\n      renew_at: 1w\n      # Whether to include a link to click in the emails sent to users. If false, only a\n      # renewal token is sent, in which case a shorter token is used, and the\n      # user will need to copy it into a compatible client that will send an\n      # authenticated request to the server.\n      # Defaults to true.\n      send_links: true\n```\n\nThe syntax for durations is the same as in the rest of Synapse's configuration file.\n\n## Templates\n\nThe templates the module will use are:\n\n* `notice_expiry.(html|txt)`: The content of the renewal email. It gets passed the\n  following variables:\n    * `app_name`: The value configured for `app_name` in the Synapse configuration file\n      (under the `email` section).\n    * `display_name`: The display name of the user needing renewal.\n    * `expiration_ts`: A timestamp in milliseconds representing when the account will\n      expire. Templates can use the `format_ts` (with a date format as the function's\n      parameter) to format this timestamp into a human-readable date.\n    * `url`: The URL the user is supposed to click on to renew their account. If\n      `send_links` is set to `false` in the module's configuration, the value of this\n      variable will be `None`.\n    * `renewal_token`: The token to use in order to renew the user's account. If\n      `send_links` is set to `false`, templates should prefer this variable to `url`.\n* `account_renewed.html`: The HTML to display to a user when they successfully renew\n  their account. It gets passed the following vaiables:\n    * `expiration_ts`: A timestamp in milliseconds representing when the account will\n      expire. Templates can use the `format_ts` (with a date format as the function's\n      parameter) to format this timestamp into a human-readable date.\n* `account_previously_renewed.html`: The HTML to display to a user when they try to renew\n  their account with a token that's valid but previously used. It gets passed the same\n  variables as `account_renewed.html`.\n* `invalid_token.html`: The HTML to display to a user when they try to renew their account\n  with the wrong token. It doesn't get passed any variable.\n\nYou can find and change the default templates [here](https://github.com/matrix-org/synapse-email-account-validity/tree/main/email_account_validity/templates).\nAdmins can install custom templates either by changing the default ones directly, or by\nconfiguring Synapse with a custom template directory that contains the custom templates.\nNote that the templates directory contains two files that aren't templates (`mail.css`\nand `mail-expiry.css`), but are used by email templates to apply visual adjustments.\n\nAdmins that don't need to customise their templates can just use the module as is and\nignore the previous paragraph.\n\n## Routes\n\nThis plugin exposes three HTTP routes to manage account validity:\n\n* `POST /_synapse/client/email_account_validity/send_mail`, which any registered user can\n  hit with an access token to request a renewal email to be sent to their email addresses.\n* `GET /_synapse/client/email_account_validity/renew`, which requires a `token` query\n  parameter containing the latest token sent via email to the user, which renews the\n  account associated with the token.\n* `POST /_synapse/client/email_account_validity/admin`, which any server admin can use to\n  manage the account validity of any registered user. It takes a JSON body with the\n  following keys:\n    * `user_id` (string, required): The Matrix ID of the user to update.\n    * `expiration_ts` (integer, optional): The new expiration timestamp for this user, in\n      milliseconds. If no token is provided, a value corresponding to `now + period` is\n      used.\n    * `enable_renewal_emails` (boolean, optional): Whether to allow renewal emails to be\n      sent to this user.\n\nThe two first routes need to be reachable by the end users for this feature to work as\nintended.\n\n## Development and Testing\n\nThis repository uses `tox` to run tests.\n\n### Tests\n\nThis repository uses `unittest` to run the tests located in the `tests`\ndirectory. They can be ran with `tox -e tests`.\n\n### Making a release\n\n```\ngit tag vX.Y\npython3 setup.py sdist\ntwine upload dist/synapse-email-account-validity-X.Y.tar.gz\ngit push origin vX.Y\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatrix-org%2Fsynapse-email-account-validity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatrix-org%2Fsynapse-email-account-validity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatrix-org%2Fsynapse-email-account-validity/lists"}