{"id":20218071,"url":"https://github.com/matrix-org/synapse-user-restrictions","last_synced_at":"2025-04-10T15:45:43.936Z","repository":{"id":43842785,"uuid":"416818022","full_name":"matrix-org/synapse-user-restrictions","owner":"matrix-org","description":"This module allows restricting users from performing actions such as creating rooms or sending invites.","archived":false,"fork":false,"pushed_at":"2022-02-16T10:17:58.000Z","size":27,"stargazers_count":17,"open_issues_count":1,"forks_count":4,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-04-10T05:46:47.398Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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}},"created_at":"2021-10-13T16:26:09.000Z","updated_at":"2025-03-18T14:31:32.000Z","dependencies_parsed_at":"2022-09-05T23:11:31.682Z","dependency_job_id":null,"html_url":"https://github.com/matrix-org/synapse-user-restrictions","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matrix-org%2Fsynapse-user-restrictions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matrix-org%2Fsynapse-user-restrictions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matrix-org%2Fsynapse-user-restrictions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matrix-org%2Fsynapse-user-restrictions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matrix-org","download_url":"https://codeload.github.com/matrix-org/synapse-user-restrictions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248243511,"owners_count":21071055,"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:37:03.917Z","updated_at":"2025-04-10T15:45:43.912Z","avatar_url":"https://github.com/matrix-org.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Synapse User Restrictions Module\n\nThis module allows restricting users, that match given regular expressions,\nfrom performing actions such as creating rooms or sending invites.\n\nNote that server administrators are not bound by these rules, as the code\nwithin Synapse exempts server administrators from some 'spam checks',\nincluding those used in this module (creating rooms and inviting users).\n\n\n## Installation\n\nFrom the virtual environment that you use for Synapse, install this module with:\n```shell\npip install path/to/synapse-user-restrictions\n```\n(If you run into issues, you may need to upgrade `pip` first, e.g. by running\n`pip install --upgrade pip`)\n\nThen alter your homeserver configuration, adding to your `modules` configuration:\n```yaml\nmodules:\n  - module: synapse_user_restrictions.UserRestrictionsModule\n    config:\n      # List of rules. Earlier rules have a higher priority than later rules.\n      rules:\n        - match: \"@admin.*:example.org\"\n          allow: [invite, create_room]\n\n        - match: \"@assistant.*:example.org\"\n          allow: [invite]\n\n      # If no rules match, then these permissions are denied.\n      # All other permissions are allowed by default.\n      default_deny: [invite, create_room]\n```\n\nIn this example:\n- `@adminalice:example.org` could create rooms and invite users to\nrooms;\n- `@assistantbob:example.org` could invite users to rooms but NOT create rooms;\nand\n- `@plainoldjoe:example.org` could neither create rooms nor invite users.\n\n### Configuration\n\nRules are applied top-to-bottom, with the first matching rule being used.\n\nA rule matches if the regular expression (written in `match`) fully matches the\nuser's Matrix ID, and the permission being sought is either in the `allow` list\nor the `deny` list.\nThe regular expression must match the full Matrix ID and not just a portion of it.\n\nValid permissions (as at the time of writing) are:\n\n- `invite`: the user is trying to invite another user to a room\n- `create_room`: the user is trying to create a room\n\nIf no rules match, then `default_deny` is consulted;\n`default_deny` is useful for only allowing a select few listed user patterns to\nbe allowed to use certain features.\n\n\n## Development\n\nIn a virtual environment with pip ≥ 21.1, run\n```shell\npip install -e .[dev]\n```\n\nTo run the unit tests, you can either use:\n```shell\ntox -e py\n```\nor\n```shell\ntrial tests\n```\n\nTo run the linters and `mypy` type checker, use `./scripts-dev/lint.sh`.\n\n\n## Releasing\n\nThe exact steps for releasing will vary; but this is an approach taken by the\nSynapse developers (assuming a Unix-like shell):\n\n 1. Set a shell variable to the version you are releasing (this just makes\n    subsequent steps easier):\n    ```shell\n    version=X.Y.Z\n    ```\n\n 2. Update `setup.cfg` so that the `version` is correct.\n\n 3. Stage the changed files and commit.\n    ```shell\n    git add -u\n    git commit -m v$version -n\n    ```\n\n 4. Push your changes.\n    ```shell\n    git push\n    ```\n\n 5. When ready, create a signed tag for the release:\n    ```shell\n    git tag -s v$version\n    ```\n    Base the tag message on the changelog.\n\n 6. Push the tag.\n    ```shell\n    git push origin tag v$version\n    ```\n\n 7. If applicable:\n    Create a *release*, based on the tag you just pushed, on GitHub or GitLab.\n\n 8. If applicable:\n    Create a source distribution and upload it to PyPI.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatrix-org%2Fsynapse-user-restrictions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatrix-org%2Fsynapse-user-restrictions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatrix-org%2Fsynapse-user-restrictions/lists"}