moan0s / matrix-registration-bot

A bot that is used to create and manage registration tokens for a matrix server
GNU Affero General Public License v3.0
64 stars 10 forks source link

Password login of bot is broken #23

Closed LostRager closed 1 year ago

LostRager commented 1 year ago

When i try to start the docker container:

2022-10-25 22:58:06,523 DEBUG:No config file set via the environment variable
2022-10-25 22:58:06,524 DEBUG:No config file set via the --config option, defaulting to config.yml in working directory
2022-10-25 22:58:06,524 INFO:Tying to load bot configuration from config.yml
2022-10-25 22:58:06,524 ERROR:Cold not find bot configuration at config.yml
2022-10-25 22:58:06,524 DEBUG:BOT_SERVER set via environment
2022-10-25 22:58:06,524 DEBUG:BOT_USERNAME set via environment
2022-10-25 22:58:06,524 DEBUG:BOT_PASSWORD set via environment
2022-10-25 22:58:06,524 DEBUG:BOT_ACCESS_TOKEN not set in environment
2022-10-25 22:58:06,525 DEBUG:API_BASE_URL set via environment
2022-10-25 22:58:06,525 DEBUG:API_TOKEN set via environment
2022-10-25 22:58:06,525 DEBUG:LOGGING_LEVEL set via environment
2022-10-25 22:58:06,525 INFO:Using password based authentication for the bot
2022-10-25 22:58:06,561 INFO:Loaded the simple-matrix-bot config file config.toml
2022-10-25 22:58:06,562 DEBUG:Using selector: EpollSelector
Traceback (most recent call last):
  File "/opt/venv/bin/matrix-registration-bot", line 8, in <module>
    sys.exit(run_bot())
  File "/opt/venv/lib/python3.10/site-packages/matrix_registration_bot/bot.py", line 201, in run_bot
    bot.run()
  File "/opt/venv/lib/python3.10/site-packages/simplematrixbotlib/bot.py", line 88, in run
    asyncio.run(self.main())
  File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/opt/venv/lib/python3.10/site-packages/simplematrixbotlib/bot.py", line 50, in main
    await self.api.login()
  File "/opt/venv/lib/python3.10/site-packages/simplematrixbotlib/api.py", line 151, in login
    self.async_client.load_store()
  File "/opt/venv/lib/python3.10/site-packages/nio/client/base_client.py", line 356, in load_store
    raise LocalProtocolError("User id is not set")
nio.exceptions.LocalProtocolError: User id is not set
LostRager commented 1 year ago

Also an issue with standalone installation. Seems like there is a problem with password auth.

Changed to key auth and it now works.

moan0s commented 1 year ago

Thanks for the report, I'll look into it

moan0s commented 1 year ago

Okay, this is a wired one as it only appears in the docker image and is therefore harder to debug.. I tested with the same configuration file in docker and non-docker.

moan0s commented 1 year ago

@LostRager can you tell us the version of simplematrixbotlib and matrix-nio that you use?

Takalele commented 1 year ago

hi @moan0s @LostRager same issue here with the docker-image, the password login is broken - accesstoken works. i also found out that the docker-image is allready using the "pr Add encryption and verification support" which does not work - at least in my setup - the verification just times out. the simplematrixbotlib is 2.7.4 and matrix-nio is 0.19.0 see pip freeze down below.

first verification try

