Skip to content
This repository was archived by the owner on May 18, 2025. It is now read-only.

Commit 68ed2eb

Browse files
committed
Add support for Synapse Simple Antispam
Fixes spantaleev#255 (Github Issue).
1 parent 4b1e9a4 commit 68ed2eb

File tree

8 files changed

+92
-1
lines changed

8 files changed

+92
-1
lines changed

CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
# 2019-09-09
2+
3+
## Synapse Simple Antispam support
4+
5+
There have been lots of invite-spam attacks lately and [Travis](https://github.com/t2bot) has created a Synapse module ([synapse-simple-antispam](https://github.com/t2bot/synapse-simple-antispam)) to let people protect themselves.
6+
7+
From now on, you can easily install and configure this spam checker module through the playbook.
8+
9+
Learn more in [Setting up Synapse Simple Antispam](docs/configuring-playbook-synapse-simple-antispam.md).
10+
11+
112
# 2019-08-25
213

314
## Extensible Riot-web configuration
@@ -9,7 +20,7 @@ This should be enough for most customization needs.
920

1021
If you need even more power, you can now also take full control and override `matrix_riot_web_configuration_default` (or `matrix_riot_web_configuration`) directly.
1122

12-
Learn more here in [Configuring Riot-web](docs/configuring-playbook-riot-web.md).
23+
Learn more in [Configuring Riot-web](docs/configuring-playbook-riot-web.md).
1324

1425

1526
# 2019-08-22
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Setting up Synapse Simple Antispam (optional, advanced)
2+
3+
The playbook can install and configure [synapse-simple-antispam](https://github.com/t2bot/synapse-simple-antispam) for you.
4+
5+
See that project's documentation to learn what it does and why it might be useful to you.
6+
In short, it lets you fight invite-spam by automatically blocking invitiations from a list of servers specified by you (blacklisting).
7+
8+
If you decide that you'd like to let this playbook install it for you, you need some configuration like this:
9+
10+
```yaml
11+
matrix_synapse_ext_spam_checker_synapse_simple_antispam_enabled: true
12+
13+
matrix_synapse_ext_spam_checker_synapse_simple_antispam_config_blocked_homeservers:
14+
- example.com
15+
- another.com
16+
```

docs/configuring-playbook.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ When you're done with all the configuration you'd like to do, continue with [Ins
7272

7373
- [Setting up the LDAP password provider module](configuring-playbook-ldap-auth.md) (optional, advanced)
7474

75+
- [Setting up Synapse Simple Antispam](configuring-playbook-synapse-simple-antispam.md) (optional, advanced)
76+
7577
- [Setting up Matrix Corporal](configuring-playbook-matrix-corporal.md) (optional, advanced)
7678

7779

roles/matrix-synapse/defaults/main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,12 @@ matrix_synapse_ext_password_provider_ldap_bind_dn: ""
263263
matrix_synapse_ext_password_provider_ldap_bind_password: ""
264264
matrix_synapse_ext_password_provider_ldap_filter: ""
265265

266+
# Enable this to activate the Synapse Antispam spam-checker module.
267+
# See: https://github.com/t2bot/synapse-simple-antispam
268+
matrix_synapse_ext_spam_checker_synapse_simple_antispam_enabled: false
269+
matrix_synapse_ext_spam_checker_synapse_simple_antispam_git_repository_url: "https://github.com/t2bot/synapse-simple-antispam"
270+
matrix_synapse_ext_spam_checker_synapse_simple_antispam_git_version: "f058d9ce2c7d4195ae461dcdd02df11a2d06a36b"
271+
matrix_synapse_ext_spam_checker_synapse_simple_antispam_config_blocked_homeservers: []
266272

267273
matrix_s3_media_store_enabled: false
268274
matrix_s3_media_store_custom_endpoint_enabled: false

roles/matrix-synapse/tasks/ext/setup.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@
55
- import_tasks: "{{ role_path }}/tasks/ext/shared-secret-auth/setup.yml"
66

77
- import_tasks: "{{ role_path }}/tasks/ext/ldap-auth/setup.yml"
8+
9+
- import_tasks: "{{ role_path }}/tasks/ext/synapse-simple-antispam/setup.yml"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
3+
- import_tasks: "{{ role_path }}/tasks/ext/synapse-simple-antispam/setup_install.yml"
4+
when: matrix_synapse_ext_spam_checker_synapse_simple_antispam_enabled|bool
5+
6+
- import_tasks: "{{ role_path }}/tasks/ext/synapse-simple-antispam/setup_uninstall.yml"
7+
when: "not matrix_synapse_ext_spam_checker_synapse_simple_antispam_enabled|bool"
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
3+
- name: Fail if Synapse Simple Antispam blocked homeservers is not set
4+
fail:
5+
msg: "Synapse Simple Antispam is enabled, but no blocked homeservers have been set in matrix_synapse_ext_spam_checker_synapse_simple_antispam_config_blocked_homeservers"
6+
when: "matrix_synapse_ext_spam_checker_synapse_simple_antispam_config_blocked_homeservers|length == 0"
7+
8+
- name: Ensure git installed (RedHat)
9+
yum:
10+
name:
11+
- git
12+
state: present
13+
update_cache: no
14+
when: "ansible_os_family == 'RedHat'"
15+
16+
- name: Ensure git installed (Debian)
17+
apt:
18+
name:
19+
- openssl
20+
state: present
21+
update_cache: no
22+
when: "ansible_os_family == 'Debian'"
23+
24+
- name: Clone synapse-simple-antispam git repository
25+
git:
26+
repo: "{{ matrix_synapse_ext_spam_checker_synapse_simple_antispam_git_repository_url }}"
27+
version: "{{ matrix_synapse_ext_spam_checker_synapse_simple_antispam_git_version }}"
28+
dest: "{{ matrix_synapse_ext_path }}/synapse-simple-antispam"
29+
become: true
30+
become_user: "{{ matrix_user_username }}"
31+
32+
- set_fact:
33+
matrix_synapse_spam_checker:
34+
module: "synapse_simple_antispam.AntiSpamInvites"
35+
config:
36+
blocked_homeservers: "{{ matrix_synapse_ext_spam_checker_synapse_simple_antispam_config_blocked_homeservers }}"
37+
38+
matrix_synapse_container_extra_arguments: >
39+
{{ matrix_synapse_container_extra_arguments|default([]) }}
40+
+
41+
{{ ["--mount type=bind,src={{ matrix_synapse_ext_path }}/synapse-simple-antispam/synapse_simple_antispam,dst={{ matrix_synapse_in_container_python_packages_path }}/synapse_simple_antispam,ro"] }}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
3+
- name: Ensure synapse-simple-antispam doesn't exist
4+
file:
5+
path: "{{ matrix_synapse_ext_path }}/synapse-simple-antispam"
6+
state: absent

0 commit comments

Comments
 (0)