Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Registring with Token (matrix-registration & matrix-registration-bot) #3064

Open
ivoruetsche opened this issue Dec 27, 2023 · 5 comments
Open
Labels
question This issue is a question related to installation

Comments

@ivoruetsche
Copy link

Hi all

I struggling with the user registration part "matrix-registration" and "matrix-registration-bot". If I setup a complete new server and I set the matrix_bot_matrix_registration_bot_enabled to "true", the script can't add the user, so I set it to false, add the bot user manually and add the bot separate with the ansible script, then, it works.

Then, I create a now Token with the matrix-registration-bot, but if a new user will register with the generated token, the GUI points to the Token field ans say's "Please match the requested format.". If I try to generate the token with the "generate-matrix-registration-token" tag, the GUI says:

Error
There was an error while trying to register you.
Token Error
Token is invalid

I think I didn't understand anything correct, or I forgot something?

my inventory/host_vars/matrix.urig.digital/vars.yml:

matrix_domain: mydom.tld
matrix_homeserver_implementation: synapse
matrix_homeserver_generic_secret_key: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
matrix_playbook_reverse_proxy_type: playbook-managed-traefik
devture_traefik_config_certificatesResolvers_acme_email: '[email protected]'
devture_postgres_connection_password: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

matrix_synapse_federation_domain_whitelist:
- x.xxxxx-dddddd.com

matrix_bot_matrix_registration_bot_enabled: true

matrix_bot_matrix_registration_bot_bot_password: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
matrix_synapse_enable_registration: true
matrix_synapse_registration_requires_token: true

matrix_registration_enabled: true
matrix_registration_admin_secret: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

matrix_synapse_admin_enabled: true

matrix_synapse_ext_password_provider_shared_secret_auth_enabled: true
matrix_synapse_ext_password_provider_shared_secret_auth_shared_secret: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

@ivoruetsche
Copy link
Author

...in the mean time, I understand, that "matrix-registration" and "matrix-registration-bot" has no relation between (as the documentation mention on "matrix-registration" - sorry, my fault...), so I didn't need "matrix-registration", just "matrix-registration-bot". I can generate the tokens via the "matrix-registration-bot" and can use it for new users on the login page, maybe it would be nice to have it in the documentation, how to use the tokens.

Because we deploy more Matrix servers, we would like to let the script run without manual tasks, but if we execute "a brand new server (without importing data)", the script stops with this error:

$ ansible-playbook -i inventory/hosts setup.yml --tags=install-all,ensure-matrix-users-created,start
...
TASK [custom/matrix-user-creator : Ensure Synapse user registered - bot.matrix-registration-bot] ******************************************************************************************************************
fatal: [matrix.urig.digital]: FAILED! => changed=false 
  cmd:
  - /usr/bin/env
  - docker
  - exec
  - matrix-synapse
  - register_new_matrix_user
  - -u
  - bot.matrix-registration-bot
  - -p
  - abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvwxyz12
  - -c
  - /data/homeserver.yaml
  - --admin
  - http://localhost:8008
  delta: '0:00:01.539306'
  end: '2023-12-31 12:30:37.085822'
  failed_when_result: true
  msg: non-zero return code
  rc: 1
  start: '2023-12-31 12:30:35.546516'
  stderr: |-
    Traceback (most recent call last):
      File "/usr/local/lib/python3.11/site-packages/urllib3/connection.py", line 203, in _new_conn
        sock = connection.create_connection(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/urllib3/util/connection.py", line 85, in create_connection
        raise err
      File "/usr/local/lib/python3.11/site-packages/urllib3/util/connection.py", line 73, in create_connection
        sock.connect(sa)
    ConnectionRefusedError: [Errno 111] Connection refused
  
    The above exception was the direct cause of the following exception:
  
    Traceback (most recent call last):
      File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 791, in urlopen
        response = self._make_request(
                   ^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 497, in _make_request
        conn.request(
      File "/usr/local/lib/python3.11/site-packages/urllib3/connection.py", line 395, in request
        self.endheaders()
      File "/usr/local/lib/python3.11/http/client.py", line 1289, in endheaders
        self._send_output(message_body, encode_chunked=encode_chunked)
      File "/usr/local/lib/python3.11/http/client.py", line 1048, in _send_output
        self.send(msg)
      File "/usr/local/lib/python3.11/http/client.py", line 986, in send
        self.connect()
      File "/usr/local/lib/python3.11/site-packages/urllib3/connection.py", line 243, in connect
        self.sock = self._new_conn()
                    ^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/urllib3/connection.py", line 218, in _new_conn
        raise NewConnectionError(
    urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f2aa28f7a90>: Failed to establish a new connection: [Errno 111] Connection refused
  
    The above exception was the direct cause of the following exception:
  
    Traceback (most recent call last):
      File "/usr/local/lib/python3.11/site-packages/requests/adapters.py", line 486, in send
        resp = conn.urlopen(
               ^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 845, in urlopen
        retries = retries.increment(
                  ^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/urllib3/util/retry.py", line 515, in increment
        raise MaxRetryError(_pool, url, reason) from reason  # type: ignore[arg-type]
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=8008): Max retries exceeded with url: /_synapse/admin/v1/register (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f2aa28f7a90>: Failed to establish a new connection: [Errno 111] Connection refused'))
  
    During handling of the above exception, another exception occurred:
  
    Traceback (most recent call last):
      File "/usr/local/bin/register_new_matrix_user", line 8, in <module>
        sys.exit(main())
                 ^^^^^^
      File "/usr/local/lib/python3.11/site-packages/synapse/_scripts/register_new_matrix_user.py", line 266, in main
        register_new_user(
      File "/usr/local/lib/python3.11/site-packages/synapse/_scripts/register_new_matrix_user.py", line 150, in register_new_user
        request_registration(
      File "/usr/local/lib/python3.11/site-packages/synapse/_scripts/register_new_matrix_user.py", line 53, in request_registration
        r = requests.get(url)
            ^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/requests/api.py", line 73, in get
        return request("get", url, params=params, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/requests/api.py", line 59, in request
        return session.request(method=method, url=url, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 589, in request
        resp = self.send(prep, **send_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 703, in send
        r = adapter.send(request, **kwargs)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/requests/adapters.py", line 519, in send
        raise ConnectionError(e, request=request)
    requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=8008): Max retries exceeded with url: /_synapse/admin/v1/register (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f2aa28f7a90>: Failed to establish a new connection: [Errno 111] Connection refused'))
  stderr_lines: <omitted>
  stdout: ''
  stdout_lines: <omitted>
...

When I try to create the user (as root) manually, it works:

$ docker exec matrix-synapse register_new_matrix_user -u bot.matrix-registration-bot -p abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvwxyz12 -c /data/homeserver.yaml --admin http://localhost:8008
Sending registration request...
Success!

Then we let the ansible script running again and end's without errors.

Thanks a lot
Ivo

@ristein
Copy link

ristein commented Mar 19, 2024

Having same problem:
matrix-registration is not working anymore (we have benn warned).
matrix-registration-bot does not create user @bot.matrix-registration-bot:DOMAIN and thus can't be used.
Even after creating user and giving admin persissions, bot would not accept invite.

@ristein
Copy link

ristein commented Mar 20, 2024

I just saw that registration tokens can also be created in synapse-admin. You can use this until the bot is working again

@luixxiul luixxiul added the question This issue is a question related to installation label Nov 1, 2024
Copy link

github-actions bot commented Jan 1, 2025

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days. To exempt the issue from being marked as stale again due to inactivity, add "confirmed" label.

@github-actions github-actions bot added the stale label Jan 1, 2025
@phansch
Copy link

phansch commented Jan 3, 2025

matrix-registration-bot doesn't work for me on a fresh install. The docker container fails to start due to missing dependencies: moan0s/matrix-registration-bot#35

Creating registration tokens in synapse-admin seems to work fine though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question This issue is a question related to installation
Projects
None yet
Development

No branches or pull requests

4 participants