2022-11-06 10:46:32,494 DEBUG:('INSERT OR REPLACE INTO "synctokens" ("token", "account_id") VALUES (?, ?)', ['<<redacted>>_182474_2327_0', 1])
Connected to http://matrix_synapse:8008 as @registration-bot:matrix.some.tld (<<redacted>>)
This bot's public fingerprint ("Session key") for one-sided verification is: o493 <<redacted>>
[('📌', 'Pin'), ('🐟', 'Fish'), ('🦋', 'Butterfly'), ('🚲', 'Bicycle'), ('🌳', 'Tree'), ('💡', 'Light Bulb'), ('⌛', 'Hourglass')]
2022-11-06 10:46:32,495 DEBUG:('BEGIN', None)
2022-11-06 10:46:32,496 DEBUG:('SELECT "t1"."id", "t1"."account", "t1"."user_id", "t1"."device_id", "t1"."shared" FROM "accounts" AS "t1" WHERE (("t1"."user_id" = ?) AND ("t1"."device_id" = ?)) LIMIT ? OFFSET ?', ['@registration-bot:matrix.some.tld', '<<redacted>>', 1, 0])
2022-11-06 10:46:38,515 DEBUG:('SELECT "t1"."id", "t1"."account", "t1"."user_id", "t1"."device_id", "t1"."shared" FROM "accounts" AS "t1" WHERE (("t1"."user_id" = ?) AND ("t1"."device_id" = ?)) LIMIT ? OFFSET ?', ['@registration-bot:matrix.some.tld', '<<redacted>>', 1, 0])
2022-11-06 10:46:38,515 DEBUG:('INSERT OR REPLACE INTO "synctokens" ("token", "account_id") VALUES (?, ?)', ['<<redacted>>_182475_2327_0', 1])
2022-11-06 10:46:38,517 DEBUG:('BEGIN', None)
2022-11-06 10:46:38,517 DEBUG:('SELECT "t1"."id", "t1"."account", "t1"."user_id", "t1"."device_id", "t1"."shared" FROM "accounts" AS "t1" WHERE (("t1"."user_id" = ?) AND ("t1"."device_id" = ?)) LIMIT ? OFFSET ?', ['@registration-bot:matrix.some.tld', '<<redacted>>', 1, 0])
2022-11-06 10:46:40,379 DEBUG:('SELECT "t1"."id", "t1"."account", "t1"."user_id", "t1"."device_id", "t1"."shared" FROM "accounts" AS "t1" WHERE (("t1"."user_id" = ?) AND ("t1"."device_id" = ?)) LIMIT ? OFFSET ?', ['@registration-bot:matrix.some.tld', '<<redacted>>', 1, 0])
2022-11-06 10:46:40,380 DEBUG:('INSERT OR REPLACE INTO "synctokens" ("token", "account_id") VALUES (?, ?)', ['<<redacted>>_182476_2327_0', 1])
2022-11-06 10:46:40,381 DEBUG:('BEGIN', None)
2022-11-06 10:46:40,382 DEBUG:('SELECT "t1"."id", "t1"."account", "t1"."user_id", "t1"."device_id", "t1"."shared" FROM "accounts" AS "t1" WHERE (("t1"."user_id" = ?) AND ("t1"."device_id" = ?)) LIMIT ? OFFSET ?', ['@registration-bot:matrix.some.tld', '<<redacted>>', 1, 0])
2022-11-06 10:47:40,545 DEBUG:('SELECT "t1"."id", "t1"."account", "t1"."user_id", "t1"."device_id", "t1"."shared" FROM "accounts" AS "t1" WHERE (("t1"."user_id" = ?) AND ("t1"."device_id" = ?)) LIMIT ? OFFSET ?', ['@registration-bot:matrix.some.tld', '<<redacted>>', 1, 0])
2022-11-06 10:47:40,546 DEBUG:('INSERT OR REPLACE INTO "synctokens" ("token", "account_id") VALUES (?, ?)', ['<<redacted>>_182476_2327_0', 1])
2022-11-06 10:47:40,547 DEBUG:('BEGIN', None)
2022-11-06 10:47:40,548 DEBUG:('SELECT "t1"."id", "t1"."account", "t1"."user_id", "t1"."device_id", "t1"."shared" FROM "accounts" AS "t1" WHERE (("t1"."user_id" = ?) AND ("t1"."device_id" = ?)) LIMIT ? OFFSET ?', ['@registration-bot:matrix.some.tld', '<<redacted>>', 1, 0])
2022-11-06 10:47:46,567 DEBUG:('SELECT "t1"."id", "t1"."account", "t1"."user_id", "t1"."device_id", "t1"."shared" FROM "accounts" AS "t1" WHERE (("t1"."user_id" = ?) AND ("t1"."device_id" = ?)) LIMIT ? OFFSET ?', ['@registration-bot:matrix.some.tld', '<<redacted>>', 1, 0])
2022-11-06 10:47:46,567 DEBUG:('INSERT OR REPLACE INTO "synctokens" ("token", "account_id") VALUES (?, ?)', ['<<redacted>>_182477_2327_0', 1])
2022-11-06 10:47:46,568 DEBUG:('BEGIN', None)
2022-11-06 10:47:46,569 DEBUG:('SELECT "t1"."id", "t1"."account", "t1"."user_id", "t1"."device_id", "t1"."shared" FROM "accounts" AS "t1" WHERE (("t1"."user_id" = ?) AND ("t1"."device_id" = ?)) LIMIT ? OFFSET ?', ['@registration-bot:matrix.some.tld', '<<redacted>>', 1, 0])
2022-11-06 10:48:40,724 DEBUG:('SELECT "t1"."id", "t1"."account", "t1"."user_id", "t1"."device_id", "t1"."shared" FROM "accounts" AS "t1" WHERE (("t1"."user_id" = ?) AND ("t1"."device_id" = ?)) LIMIT ? OFFSET ?', ['@registration-bot:matrix.some.tld', '<<redacted>>', 1, 0])
2022-11-06 10:48:40,724 DEBUG:('INSERT OR REPLACE INTO "synctokens" ("token", "account_id") VALUES (?, ?)', ['<<redacted>>_182477_2327_0', 1])
2022-11-06 10:48:40,725 DEBUG:('BEGIN', None)
2022-11-06 10:48:40,726 DEBUG:('SELECT "t1"."id", "t1"."account", "t1"."user_id", "t1"."device_id", "t1"."shared" FROM "accounts" AS "t1" WHERE (("t1"."user_id" = ?) AND ("t1"."device_id" = ?)) LIMIT ? OFFSET ?', ['@registration-bot:matrix.some.tld', '<<redacted>>', 1, 0])

