mirror of
https://github.com/matrix-org/mjolnir.git
synced 2024-10-01 01:36:06 -04:00
50f80f2392
Mjolnir can now be run as an application service, meaning it will host multiple independent mjolnirs that can be requested by users. If the user is on the same homeserver as the appservice is deployed on, then they can provision a mjolnir via a widget https://github.com/matrix-org/mjolnir-widget. Otherwise they can invite the appservice bot to a room they want to protect. This will create them a mjolnir, a management room and a policy list. The appservice shares the same docker image as the bot, but is started slightly differently by specifying "appservice" as the first argument to docker run (this s managed by `mjolnir-entrypoint.sh`. We could have used another Dockerfile for the appservice, extending the existing one but we decided not to because there would have been lots of fiddling around the entrypoint and logistics involved around adding a tag for it via github actions. Not to mention that this would be duplicating the image just to run it with a different binary. A list of followup issues can be found here https://github.com/issues?q=is%3Aopen+is%3Aissue+author%3AGnuxie+archived%3Afalse+label%3AA-Appservice. Somewhat relevant and squashed commit messages(regrettably squashing because frankly these won't make sense in isolation): * draft widget backend * add `managementRoomId` to `provisionNewMjolnir` * remove ratelimits from appservice mjolnirs * add /join endpoint to api backend * tighter guard around room type in PolicyList matrix-bot-sdk imporved the types for this * enable esModuleInterop * launch and use postgres in a container whilst using mx-tester * limited access control policy list used for access control * Redesign initialization API of many mjolnir. It's much harder to forget to initialize the components now that you have to in order to construct them in the first place. * Ammend config not to clash with existing CI this means that the appsrvice bot is now called 'mjolnir-bot' by default which was easier than going through old code base and renaming * Change entrypoint in Dockerfile so that we can start the appservice. We could have used another Dockerfile for the appservice, extending the exising one but we decided not to because there would have been lots of fiddling around the entrypoint and logistics involved around adding a tag for it via github actions. Not to mention that this would be duplicating the image just to run it with a different binary. This solution is much simpler, backwards compatible, and conscious about the future. Co-authored-by: gnuxie <gnuxie@element.io>
78 lines
2.5 KiB
YAML
78 lines
2.5 KiB
YAML
name: mjolnir
|
|
|
|
up:
|
|
before:
|
|
- docker run --rm --network $MX_TEST_NETWORK_NAME --name mjolnir-test-postgres --domainname mjolnir-test-postgres -e POSTGRES_PASSWORD=mjolnir-test -e POSTGRES_USER=mjolnir-tester -e POSTGRES_DB=mjolnir-test-db -d -p 127.0.0.1:8083:5432 postgres
|
|
# Wait until postgresql is ready
|
|
- until psql postgres://mjolnir-tester:mjolnir-test@localhost:8083/mjolnir-test-db -c ""; do echo "Waiting for psql..."; sleep 1s; done
|
|
# Make table in postgres
|
|
- psql postgres://mjolnir-tester:mjolnir-test@localhost:8083/mjolnir-test-db -c "CREATE TABLE mjolnir (local_part VARCHAR(255), owner VARCHAR(255), management_room TEXT)"
|
|
# Launch the reverse proxy, listening for connections *only* on the local host.
|
|
- docker run --rm --network host --name mjolnir-test-reverse-proxy -p 127.0.0.1:8081:80 -v $MX_TEST_CWD/test/nginx.conf:/etc/nginx/nginx.conf:ro -d nginx
|
|
- yarn install
|
|
- npx ts-node src/appservice/cli.ts -r -u "http://host.docker.internal:9000"
|
|
- cp mjolnir-registration.yaml $MX_TEST_SYNAPSE_DIR/data/
|
|
after:
|
|
# Wait until Synapse is ready
|
|
- until curl localhost:9999 --stderr /dev/null > /dev/null; do echo "Waiting for Synapse..."; sleep 1s; done
|
|
- echo "Synapse is ready"
|
|
|
|
run:
|
|
- yarn test:integration
|
|
|
|
down:
|
|
finally:
|
|
- docker stop mjolnir-test-postgres || true
|
|
- docker stop mjolnir-test-reverse-proxy || true
|
|
|
|
modules:
|
|
- name: mjolnir
|
|
build:
|
|
- cp -r synapse_antispam $MX_TEST_MODULE_DIR/
|
|
config:
|
|
module: mjolnir.Module
|
|
config: {}
|
|
|
|
|
|
homeserver:
|
|
# Basic configuration.
|
|
server_name: localhost:9999
|
|
public_baseurl: http://localhost:9999
|
|
registration_shared_secret: REGISTRATION_SHARED_SECRET
|
|
# Make manual testing easier
|
|
enable_registration: true
|
|
enable_registration_without_verification: true
|
|
|
|
app_service_config_files:
|
|
- "/data/mjolnir-registration.yaml"
|
|
|
|
# We remove rc_message so we can test rate limiting,
|
|
# but we keep the others because of https://github.com/matrix-org/synapse/issues/11785
|
|
# and we don't want to slow integration tests down.
|
|
rc_registration:
|
|
per_second: 10000
|
|
burst_count: 10000
|
|
|
|
rc_login:
|
|
address:
|
|
per_second: 10000
|
|
burst_count: 10000
|
|
account:
|
|
per_second: 10000
|
|
burst_count: 10000
|
|
failed_attempts:
|
|
per_second: 10000
|
|
burst_count: 10000
|
|
|
|
rc_admin_redaction:
|
|
per_second: 10000
|
|
burst_count: 10000
|
|
|
|
rc_joins:
|
|
local:
|
|
per_second: 10000
|
|
burst_count: 10000
|
|
remote:
|
|
per_second: 10000
|
|
burst_count: 10000
|