Package: matrix-registration-bot
Matrix Registration BotThis bot aims to create and manage registration tokens for a matrix
server. It wants to help invitation based servers to maintain usability.
It does not create a user itself, but allows registration only with a
valid token as defined by Matrix standardMSC3231.
The benefit is, that an administrator minimizes manual work and does not
know a user’s password at any time.This means, that a user that registers on your server has to provide a
registration token to successfully create an account. The token can be
created by interacting with this bot. So to invite a friend you would
sendcreateto the bot which answers with a token. You send the
token to the friend, and they can use this to create an account.The feature was added in Matrix v1.2. More information can be found in
theSynapse
Documentation.If you have any questions, or if you need help setting it up, read thetroublshooting guideor join#matrix-registration-bot:hyteck.de.Supported commandsUnrestricted commandshelp: Shows this helpRestricted commandslist: Lists all registration tokensshow <token>: Shows token details in human-readable formatcreate: Creates a token that that is valid for one registration
for seven daysdelete <token>Deletes the specified token(s)delete-allDeletes all tokensallow @user:example.comAllows the specified user (or a user
matching a regex pattern) to use restricted commandsdisallow @user:example.comStops a specified user (or a user
matching a regex pattern) from using restricted commandsPermissionsBy default, any user on the homeserver of the bot is allowed to use
restricted commands. You can change that, by using theallowcommand
to configure one (or multiple) specific user. Read thesimple-matrix-bot
documentationfor more information. If you get locked out for any reason, simply
modify the config.toml that is created in the bots working directory.Getting startedInstall viamatrix-docker-ansible-deployIf you already installed your homeserver with this ansible playbook you
can make use of a very simple setup. Check outthe setup instructions
in the project’s
repo.Prerequisites for all other installation methodsServer configurationYour server should be configured to a token restricted registration. Add
the following to yourhomeserver.yaml:enable_registration:trueregistration_requires_token:trueCreate a bot accountThen you need to create an account for the bot on the server, like you
would do with any other account. A good username isregistration-bot. If you want to use token based login, note the
access token of the bot. One way to get the token is to log in as the
bot and got toSettings->Help & About->Access Tokenin Element,
however you mustn’t log out or the token will be invalidated. As an
alternative you can use the commandcurl-XPOST--header'Content-Type: application/json'-d'{
    "identifier": { "type": "m.id.user", "user": "YourBotUsername" },
    "password": "YourBotPassword",
    "type": "m.login.password"
}''https://matrix.YOURDOMAIN/_matrix/client/r0/login'Once you are finished you can start the installation of the bot.Manual InstallationThe installation can easily be done viaPyPi$pipinstallmatrix-registration-botConfigurationConfigure the bot with a file namedconfig.yml. It should look like
thisbot:server:"https://synapse.example.com"username:"registration-bot"access_token:"verysecret"# It is also possible to use a password based login by commenting out the access token line and adjusting the line below# password: "secretpassword"prefix:""api:# API endpoint of the registration tokensbase_url:'https://synapse.example.com'# Access token of an administrator on the server. If you configured the bot to be an admin on the sever you can use the same token as above.token:"supersecret"logging:level:DEBUG/INFO/ERRORIt is also possible to use environment variables to configure the bot.
The variable names are all upper case, concatenated with_e.g.LOGGING_LEVEL.Start the botStart the bot withpython-mmatrix_registration_bot.botand then open a Direct Message to the bot. The type one of the following
commands.Automatically (re-)start the bot with SystemdTo have the bot start automatically after reboots create the file/etc/systemd/system/matrix-registration-bot.servicewith the
following content on your server. This assumes you use that you place
your configuration in/matrix/matrix-registration-bot/config.yml.[Unit]
Description=matrix-registration-bot

[Service]
Type=simple

WorkingDirectory=/matrix/matrix-registration-bot
ExecStart=python3 -m matrix_registration_bot.bot

Restart=always
RestartSec=30
SyslogIdentifier=matrix-registration-bot

[Install]
WantedBy=multi-user.targetAfter creating the service reload your daemon and start+enable the
service.$sudosystemctldaemon-reload$sudosystemctlstartmatrix-registration-bot$sudosystemcltenablematrix-registration-botInstall using docker-composeTo use this container via docker you can create the followingdocker-compose.ymland start the container withdocker-composeup-d. Explanation on how to obtain the correct
values of the configuration can be found in theManual installationsection.version:"3.7"services:matrix-registration-bot:image:moanos/matrix-registration-bot:latestenvironment:LOGGING_LEVEL:DEBUGBOT_SERVER:"https://synapse.example.com"BOT_USERNAME:"registration-bot"BOT_PASSWORD:"password"API_BASE_URL:'https://synapse.example.com'API_TOKEN:"syt_xxxxxxxxxxxxxxxxxxxxxxxx"git checkout de # End-to-End EncryptionFrom version 1.2.0 the bot supports E2E encryption. This is a bit safer
and also allows to create direct messages (which are by default
encrypted). This will be enabled by default.ContributingFeel free to contribute or discuss this bot at#matrix-registration-bot:hyteck.deor simply open issues and PRs here.Code of
ConductRelated ProjectsThe project is made possible bySimple-Matrix-Bot-Lib.An alternative for managing tokens isSynapse
Admin