matrix-org / matrix-org/matrix-hookshot
Encryption: Unable to start matrix-hookshot with MAS
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 450
- Forks
- 95
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 23
Description
Config:
1. Docker serves all matrix services.
2. `Matrix Authentication Service` is installed and configured to use a OIDC upstream.
3. Using Authelia for IdP, and SWAG as a reverse proxy.
4. This worked until I tried to get encryption working.
```
WARN 11:27:02:665 [Config]
You have enabled encryption support in the bridge. This feature is HIGHLY EXPERIMENTAL AND SUBJECT TO CHANGE.
For more details, see https://github.com/matrix-org/matrix-hookshot/issues/594.
INFO 11:27:02:670 [ListenerService] Listening on http://0.0.0.0:9000 for webhooks
DEBUG 11:27:02:670 [LogWrapper] Reconfigured logging
INFO 11:27:02:671 [Appservice] Initialising Redis storage
INFO 11:27:02:673 [Appservice] Initialising crypto storage
INFO 11:27:02:679 [UserTokenStore] Loading token key file /data/passkey.pem
INFO 11:27:02:720 [Bridge] Starting up
INFO 11:27:02:721 [RedisASProvider] Successfully connected
INFO 11:27:02:721 [Bridge] Ensuring homeserver can be reached...
INFO 11:27:02:742 [BotUsersManager] Ensuring bot users are set up...
DEBUG 11:27:02:742 [BotUsersManager] Ensuring bot user @hookshot:mydomain.xyz is registered
DEBUG 11:27:02:743 [BotUsersManager] Ensuring profile for @hookshot:mydomain.xyz is updated
INFO 11:27:02:747 [BotUsersManager] Getting joined rooms...
ERROR 11:27:02:750 [MatrixHttpClient] (REQ-5) { errcode: 'M_UNRECOGNIZED', error: 'Invalid login type' }
ERROR 11:27:02:751 [Appservice] Failed to set up crypto on intent @hookshot:mydomain.xyz MatrixError: M_UNRECOGNIZED: Invalid login type
at doHttpRequest (/usr/bin/matrix-hookshot/node_modules/matrix-bot-sdk/lib/http.js:95:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async descriptor.value (/usr/bin/matrix-hookshot/node_modules/matrix-bot-sdk/lib/metrics/decorators.js:19:32)
at async /usr/bin/matrix-hookshot/node_modules/matrix-bot-sdk/lib/appservice/Intent.js:166:41 {
body: { errcode: 'M_UNRECOGNIZED', error: 'Invalid login type' },
statusCode: 400,
errcode: 'M_UNRECOGNIZED',
error: 'Invalid login type',
retryAfterMs: undefined
}
node:internal/process/promises:289
triggerUncaughtException(err, true /* fromPromise */);
^
MatrixError: M_UNRECOGNIZED: Invalid login type
at doHttpRequest (/usr/bin/matrix-hookshot/node_modules/matrix-bot-sdk/lib/http.js:95:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async descriptor.value (/usr/bin/matrix-hookshot/node_modules/matrix-bot-sdk/lib/metrics/decorators.js:19:32)
at async /usr/bin/matrix-hookshot/node_modules/matrix-bot-sdk/lib/appservice/Intent.js:166:41 {
body: { errcode: 'M_UNRECOGNIZED', error: 'Invalid login type' },
statusCode: 400,
errcode: 'M_UNRECOGNIZED',
error: 'Invalid login type',
retryAfterMs: undefined
}
Node.js v20.12.2
```
In the MAS logs:
```
12024-10-26T11:07:44.243634Z ERROR http.server.request{otel.kind="server" otel.name="POST /_matrix/client/:version/login" network.protocol.name="http" network.protocol.version="1.1" http.request.method="POST" url.path="/_matrix/client/v3/login" url.scheme="http" http.route="/_matrix/client/:version/login" url.query="user_id=%40hookshot%somedomain.xyz"}:handlers.compat.login.post: mas_handlers::compat::login: crates/handlers/src/compat/login.rs:219: error=unsupported login method
```
So, MAS requires this: https://element-hq.github.io/matrix-authentication-service/setup/reverse-proxy.html#compatibility-layer
Which means that requests that go to that endpoint, like it appears to be, it's making a `POST` request to https://matrix.mydomain.xyz/_matrix/client/v3/login?user_id=%40hookshot%3Adomain.xyz
That will be redirected to MAS. it then fails to login. Then also, if you use the internal IP, instead of the matrix homeserver URL like above, such as http://172.28.0.100:8008 then it fails because the endpoint is already not accepting login states at THAT endpoint since it's bypassing the compatibility layer.
Anyways, does anyone have this working with MAS?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the encryption setup that fails while initializing the @hookshot intent, focusing on the Matrix client login request shown in the stack trace. Reproduce the startup with Matrix Authentication Service and its compatibility layer; done means hookshot starts encryption successfully without the M_UNRECOGNIZED login error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- authentication, backend, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 32/100