second verfication try:

2022-11-06 10:54:47,753 DEBUG:('SELECT "t1"."id", "t1"."account", "t1"."user_id", "t1"."device_id", "t1"."shared" FROM "accounts" AS "t1" WHERE (("t1"."user_id" = ?) AND ("t1"."device_id" = ?)) LIMIT ? OFFSET ?', ['@registration-bot:matrix.some.tld', '<<redacted>>', 1, 0])
2022-11-06 10:54:47,753 DEBUG:('INSERT OR REPLACE INTO "synctokens" ("token", "account_id") VALUES (?, ?)', ['<<redacted>>_182478_2327_0', 1])
2022-11-06 10:54:47,788 DEBUG:('BEGIN', None)
2022-11-06 10:54:47,789 DEBUG:('SELECT "t1"."id", "t1"."account", "t1"."user_id", "t1"."device_id", "t1"."shared" FROM "accounts" AS "t1" WHERE (("t1"."user_id" = ?) AND ("t1"."device_id" = ?)) LIMIT ? OFFSET ?', ['@registration-bot:matrix.some.tld', '<<redacted>>', 1, 0])
2022-11-06 10:54:47,848 DEBUG:('SELECT "t1"."id", "t1"."account", "t1"."user_id", "t1"."device_id", "t1"."shared" FROM "accounts" AS "t1" WHERE (("t1"."user_id" = ?) AND ("t1"."device_id" = ?)) LIMIT ? OFFSET ?', ['@registration-bot:matrix.some.tld', '<<redacted>>', 1, 0])
2022-11-06 10:54:47,849 DEBUG:('INSERT OR REPLACE INTO "synctokens" ("token", "account_id") VALUES (?, ?)', ['<<redacted>>_182481_2327_0', 1])
Do the emojis match? (Y/N) (C for Cancel) Traceback (most recent call last):
  File "/opt/venv/lib/python3.10/site-packages/simplematrixbotlib/callbacks.py", line 142, in emoji_verification
    yn = input("Do the emojis match? (Y/N) (C for Cancel) ")
EOFError: EOF when reading a line

Traceback (most recent call last):
  File "/opt/venv/lib/python3.10/site-packages/simplematrixbotlib/callbacks.py", line 170, in emoji_verification
    todevice_msg = sas.get_mac()
  File "/opt/venv/lib/python3.10/site-packages/nio/crypto/sas.py", line 520, in get_mac
    raise LocalProtocolError("SAS string wasn't yet accepted")
nio.exceptions.LocalProtocolError: SAS string wasn't yet accepted

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/venv/lib/python3.10/site-packages/simplematrixbotlib/callbacks.py", line 171, in emoji_verification
    except LocalProtocolError as e:
NameError: name 'LocalProtocolError' is not defined

