Giter Site home page Giter Site logo

krombel / matrix-register-bot Goto Github PK

View Code? Open in Web Editor NEW
26.0 4.0 5.0 83 KB

Bot that offers two step registrations to a matrix-synapse server

License: Apache License 2.0

PHP 100.00%
synapse matrix registration mxisd matrix-register-bot approval

matrix-register-bot's Introduction

matrix-register-bot

state: alpha #matrix-register-bot:msg-net.de

This bot provides a two-step-registration for matrix (synapse).

This is done in several steps:

  • potential new user registers on a bot-provided site
  • user has to verify its mail address
  • bot sends a message to predefined room with a registration notification.
  • users in that room now can approve or decline the registration.
  • When approved
    • the bot creates short time credentials
    • sends them to the user
    • stores them encrypted in own databas or uses that as initial password for registration

There are two operation modes available:

  • operationMode=synapse
  • operationMode=local:
    • Bot handles user management. Therefore it stores the user-data and uses matrix-synapse-rest-auth to authenticate the users.
    • This way it is possible to set the display name of a user on first login (first- and lastname instead of username)
    • The email address of the user can be used to implement third party lookup (requires mxisd)
    • search for users you have not seen yet but are available on the server

Requirements

  • Working PHP environment with
    • database connection provider [one of sqlite, mysql, postgres]
    • curl extension
    • mail capability to interact with the users (verification, approval (+ initial password), notifications)
      • either via sendmail or with credentials
  • composer installed
  • matrix-synapse-rest-auth when using operationMode=local

How to install

git clone https://github.com/krombel/matrix-register-bot
cd matrix-register-bot
composer install
cp config.sample.php config.php
editor config.php
  • Configure your webserver to have the folder public accessible via web.

When running operationMode=local:

  • Configure your webserver to provide the folder internal internally. This is only meant to be accessible by mxisd and matrix-synapse-rest-auth
  • To integrate with matrix-synapse-rest-auth:
    • /_matrix-internal/identity/v1/check_credentials should map to internal/login.php
  • To integrate with mxisd: Have a look at the docs of mxisd and apply as follows:
Key file which handles that Description
rest.endpoints.auth internal/login.php Validate credentials and get user profile
rest.endpoints.directory internal/directory_search.php Search for users by arbitrary input
rest.endpoints.identity.single internal/identity_single.php Endpoint to query a single 3PID
rest.endpoints.identity.bulk internal/identity_bulk.php Endpoint to query a list of 3PID

Further notes:

Security: Passwords from registration form are stored in clear text

Currently the passwords which are typed in while capturing the register request are stored in clear text. The bot needs to access them to trigger a register request with correct credentials. It is currently strongly recommended to set "getPasswordOnRegistration" => false in your config! This leads to autocreating passwords which will then be send to the users directly without storing it.

Use the ChangePasswortInterceptor (if operationMode=local)

To allow users to change their pasword you need a reverse proxy which maps /_matrix/client/r0/account/password to internal/intercept_change_password.php. Here is an example for nginx:

        location /_matrix/client/r0/account/password {
                proxy_pass http://localhost/mxbot/internal/intercept_change_password.php;
                proxy_set_header X-Forwarded-For $remote_addr;
        }

The bot postpones some actions

There is a cron.php which implements retries and database cleanups (e.g. to remove a username claim) For this run cron.php regularly with your system of choice. A suggested interval is once per day

matrix-register-bot's People

Contributors

dependabot[bot] avatar krombel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

matrix-register-bot's Issues

Implement config check with setting of defaults

It would be nice to implement some checks of the config so the user of the bot can validate its config while configuring.
I am thinking of a class or some other kind of validator which reads the config file and provides

  • some getters to access the configs (which provide defaults if they are unset) or
  • sets all undefined values with defaults when unset

Invalid macaroon when validating account

I was wondering if the bot is still working with the latest version of matrix.

I cannot seem to make it work. I see the following error messages when trying to verify an account:
PHP message: Request has failed with error Invalid macaroon passed" while reading response header from upstream
Any clue on how to approach this problem?

add registration interceptor

Currently there is some API the client can use to register itself. It should be possible to intercept that endpoint and handle that as register request

Does not work anymore on synapse v0.33.3

In v0.33.3 they remove the shared registration token procedure and replace it with a new api.
Here are the release notes
Here is the new API

FTR: This issue only affects operationMode=synapse. operationMode=local is still working as designed

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.