matrix invite token system
Find a file
Your Name 89af3a1987 log
2025-04-04 23:32:57 -05:00
readme first commit 2025-03-10 22:03:00 -05:00
go.mod first commit 2025-03-10 22:03:00 -05:00
go.sum first commit 2025-03-10 22:03:00 -05:00
main.go log 2025-04-04 23:32:57 -05:00
matrix-invite.html first commit 2025-03-10 22:03:00 -05:00
matrix-register first commit 2025-03-10 22:03:00 -05:00
matrix-register.html first commit 2025-03-10 22:03:00 -05:00
matrix-register.service first commit 2025-03-10 22:03:00 -05:00
README.md warning about domain 2025-03-11 00:00:55 -05:00
success.html Clean up success text 2025-03-10 23:55:55 -05:00

matrix-register

Step 1: Server Admin or Moderator creates a single-use invite token:

"Create Matrix Invite Code" there is a form with a single shared secret field. The result of the form submission is shown, with a URL that ends in matrix-invite/xxx

Step 2: The invited person navigates to the token URL and enters thier desired username and password.

"matrix account registration" there is a form with username and password fields

setting it up on the server the first time

Install the matrix-register.service systemd service unit file at /lib/systemd/system/matrix-register.service

/systemctl daemon-reload

Caddyfile routes some paths to the service:

root@matrix:/opt/matrix-register# cat /etc/caddy/Caddyfile
https://matrix.cyberia.club {

  reverse_proxy /matrix-invite http://localhost:3000
  reverse_proxy /matrix-register http://localhost:3000
  reverse_proxy /matrix-invite/* http://localhost:3000
  reverse_proxy /matrix-register/* http://localhost:3000


  reverse_proxy /_matrix/* http://localhost:8008

....

⚠️ Warning: for now this is probably a REQUIREMENT, that the registration server runs on the same domain as the synapse API.

Here's how the filesystem has to be set up:

root@matrix:/opt/matrix-register# tree
.
|-- inviteCodes
|   |-- xxxxxxxxxxx
|   `-- xxxxxxxxxxx
|-- matrix-invite.html
|-- matrix-register
|-- matrix-register.html
`-- success.html

systemctl enable --now matrix-register.service

you can read the logs with journalctl -u matrix-register -n 100 --no-pager

Deploying updates

on dev machine

go build -tags netgo,osusergo -o matrix-register .
curl https://webclip.sequentialread.com/matrix-register | bash

on matrix server

cd /opt/matrix-register && systemctl disable --now matrix-register && rm matrix-register && curl https://webclip.sequentialread.com/ > matrix-register && chmod +x matrix-register && systemctl enable --now matrix-register && sleep 1 &&  journalctl -u matrix-register -n 5 --no-pager