Verification has been cancelled by @registration-bot:matrix.some.tld for reason "Timed out".
[('🍌', 'Banana'), ('⏰', 'Clock'), ('🌙', 'Moon'), ('🚲', 'Bicycle'), ('🤖', 'Robot'), ('🦁', 'Lion'), ('🌙', 'Moon')]
2022-11-06 10:54:47,851 DEBUG:('BEGIN', None)
2022-11-06 10:54:47,851 DEBUG:('SELECT "t1"."id", "t1"."account", "t1"."user_id", "t1"."device_id", "t1"."shared" FROM "accounts" AS "t1" WHERE (("t1"."user_id" = ?) AND ("t1"."device_id" = ?)) LIMIT ? OFFSET ?', ['@registration-bot:matrix.some.tld', '<<redacted>>', 1, 0])
2022-11-06 10:54:53,876 DEBUG:('SELECT "t1"."id", "t1"."account", "t1"."user_id", "t1"."device_id", "t1"."shared" FROM "accounts" AS "t1" WHERE (("t1"."user_id" = ?) AND ("t1"."device_id" = ?)) LIMIT ? OFFSET ?', ['@registration-bot:matrix.some.tld', '<<redacted>>', 1, 0])
2022-11-06 10:54:53,876 DEBUG:('INSERT OR REPLACE INTO "synctokens" ("token", "account_id") VALUES (?, ?)', ['<<redacted>>_182482_2327_0', 1])
2022-11-06 10:54:53,877 DEBUG:('BEGIN', None)
2022-11-06 10:54:53,878 DEBUG:('SELECT "t1"."id", "t1"."account", "t1"."user_id", "t1"."device_id", "t1"."shared" FROM "accounts" AS "t1" WHERE (("t1"."user_id" = ?) AND ("t1"."device_id" = ?)) LIMIT ? OFFSET ?', ['@registration-bot:matrix.some.tld', '<<redacted>>', 1, 0])
2022-11-06 10:55:00,135 DEBUG:('SELECT "t1"."id", "t1"."account", "t1"."user_id", "t1"."device_id", "t1"."shared" FROM "accounts" AS "t1" WHERE (("t1"."user_id" = ?) AND ("t1"."device_id" = ?)) LIMIT ? OFFSET ?', ['@registration-bot:matrix.some.tld', '<<redacted>>', 1, 0])
2022-11-06 10:55:00,136 DEBUG:('INSERT OR REPLACE INTO "synctokens" ("token", "account_id") VALUES (?, ?)', ['<<redacted>>_182483_2327_0', 1])
2022-11-06 10:55:00,137 DEBUG:('BEGIN', None)
2022-11-06 10:55:00,138 DEBUG:('SELECT "t1"."id", "t1"."account", "t1"."user_id", "t1"."device_id", "t1"."shared" FROM "accounts" AS "t1" WHERE (("t1"."user_id" = ?) AND ("t1"."device_id" = ?)) LIMIT ? OFFSET ?', ['@registration-bot:matrix.some.tld', '<<redacted>>', 1, 0])

pip freeze:

aiodns==3.0.0
aiofiles==0.6.0
aiohttp==3.8.3
aiohttp-socks==0.7.1
aiosignal==1.2.0
async-timeout==4.0.2
atomicwrites==1.4.1
attrs==22.1.0
Brotli==1.0.9
cachetools==4.2.4
cffi==1.15.1
charset-normalizer==2.1.1
cryptography==38.0.1
frozenlist==1.3.1
future==0.18.2
h11==0.12.0
h2==4.1.0
hpack==4.0.0
hyperframe==6.0.1
idna==3.4
jsonschema==3.2.0
Logbook==1.5.3
Markdown==3.4.1
matrix-nio==0.19.0
matrix-registration-bot==1.2.2
multidict==6.0.2
peewee==3.15.3
Pillow==9.2.0
pycares==4.2.2
pycparser==2.21
pycryptodome==3.15.0
pyrsistent==0.18.1
python-cryptography-fernet-wrapper==1.0.4
python-olm==3.1.3
python-socks==2.0.3
PyYAML==6.0
simplematrixbotlib==2.7.4
six==1.16.0
toml==0.10.2
unpaddedbase64==2.1.0
yarl==1.8.1

BR Takalele

moan0s commented 1 year ago

Thanks for the report. I really hope to get to it soon. First I have to do some work in the upstream repository (simplematrixbotlib) which currently blocks work here

hank commented 1 year ago

I ran into this today and used BOT_ACCESS_TOKEN as a workaround. I got the token using the curl command in the README.

moan0s commented 1 year ago

This is fixed now in the latest docker image. Can you confirm that @hank @Takalele or @LostRager ? I am very sorry that it took so long

moan0s commented 1 year ago

A user in the chat also confirmed that the latest docker image (1.2.2-1) fixes the issue. Therefore I'm closing this issue, but feel to reopen if needed 😊

moan0s commented 1 year ago

Closing