You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+48-17Lines changed: 48 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,13 +12,15 @@ The service authenticates to the Matrix homeserver as an **Application Service**
12
12
13
13
The proxy is configured via environment variables. Minimal required env:
14
14
15
-
-`MATRIX_HOMESERVER_URL`: URL of your Matrix homeserver (e.g. `https://matrix.example`)
15
+
-`MATRIX_HOMESERVER_URL`: URL of your Matrix homeserver (e.g. `https://matrix.example`),
16
+
used also to derive the hostname when constructing Matrix IDs from external auth responses
16
17
-`SUPER_ADMIN_TOKEN`: the Application Service `as_token` from your registration file
17
18
-`PROXY_PORT` (optional): port to listen on (default: `8080`)
18
19
-`AS_USER_ID` (optional): the user ID of the Application Service bot (default: `@_acrobits_proxy:matrix.example`)
19
20
-`PROXY_URL` (optional): public-facing URL of this proxy (e.g. `https://matrix-proxy.example.com`) - **required for push notification support**
21
+
-`EXT_AUTH_URL` (optional): external HTTP endpoint used to validate extension+password for push token reports (default: `https://voice.gs.nethserver.net/freepbx/testextauth`)
22
+
-`EXT_AUTH_TIMEOUT_S` (optional): timeout in seconds for calls to `EXT_AUTH_URL` (default: `5`)
-`MAPPING_FILE` (optional): path to a JSON file containing -to-Matrix mappings to load at startup
22
24
-`PUSH_TOKEN_DB_PATH` (optional): path to a database file for storing push tokens
23
25
-`CACHE_TTL_SECONDS` (optional): time-to-live for in-memory cache entries (default: `3600` seconds)
24
26
@@ -49,20 +51,7 @@ The `LOGLEVEL` environment variable controls the verbosity of application logs:
49
51
50
52
For debugging mapping and API issues, set `LOGLEVEL=DEBUG` to see detailed trace information.
51
53
52
-
### Loading Mappings from File
53
54
54
-
You can pre-load -to-Matrix mappings at startup by providing a `MAPPING_FILE` environment variable pointing to a JSON file. This is useful for initializing the proxy with a set of known mappings.
55
-
56
-
See `docs/example-mappings.json` for an example format.
57
-
58
-
Usage:
59
-
60
-
```bash
61
-
export MAPPING_FILE="/path/to/mappings.json"
62
-
./matrix2acrobits
63
-
```
64
-
65
-
The loaded mappings will be logged at startup with the message: `mappings loaded from file count=N file=/path/to/mappings.json`
All client API endpoints (`/api/client/fetch_messages`, `/api/client/send_message`, `/api/client/push_token_report`) require authentication via an external authentication service.
77
+
78
+
### External Auth Flow
79
+
80
+
When a client sends a request, the proxy:
81
+
1. Extracts the `username` (extension) and `password` from the request.
82
+
2. Calls `EXT_AUTH_URL` with a POST request containing JSON: `{"extension":"<username>","secret":"<password>"}`.
83
+
3. On successful auth (200), parses the response for `main_extension`, `sub_extensions`, and `user_name`, which are converted into a mapping and saved.
84
+
4. On failure (401 or other error), returns an authentication error and does NOT save the push token or create a mapping.
85
+
5. Auth responses are cached in-memory for `CACHE_TTL_SECONDS` seconds to reduce external service load.
86
+
87
+
### Request Requirements
88
+
89
+
-**`/api/client/fetch_messages`**: Requires `username` and `password` fields.
90
+
-**`/api/client/send_message`**: Requires `from` (sender extension/ID) and `password` fields.
91
+
-**`/api/client/push_token_report`**: Requires `username` (extension) and `password` fields.
92
+
93
+
If any request is missing a `password`, it fails with authentication error.
94
+
85
95
## TODO
86
96
87
97
The following features are not yet implemented:
88
98
89
-
- sendMessage: implement password validation on send messages, currently the password is ignored
90
99
- when a private room is deleted, there is no way to send messages to the user
0 commit comments