Compare commits

...
Author SHA1 Message Date
Ginger fe8314bb4d chore: Fix typo 2026-11-05 10:35:18 -05:00
Ginger 4922e5da01 feat: Add support for OAuth client credentials grant 2026-11-05 10:35:17 -05:00
Erwan Leboucher 8c720e5427 fix: Store to-device messages before syncs can read their count 2026-11-05 15:17:36 +00:00
Erwan Leboucher fb389cb6f9 fix: Record device list changes before syncs can read their count
Signed-off-by: Erwan Leboucher <erwanleboucher@gmail.com>
2026-11-05 15:17:23 +00:00
Bardi Harborow db86d42801 fix: Compare push user_is_target against the notified user
`user_is_target` was set by comparing a member event's `state_key` to its
sender, rather than to the user receiving the notification.
2026-11-05 15:27:50 +11:00
Bardi Harborow 223e889459 fix: Return 405 when setting m.fully_read via account data
The spec requires servers to reject client writes to server-managed
account data types with 405 M_BAD_JSON. We returned 400.
2026-11-04 19:32:17 +00:00
Bardi Harborow 219e8d2e1e fix: Return M_UNKNOWN_DEVICE for unknown masqueraded appservice devices
When an appservice masqueraded as a device_id that does not exist for
the user, we returned 403 M_FORBIDDEN. The spec requires 400
M_UNKNOWN_DEVICE.
2026-11-04 19:32:17 +00:00
Bardi Harborow 4d0ccd998f fix: Return M_PROFILE_TOO_LARGE for oversize profiles
Profile updates that would push the profile over 64 KiB were rejected
with an untyped error, producing a 500. The spec requires 400
M_PROFILE_TOO_LARGE, which ruma now provides.
2026-11-04 19:32:17 +00:00
Bardi Harborow 42609eab02 fix: Return M_KEY_TOO_LARGE for oversize profile keys
Profile keys longer than 255 bytes were rejected with 413 M_TOO_LARGE.
The spec requires 400 M_KEY_TOO_LARGE, which ruma now provides.
2026-11-04 19:32:17 +00:00
Bardi Harborow dad9e1426c fix: Advertise m.forget_forced_upon_leave capability according to config 2026-11-04 18:48:40 +00:00
Ginger 34c5787af0 fix: Fix join rule evaluation for servers again
Reviewed-by: timedout <git@nexy7574.co.uk>
Reviewed-by: Jade Ellis <jade@ellis.link>
2026-11-04 12:24:51 -05:00
Renovate Bot d2eeae34a9 chore(deps): update ghcr.io/renovatebot/renovate docker tag to v44.210.1 2026-11-04 05:01:50 +00:00
Ginger 2ee28c1b82 fix: Fix busted axum feature list 2026-11-03 20:48:58 -05:00
Ginger c77bbf6d18 fix: Fix busted url_preview feature gate 2026-11-03 20:41:11 -05:00
Erwan Leboucher 0727d564a2 fix: Avoid v12 room ID collisions when creating rooms concurrently
Fixes #2424. v12 rooms created by the same user in the same millisecond got the same room ID, so they ended up as one room.

Reviewed-on: https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2433
Reviewed-by: nex <me@nexy7574.co.uk>
Reviewed-by: Jade Ellis <jade@ellis.link>
2026-11-03 09:52:43 +00:00
Renovate Bot 0e5baa9399 chore(deps): update https://github.com/taiki-e/install-action digest to 682ce6c 2026-11-03 05:03:31 +00:00
Ginger d8229a7933 fix(ci): Use local versions of workflows hosted on tomfos.tr 2026-11-02 14:03:52 -05:00
Renovate Bot ddbdd1ed0c chore(deps): update ruma digest to 0ed7fba 2026-11-02 05:36:01 +00:00
timedout f3d8e8d688 chore: Reformat 2026-11-02 00:50:41 +00:00
Ginger 5a4f3acae4 chore: Changelog 2026-11-02 00:44:02 +00:00
Ginger dc03f2136a fix: Validate OAuth HTTPS redirect URIs are subdomains of the client domain 2026-11-02 00:44:02 +00:00
Erwan Leboucher abf8f878bc fix: gap fill outliers that are missing prev events
Signed-off-by: Erwan Leboucher <erwanleboucher@gmail.com>
2026-10-31 09:02:27 +01:00
timedout cb27a2082d chore: Add newsfrag 2026-10-30 00:56:10 +00:00
timedout 068ba88378 style: Fix formatting 2026-10-30 00:54:52 +00:00
timedout 60de549cf9 perf: Write empty rows when replacing extremities 2026-10-30 00:51:52 +00:00
timedout 363097b31b fix: Centralise extremity progression 2026-10-30 00:51:52 +00:00
timedout d128207d71 fix: Make the extremity check consistency migration faster 2026-10-30 00:51:51 +00:00
timedout c6832372c2 feat: Add command to enumerate extremities 2026-10-30 00:51:51 +00:00
timedout 14f5f62182 fix: Only consider accepted PDUs in extremity consistency check 2026-10-30 00:51:51 +00:00
timedout 5208efcb5e fix: Make migration handle excessive extremities too 2026-10-30 00:51:51 +00:00
timedout 224cf04936 fix: Never allow unknown/backfilled PDUs to become extremities 2026-10-30 00:51:51 +00:00
timedout ae26d5c239 fix: Add startup migration to re-process existing extremities on-disk 2026-10-30 00:51:51 +00:00
timedout 30f62eef25 style: reformat 2026-10-30 00:51:51 +00:00
timedout b04ffd7e6a fix: Correctly remove extremities after creating a new event 2026-10-30 00:51:51 +00:00
timedout bc15b7b668 fix: Remove dead references to mark_event_referenced 2026-10-30 00:51:50 +00:00
timedout 3eb2788eb9 feat: Only track appended extremities 2026-10-30 00:51:47 +00:00
timedout 3b0fc25cd3 chore: Add newsfrag 2026-10-30 00:43:55 +00:00
timedout b580379a2d fix: Only check that room_id is not present on create events in PDU check 1 2026-10-30 00:43:55 +00:00
timedout 3c19206534 fix: Perform PDU checks 1, 2, and 3 before yielding a gapfilled PDU
Fixes #2386
2026-10-30 00:43:55 +00:00
Renovate Bot 7358712fb9 chore(deps): update rust crate tower-sec-fetch to 0.2.0 2026-10-29 13:40:37 +00:00
Renovate Bot 18bd828b8b chore(deps): update rust crate tokio to v1.53.3 [security] 2026-10-29 09:06:20 +00:00
Julian Anderson 4c62b96821 chore: Bump sentry and update config to required builder pattern 2026-10-29 09:05:13 +00:00
stratself a6b8bfe2c9 chore: Add changelog for 2324 2026-10-28 23:33:22 +00:00
stratself 028ffabebf docs(troubleshooting,perf): Simplify trusted servers wordings 2026-10-28 23:33:22 +00:00
stratself b70131c301 docs(troubleshooting): Improve wordings a little bit 2026-10-28 23:33:22 +00:00
stratself d4bfb38bd5 docs(troubleshooting): Update complex debug log filters 2026-10-28 23:33:22 +00:00
stratself d4ae9f9ac1 docs(troubleshooting): Add redirs to other troubleshooting topics in other pages 2026-10-28 23:33:22 +00:00
stratself 1247cf1c80 docs(livekit): Shorten redundant docker loopback section 2026-10-28 23:33:22 +00:00
stratself 0d9bb6ba7c docs(troubleshooting): Add networking issues for docker 2026-10-28 23:33:22 +00:00
stratself e769ceb147 docs(troubleshooting): Initialize docker troubleshooting section 2026-10-28 23:33:22 +00:00
stratself 206aaf6893 fix: Newline 2026-10-28 23:23:59 +00:00
stratself b07093c7ab chore: Add changelog for #2353 2026-10-28 23:23:59 +00:00
stratself 5c3bc643d2 docs(docker): Add backup/restore instructions 2026-10-28 23:23:59 +00:00
stratself c5f28c8276 docs(docker): Document volumes usage in Appendix section 2026-10-28 23:23:59 +00:00
stratself 17d575c3e3 docs(docker): Use bind mounts instead of docker volumes
Old volumes of `db` are replaced with bind mounts of `continuwuity-data`.
Other volumes are also converted. This is more beginner-friendly.
2026-10-28 23:23:59 +00:00
Erwan Leboucher 2604b13ef6 chore: Add changelog 2026-10-28 23:22:52 +00:00
Erwan Leboucher c5e976f4bc fix: Store event_id on state events received from send_knock 2026-10-28 23:22:52 +00:00
Renovate Bot a825b7db8b chore(deps): update ruma digest to e03080c 2026-10-28 23:20:41 +00:00
Renovate Bot bdb376c8fd chore(deps): update rust crate lock_api to 0.5.0 2026-10-28 23:20:31 +00:00
Freek a96fec4cbc chore: Add changelog 2026-10-28 22:50:03 +00:00
Freek ea5d2f4d4c fix: spelling 2026-10-28 22:50:03 +00:00
stratself f2cf1b2331 docs(oidc): Sweepfixes for PR2341
* Replaces yourdomain.com with example.com (other pages use this)
* Improve initial domain instructions, remove important block there
* Capitalize "Bare Metal/Docker" tabs
2026-10-28 22:50:03 +00:00
Freek 1c82c57d9f docs(oidc): PR feedback 2026-10-28 22:50:03 +00:00
Freek c6d220dc60 docs(oidc): Styling and QoL fixes 2026-10-28 22:50:03 +00:00
Freek 0adfd32b0c docs(oidc): Simplify, deduplicate and improve consistency 2026-10-28 22:50:03 +00:00
Freek 4cd0e737db docs(oidc): PR feedback: Use tabs for different identity providers, make "Configuring Continuwuity" section more idp-independent 2026-10-28 22:50:03 +00:00
Freek e8593eeaca docs(oidc): Add Authelia to OIDC instructions 2026-10-28 22:50:03 +00:00
Jade Ellis 6fae2475b8 style: Format 2026-10-28 21:56:38 +00:00
Jade Ellis 0ceabb4b3e chore: Changelog 2026-10-28 21:49:26 +00:00
Jade Ellis addd1875d3 refactor(uiaa): Defer uiaa_sessions lock until session insert
Do not hold the uiaa_sessions lock across device lookup in OAuth or
during initial validation. Lock the map only when inserting the newly
created session.
2026-10-28 21:48:55 +00:00
Jade Ellis 24b1e2ebe8 refactor(service): Use SyncRwLock and SyncMutex for in-memory services
Convert in-memory data structures in appservice, rooms::typing, and sync
wakers to use SyncRwLock and SyncMutex. Drop appservice locks before
making outbound network requests in room alias queries and federation
invites.
2026-10-28 21:48:22 +00:00
Jade Ellis 5297e01357 refactor(metrics): Replace std::sync::Mutex with SyncMutex
Replace std::sync::Mutex with parking_lot::Mutex (SyncMutex) in
core::metrics::runtime_intervals. Note that info::introspection retains
std::sync::Mutex because parking_lot panics in dtor after thread locals
are destroyed.
2026-10-28 21:47:41 +00:00
Jade Ellis 18f5f4fbfa refactor(threepid): Use SyncMutex and decouple guard from ValidSession
Change threepid sessions and send_attempts to SyncMutex and avoid

holding the sessions mutex across callers of get_valid_session.
2026-10-28 21:47:09 +00:00
Jade Ellis 98ae1fcaa1 refactor(oauth): Avoid holding pending grants lock across async calls
Convert pending grants and tickets to SyncMutex and scope locks tightly

before awaiting external calls in grant_info and redeem_token.
2026-10-28 21:46:29 +00:00
Jade Ellis ad0181a3d8 refactor(service): Scope services.manager lock during lifecycle calls
Avoid holding the services.manager lock across manager.start(),

manager.stop(), and manager.poll() async invocations.
2026-10-28 21:45:49 +00:00
Jade Ellis 938b3d2825 refactor(admin): Release handle lock before command execution
Change admin service handle to SyncRwLock and copy the handler

function pointer before awaiting execution to prevent deadlock.
2026-10-28 21:45:18 +00:00
Jade Ellis 35d606eeb7 fix(main): Prevent re-entrant read lock deadlock during reload
Reuse the already-held main_lock when checking module staleness

in run() instead of re-acquiring server.mods.read().
2026-10-28 21:44:35 +00:00
Jade Ellis 9c4f84940e fix(service): Prevent remote join lock inversion
Do not hold state.mutex across join_remote_room to prevent an ABBA

deadlock against mutex_federation.
2026-10-28 21:44:02 +00:00
Renovate Bot 2badf2dfe9 chore(deps): update dependency node to v26 2026-10-28 16:57:00 +00:00
Renovate Bot 2b18fa12bf chore(deps): update ghcr.io/renovatebot/renovate docker tag to v44.190.1 2026-10-28 05:17:21 +00:00
Jade 747a612fd1 docs: Update funding yaml 2026-10-27 11:01:46 +00:00
Renovate Bot be5c94074c chore(deps): update github-actions-digest 2026-10-27 05:19:19 +00:00
Renovate Bot 8fff8f66d3 chore(deps): update ghcr.io/renovatebot/renovate docker tag to v44.181.10 2026-10-26 05:01:31 +00:00
Ginger 81c62c4a35 fix: Silence tower_sessions warning 2026-10-25 13:47:36 -04:00
Ginger b848aed1bb chore: Update git-blame-ignore-revs 2026-10-25 13:33:31 -04:00
Ginger 3295427af6 fix: Don't check room summary access rules on remote rooms 2026-10-25 14:00:28 +00:00
Renovate Bot ffef3911e7 chore(deps): update rust crate loole to 0.6.0 2026-10-25 08:09:43 +00:00
Renovate Bot 263ccd6b0b chore(deps): update rust-zerover-patch-updates 2026-10-25 08:08:31 +00:00
Renovate Bot 0ad4fc1c25 chore(deps): update dependency cargo-bins/cargo-binstall to v1.26.1 2026-10-25 08:00:13 +00:00
Renovate Bot a13a50836b chore(deps): update rust-non-major 2026-10-25 05:19:08 +00:00
Ginger ef1378509e fix: Remove deactivate link from account page 2026-10-24 15:14:01 -04:00
timedout 9c27441acf style: Reformat with nightly 2026-10-23 23:37:51 +02:00
Erwan Leboucher c5b70958cf fix: preserve event order during state resolution
Signed-off-by: Erwan Leboucher <erwanleboucher@gmail.com>
2026-10-23 23:19:45 +02:00
Filip Kszczot 3b2afe03ac docs(deploying/generic): add haproxy host header quirk
Signed-off-by: Filip Kszczot <filip@kszczot.pl>
2026-10-23 18:13:13 +00:00
Ginger 4a20fd62a9 chore: News fragment 2026-10-21 18:29:30 -04:00
Ginger 783a68cc90 fix: Add link to the account management panel to the first run web UI 2026-10-21 18:27:42 -04:00
Renovate Bot 2f93711a09 chore(deps): update https://github.com/taiki-e/install-action digest to 8cca091 2026-10-20 05:17:52 +00:00
Renovate Bot d72a27b249 chore(deps): update ghcr.io/renovatebot/renovate docker tag to v44.167.5 2026-10-19 05:19:59 +00:00
timedout b0a5caf576 perf: Fetch auth chain events in parallel 2026-10-16 18:32:38 +01:00
timedout 17ddd3966d fix: Apply proper limits to get_missing_events 2026-10-16 18:19:22 +01:00
timedout fe02b03d15 style: Stop warning when encountering an unknown event in get_missing_events
This is actually an expected condition, but it's retained as a debug warning as it may be relevant in debugging
2026-10-16 18:11:55 +01:00
renovate a973f3e10c chore(Nix): Updated flake hashes 2026-10-16 05:07:35 +00:00
Renovate Bot ab939da036 chore(deps): update rust to v1.99.1 2026-10-16 05:02:46 +00:00
Ginger 138dd61f82 chore: Switch to upstream ruma 2026-10-15 22:56:04 -04:00
Ginger 98c694eaa3 chore: Add some comments 2026-10-15 22:56:04 -04:00
Ginger e6ca06a501 feat: Add support for MSC4560 2026-10-15 22:56:04 -04:00
Ginger 4f21fa2bda refactor: Clean up join rule evaluation logic 2026-10-15 22:55:36 -04:00
Jade Ellis 08301fba2a fix: Correctly rebuild the build metadata crate when git changes 2026-10-15 11:31:03 +01:00
Renovate Bot a21b0918dc chore(deps): update rust crate rustls to v0.23.46 [security] 2026-10-15 05:17:59 +00:00
143 changed files with 2544 additions and 1668 deletions

No files matched your search

@@ -44,7 +44,7 @@ runs:
- name: Login to builtin registry
if: ${{ env.BUILTIN_REGISTRY_ENABLED == 'true' }}
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4
uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4
with:
registry: ${{ env.BUILTIN_REGISTRY }}
username: ${{ inputs.registry_user }}
@@ -79,7 +79,7 @@ runs:
- name: Login to builtin registry
if: ${{ env.BUILTIN_REGISTRY_ENABLED == 'true' }}
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4
uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4
with:
registry: ${{ env.BUILTIN_REGISTRY }}
username: ${{ inputs.registry_user }}
+1 -1
View File
@@ -7,7 +7,7 @@ runs:
using: composite
steps:
- name: Install sccache
uses: https://git.tomfos.tr/tom/sccache-action@v1
uses: https://forgejo.ellis.link/continuwuation/sccache-action@v1
- name: Configure sccache
uses: https://github.com/actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9
with:
@@ -29,7 +29,7 @@ runs:
steps:
- name: Detect runner OS
id: runner-os
uses: https://git.tomfos.tr/actions/detect-versions@v1
uses: https://forgejo.ellis.link/continuwuation/detect-versions@v1
- name: Configure cross-compilation architecture
if: inputs.dpkg-arch != ''
+2 -2
View File
@@ -39,7 +39,7 @@ runs:
steps:
- name: Detect runner OS
id: runner-os
uses: https://git.tomfos.tr/actions/detect-versions@v1
uses: https://forgejo.ellis.link/continuwuation/detect-versions@v1
- name: Configure Cargo environment
shell: bash
@@ -147,7 +147,7 @@ runs:
run: echo "::group::📦 Restoring build cache"
- name: Setup sccache
uses: https://git.tomfos.tr/tom/sccache-action@v1
uses: https://forgejo.ellis.link/continuwuation/sccache-action@v1
- name: End build cache restore group
shell: bash
+1 -1
View File
@@ -71,7 +71,7 @@ runs:
- name: Install timelord-cli and git-warp-time
if: steps.check-binaries.outputs.need-install == 'true'
uses: https://github.com/taiki-e/install-action@1168f6810a3cb30a3514bf5756a3b7f0422c6df8 # v2
uses: https://github.com/taiki-e/install-action@682ce6c3c696a4cd5168a05f98e51aa02b877941 # v2
with:
tool: git-warp-time,timelord-cli@3.0.1
+1 -1
View File
@@ -60,7 +60,7 @@ jobs:
cargo-debian-${{ steps.debian-version.outputs.distribution }}-${{ matrix.arch }}-
- name: Setup sccache
uses: https://git.tomfos.tr/tom/sccache-action@v1
uses: https://forgejo.ellis.link/continuwuation/sccache-action@v1
- name: Configure sccache environment
run: |
+2 -2
View File
@@ -28,13 +28,13 @@ jobs:
- name: Detect runner environment
id: runner-env
uses: https://git.tomfos.tr/actions/detect-versions@v1
uses: https://forgejo.ellis.link/continuwuation/detect-versions@v1
- name: Setup Node.js
if: steps.runner-env.outputs.node_major == '' || steps.runner-env.outputs.node_major < '20'
uses: https://github.com/actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7
with:
node-version: 24
node-version: 26
- name: Cache npm dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
+1 -1
View File
@@ -43,7 +43,7 @@ jobs:
name: Renovate
runs-on: ubuntu-latest
container:
image: ghcr.io/renovatebot/renovate:44.151.2@sha256:29b3bf193f855c6f4b7027395a9c66c3417ad8bb6f30458090e1c2363d04eef7
image: ghcr.io/renovatebot/renovate:44.210.1@sha256:45cc73346c44a9afe037f2d19766f2b545b59b2ed31b937b5b09017d2958e45f
options: --tmpfs /tmp:exec
steps:
- name: Checkout
+2 -1
View File
@@ -7,6 +7,7 @@ f419c64aca300a338096b4e0db4c73ace54f23d0
5998a0d883d31b866f7c8c46433a8857eae51a89
# trailing whitespace and newlines
46c193e74b2ce86c48ce802333a0aabce37fd6e9
# rustfmt update that rewrapped tons of comments
# rustfmt updates that rewrapped tons of comments
9fbabe221051e6956a05d8824142092ede68971e
b0c0905472b882ff0cc79232e73d307fd0b5035b
9c27441acf2e65f85c106ccff5c6b6c37030ddca
+1
View File
@@ -1,3 +1,4 @@
open_collective: continuwuity
github: [JadedBlueEyes, timedoutuk, gingershaped]
custom:
- https://timedout.uk/donate.html
Generated
+193 -212
View File
File diff suppressed because it is too large. Load diff
+8 -6
View File
@@ -104,6 +104,7 @@ version = "0.8.8"
default-features = false
features = [
"form",
"query",
"http1",
"http2",
"json",
@@ -330,7 +331,7 @@ version = "2.1.1"
# used for MPSC channels
[workspace.dependencies.loole]
version = "0.4.0"
version = "0.6.0"
# used for MPMC channels
[workspace.dependencies.async-channel]
@@ -348,7 +349,7 @@ version = "1.1.1"
# Used for matrix spec type definitions and helpers
[workspace.dependencies.ruma]
git = "https://github.com/ruma/ruma.git"
rev = "f5e5e1c885f598036fd4326c566e9d1928027d5d"
rev = "0ed7fba34213f18a628a56f527c6cc795cd7eef5"
features = [
"appservice-api-c",
"client-api",
@@ -388,6 +389,7 @@ features = [
"unstable-msc4494",
"unstable-msc4484",
"unstable-msc4540",
"unstable-msc4560",
"unstable-extensible-events",
]
@@ -452,7 +454,7 @@ features = ["http", "grpc-tonic", "trace", "logs", "metrics"]
# optional sentry metrics for crash/panic reporting
[workspace.dependencies.sentry]
version = "0.48.0"
version = "0.49.0"
default-features = false
features = [
"backtrace",
@@ -467,9 +469,9 @@ features = [
]
[workspace.dependencies.sentry-tracing]
version = "0.48.0"
version = "0.49.0"
[workspace.dependencies.sentry-tower]
version = "0.48.0"
version = "0.49.0"
# jemalloc usage
[workspace.dependencies.tikv-jemalloc-sys]
@@ -543,7 +545,7 @@ features = ["hardware-lock-elision", "deadlock_detection"] # TODO: Check if dead
# Use this when extending with_lock::WithLock to parking_lot
[workspace.dependencies.lock_api]
version = "0.4.13"
version = "0.5.0"
[workspace.dependencies.bytesize]
version = "2.0"
+3
View File
@@ -0,0 +1,3 @@
Implemented unstable support for [MSC4560] (Stripped state requests over federation). Contributed by @ginger.
[MSC4560]: https://github.com/matrix-org/matrix-spec-proposals/pull/4560
+1
View File
@@ -0,0 +1 @@
The first-run version of the web UI now includes a link to the registration page. Contributed by @ginger
+1
View File
@@ -0,0 +1 @@
Continuwuity now supports the OAuth 2.0 client credentials grant type, allowing secure automated access to the Matrix homeserver admin API, as well as future administrative functionality. Contributed by @ginger.
+1
View File
@@ -0,0 +1 @@
Room summary visibility checks are no longer incorrectly applied for remote rooms. Contributed by @ginger.
@@ -0,0 +1 @@
Fix new devices sometimes never reaching other users' device lists. Contributed by @eleboucher.
@@ -0,0 +1 @@
Fix gap filling skipping outlier events that are missing their previous events. Contributed by @eleboucher.
@@ -0,0 +1 @@
Fix state resolution applying events out of order, which could undo room joins. Contributed by @eleboucher.
@@ -0,0 +1 @@
Fix to-device messages, including room keys, sometimes being lost before delivery. Contributed by @eleboucher.
+1
View File
@@ -0,0 +1 @@
Add a section on [troubleshooting Docker issues](https://continuwuity.org/troubleshooting#docker-issues). Contributed by @stratself.
+1
View File
@@ -0,0 +1 @@
Instructions for Authelia added to the [OIDC guide](https://continuwuity.org/authentication/oidc.html). Contributed by @fhoekstra
+1
View File
@@ -0,0 +1 @@
Fix some possible deadlocks/freezes and reduce lock contention (improving performance). Contributed by @Jade
+1
View File
@@ -0,0 +1 @@
Docker compose examples now use bind mounts by default, instead of Docker volumes, as they are easier to work with esp. for backup/restore. Contributed by @stratself.
+1
View File
@@ -0,0 +1 @@
Once again fixed how room extremities are handled, fixing a problem that made continuwuity gradually make rooms needlessly complex, which also caused more frequent state resets.
+1
View File
@@ -0,0 +1 @@
The OAuth identity reset page is no longer linked from the account management UI to reduce confusion. Contributed by @ginger.
+1
View File
@@ -0,0 +1 @@
Fixed a worker panic when knocking on a room over federation. Contributed by @eleboucher.
+1
View File
@@ -0,0 +1 @@
Perform more validation on events received during atomic gapfill from remote servers, fixing a panic if bad data was persisted by another server and later lazily fetched by us.
+1
View File
@@ -0,0 +1 @@
Redirect URIs in OAuth clients' metadata are now properly validated to be on a subdomain of the OAuth issuer URL domain. Contributed by @ginger.
+1
View File
@@ -0,0 +1 @@
Updated internal Sentry integration setup to the new pattern required by the SDK.
+1
View File
@@ -0,0 +1 @@
Fix v12 rooms created by the same user in the same millisecond ending up as the same room. Contributed by @eleboucher.
+1
View File
@@ -0,0 +1 @@
Setting a profile key longer than 255 bytes now returns 400 `M_KEY_TOO_LARGE` as required by the spec, instead of 413 `M_TOO_LARGE`.
+1
View File
@@ -0,0 +1 @@
Setting profile data that would make the profile exceed 64 KiB now returns 400 `M_PROFILE_TOO_LARGE` as required by the spec, instead of a 500 error.
+1
View File
@@ -0,0 +1 @@
Appservices masquerading as a device that does not exist now receive 400 `M_UNKNOWN_DEVICE` as required by the spec, instead of 403 `M_FORBIDDEN`.
+1
View File
@@ -0,0 +1 @@
Setting `m.fully_read` via the account data endpoints now returns 405 `M_BAD_JSON` as required by the spec, instead of 400.
+1
View File
@@ -0,0 +1 @@
The `m.forget_forced_upon_leave` capability now reflects the `forget_forced_upon_leave` config option instead of always being advertised as enabled.
+1
View File
@@ -0,0 +1 @@
Fixed push notifications for membership events setting `user_is_target` based on the sender rather than the user being notified.
+42
View File
@@ -2680,3 +2680,45 @@
#
# env: CONTINUWUITY_OAUTH__OIDC__PROFILE_KEY_IMPORT_MODE
#profile_key_import_mode = "on_registration"
#[global.oauth.clients."$id"]
# Use this section to add static OAuth clients for bots and automation.
# Clients added here may use the client credentials OAuth grant to authorize
# themselves with Continuwuity.
#
# Make sure to replace `$id` in the header with your client ID of choice! You can
# add more copies of this section with different IDs to add multiple clients.
#
# Because the client credentials grant authorizes the client as itself, without
# an attached user, clients that use it will not be able to access most of the Matrix
# client-server API. Administrative functionality that does not require a user
# will still be available.
# The client's client secret.
#
# This must be supplied as the `client_secret` parameter when requesting
# an access token with the OAuth 2.0 token endpoint. Continuwuity does
# not check the `Authorization` header for requests to this endpoint.
#
#client_secret =
# A list of scopes that the client may request. Continuwuity allows static
# clients to request the following scopes:
#
# - "urn:matrix:client:cc.c10y.msc4484.server_administration" (MSC4484):
# This scope grants access to the Matrix server administration APIs, as
# well as Continuwuity's internal admin API (currently a work in
# progress).
# - "urn:matrix:client:api:*": This scope grants access to the Matrix
# client-server API. Most endpoints require an authenticated Matrix user
# and thus will not be usable by static clients.
#
# The `urn:matrix:client:device:<id>` scope may not be requested by static
# clients.
#
# Scopes listed here are not granted by default. The client must
# explicitly include them in the `scope` parameter of its access token
# request.
#
#scopes = []
+1 -1
View File
@@ -50,7 +50,7 @@ EOF
# Developer tool versions
# renovate: datasource=github-releases depName=cargo-bins/cargo-binstall
ENV BINSTALL_VERSION=1.25.3
ENV BINSTALL_VERSION=1.26.1
# renovate: datasource=github-releases depName=psastras/sbom-rs
ENV CARGO_SBOM_VERSION=0.9.1
# renovate: datasource=crate depName=lddtree
+1 -1
View File
@@ -18,7 +18,7 @@ RUN --mount=type=cache,target=/etc/apk/cache apk add \
# Developer tool versions
# renovate: datasource=github-releases depName=cargo-bins/cargo-binstall
ENV BINSTALL_VERSION=1.25.3
ENV BINSTALL_VERSION=1.26.1
# renovate: datasource=github-releases depName=psastras/sbom-rs
ENV CARGO_SBOM_VERSION=0.9.1
# renovate: datasource=crate depName=lddtree
+74 -18
View File
@@ -1,3 +1,5 @@
import { Tab, Tabs } from '@rspress/core/theme';
# Delegated authentication with OIDC
Continuwuity supports delegating user authentication to an external identity provider that implements the OpenID Connect (OIDC) specification, such as Authentik, Kanidm, or Keycloak.
@@ -12,56 +14,110 @@ An account on the homeserver can only be associated with one OIDC subject claim
A simple OIDC configuration is as easy as creating a new OIDC application in your identity provider's settings and supplying Continuwuity with the client ID and client secret.
The instructions below make the following assumptions:
- Continuwuity's base URL: `https://matrix.example.com`. Note that if you employ [well-known delegation](../guides/delegation), this must match the client well-known domain rather than your server name.
- OIDC provider's base URL: `https://idm.example.com`
### Configuring the OIDC provider
This guide will use [**Kanidm**][kanidm] as an example, but the described steps are broadly applicable to other identity providers. Contributions for them are welcome.
This guide will cover [**Kanidm**][kanidm] and [**Authelia**][authelia], but the basic concepts apply to most identity providers. Contributions for them are welcome.
First, create a new application for Continuwuity in your identity provider.
<Tabs groupId="idp">
<Tab label="KanIDM">
Create a new application for continuwuity in kanidm. We will use `c10y` as the client ID.
```sh
# Here, `c10y` is the client ID that Kanidm will use, and `Continuwuity` is the display name.
# Other identity providers may generate a client ID for you.
# Use the domain that clients can reach Continuwuity at, which may not be the same as your server name
# if you have configured well-known delegation.
kanidm system oauth2 create c10y Continuwuity https://matrix.yourdomain.com
kanidm system oauth2 create c10y Continuwuity https://matrix.example.com
```
Configure the redirect URL that Continuwuity uses.
```sh
kanidm system oauth2 add-redirect-url c10y https://matrix.yourdomain.com/_continuwuity/oidc/complete
kanidm system oauth2 add-redirect-url c10y https://matrix.example.com/_continuwuity/oidc/complete
```
Allow Continuwuity to request the `openid` scope. Other identity providers may not require this step.
Allow Continuwuity to request the `openid` scope.
```sh
kanidm system oauth2 update-scope-map c10y idm_all_persons openid
```
Find the client secret that was generated. Other identity providers may show this information in their web UI.
Find the client secret that was generated.
```sh
kanidm system oauth2 show-basic-secret c10y
d1qgx352kkuvs1j70b6w293d65x68jve1f7b27fyk90gjhpr
```
Now the discovery URL for KanIDM is: `https://idm.example.com/oauth2/openid/c10y`
</Tab>
<Tab label="Authelia">
To create a new client in Authelia, it is [recommended][authelia-faq-client-secret] to randomly generate both the client id and client secret. The commands below should get you those:
<Tabs groupId="authelia-generate-client-details">
<Tab label="Bare Binary">
```sh
# Generate random value for Client ID
authelia crypto rand --length 72 --charset rfc3986
# Generate Client Secret (labeled Random Password) and its Digest
authelia crypto hash generate pbkdf2 --variant sha512 --random --random.length 72 --random.charset rfc3986
```
</Tab>
<Tab label="Docker">
```sh
# Generate random value for Client ID
docker run --rm authelia/authelia:latest authelia crypto rand --length 72 --charset rfc3986
# Generate Client Secret (labeled Random Password) and its Digest
docker run --rm authelia/authelia:latest authelia crypto hash generate pbkdf2 --variant sha512 --random --random.length 72 --random.charset rfc3986
```
</Tab>
</Tabs>
Authelia only needs to know the digest of the secret, whereas Continuwuity requires the secret itself.
Go to your Authelia configuration file, find the `identity_provers` block, and add a block for Continuwuity to the `clients` list:
```yaml
identity_providers:
oidc:
jwks:
# This part has the JWKs and is what you configured previously
# ...
clients:
# Add this block below to the clients list
- client_name: continuwuity
client_id: "client-id-goes-here"
# Use the client secret's DIGEST, not the client secret itself
client_secret: "client-secret-DIGEST-goes-here"
redirect_uris: ["https://matrix.example.com/_continuwuity/oidc/complete"]
scopes: [openid]
```
Then restart Authelia to load the new configuration.
The discovery URL is simply the root domain of your Authelia, where it can be reached by clients, i.e. `https://idm.example.com`.
</Tab>
</Tabs>
[kanidm]: https://kanidm.com
[authelia]: https://www.authelia.com
[authelia-faq-client-secret]: https://www.authelia.com/integration/openid-connect/frequently-asked-questions/#how-do-i-generate-a-client-identifier-or-client-secret
### Configuring Continuwuity
Configure Continuwuity with the client ID, client secret, and discovery URL provided from the steps above. Kanidm has a different discovery URL for each client, but other identity providers may have a single discovery URL at the root of their domain.
Configure Continuwuity with the client ID, client secret, and discovery URL provided from the steps above.
```toml
[global.oauth.oidc]
# `/.well-known/openid-configuration` will be appended automatically
discovery_url = "https://idm.example.com/oauth2/openid/c10y"
discovery_url = "https://your-discovery-url"
# This may be randomly generated by your identity provider. Kanidm requires
# you to set it manually when you create the application.
client_id = "c10y"
# From the previous step
client_secret = "d1qgx352kkuvs1j70b6w293d65x68jve1f7b27fyk90gjhpr"
client_id = "your-client-id"
client_secret = "your-client-secret"
```
### Testing that it works
+2 -21
View File
@@ -303,33 +303,14 @@ For browser-based clients, you can also inspect connections using DevTools' Netw
### Docker loopback networking issues
Some distros do not allow Docker containers in bridge networks to connect to their host's public IP by default. This makes `lk-jwt-service` fail connecting to `livekit` or `continuwuity` on the same host, causing refused and timed out connections to appear in the log entries of the JWT service, even when `LIVEKIT_URL` has been configured correctly.
You can also test that this is the case by cURLing from a sidecar container:
Some distros do not allow Docker containers to connect to the host's public IP, and this breaks connections from `lk-jwt-service` towards `livekit` and `continuwuity` if they're on the same host. This can be tested by the following command:
```bash
docker run --rm --net container:lk-jwt-service docker.io/curlimages/curl https://livekit.example.com
# --- some errors ---
```
To resolve this, configure an `extra_hosts` file mapping LiveKit's and Continuwuity's domain names to Docker's custom host loopback address, represented here by `host-gateway`:
```diff
# in docker-compose.yaml
services:
lk-jwt-service:
...
+ extra_hosts:
+ - "livekit.example.com:host-gateway"
+ - "matrix.example.com:host-gateway"
```
After implementing the changes and restarting your compose, `lk-jwt-service` should now connect to your other services. The sidecar container test above should now return an `OK` from LiveKit.
For more information about the `host-gateway` parameter, kindly refer to the `--add-host` documentation for [Docker][docker-add-host] and [Podman][podman-add-host]. Should you have further difficulties, feel free to enquire in the support rooms.
[docker-add-host]: https://docs.docker.com/reference/cli/docker/container/run/#add-host
[podman-add-host]: https://docs.podman.io/en/latest/markdown/podman-run.1.html#add-host-hostname-hostname-ip
To resolve this, follow the steps in [Docker loopback networking issues](../troubleshooting.mdx#docker-loopback-networking-issues) of the Troubleshooting page.
### Incorrect IP address for LiveKit
+58 -17
View File
@@ -53,7 +53,7 @@ For more setups with `.well-known` delegation and split-domain deployments, cons
Docker Compose is the recommended deployment method for Continuwuity containers. The following environment variables will be set:
- `CONTINUWUITY_SERVER_NAME` - Your Matrix server's domain name. **This CANNOT be changed later without a data wipe.**
- `CONTINUWUITY_DATABASE_PATH` - Where to store your database. This must match the docker volume mount.
- `CONTINUWUITY_DATABASE_PATH` - Where to store your database. This must match the docker bind mount.
- `CONTINUWUITY_ADDRESS` - Bind address (for Docker, use `0.0.0.0` to listen on all interfaces).
Alternatively, you can specify a path to mount the configuration file using the `CONTINUWUITY_CONFIG` environment variable.
@@ -89,7 +89,9 @@ Consult the [**DNS tuning guide (recommended)**](../guides/dns.mdx) for full sol
<summary>docker-compose.with-caddy.yml ([view raw](/deploying/docker-compose.with-caddy.yml))</summary>
Create a Caddyfile with the following content:
Create a directory called `caddy-data`, which will store TLS certs obtained by Caddy.
Then, create a Caddyfile with the following content:
```
https://example.com:443, https://example.com:8448 {
@@ -97,7 +99,7 @@ https://example.com:443, https://example.com:8448 {
}
```
Then, for the docker-compose:
Then, for the docker compose file:
```yaml file="../public/deploying/docker-compose.with-caddy.yml"
@@ -110,6 +112,10 @@ Then, for the docker-compose:
<details>
<summary>docker-compose.with-caddy-labels.yml ([view raw](/deploying/docker-compose.with-caddy-labels.yml))</summary>
Create a directory called `caddy-data`, which will store TLS certs obtained by Caddy.
Then, for the docker compose file:
```yaml file="../public/deploying/docker-compose.with-caddy-labels.yml"
```
@@ -132,6 +138,10 @@ Then, for the docker-compose:
<details>
<summary>docker-compose.with-traefik.yml ([view raw](/deploying/docker-compose.with-traefik.yml))</summary>
Create a directory called `traefik-acme-data`, which will store TLS certs obtained by Caddy.
Then, for the docker compose file:
```yaml file="../public/deploying/docker-compose.with-traefik.yml"
```
@@ -164,10 +174,15 @@ See the [Other reverse proxies](generic.mdx#setting-up-the-reverse-proxy) sectio
### Starting Your Server
1. Choose your compose file from the above, and rename it to `docker-compose.yml`. Replace `example.com` with your homeserver's domain name, and edit other values as you see fit.
2. If using the override file, rename it to `docker-compose.override.yml` and
edit your values.
3. Start the server:
1. Create a directory named `continuwuity-data`. This will be where your server's database lives.
2. Choose your compose file from the above, and rename it to `docker-compose.yml`. Replace `example.com` with your homeserver's domain name, and edit other values as you see fit.
- Follow all extra instructions as needed.
- If using the override file, rename it to `docker-compose.override.yml` and edit your values.
3. Start the server with the following command:
```bash
docker compose up -d
@@ -189,9 +204,7 @@ See the [Other reverse proxies](generic.mdx#setting-up-the-reverse-proxy) sectio
Pick your own username and password!
```
5. Log in to your server with any Matrix client, and register for an account with the registration token from step 4. You'll automatically be invited to the admin room where you can [manage your server](../reference/admin).
See the [generic deployment guide](generic.mdx) for more deployment options.
5. Log in to your server with any Matrix client, and register for an account with the registration token from the previous step. You'll automatically be invited to the admin room where you can [manage your server](../reference/admin).
## Testing
@@ -199,7 +212,9 @@ Test that your setup works by following these [instructions](./generic.mdx#how-d
Check your container logs using `docker-compose logs --follow` to debug any issues. See the [Troubleshooting](../troubleshooting.mdx) page for common errors and how to fix them.
## Updating
## Maintenance
### Updating
To update to a new version of Continuwuity, use the following commands:
@@ -212,6 +227,10 @@ docker compose pull
docker compose up -d
```
### Backups
The database in `./continuwuity-data` is present on the host system as a regular directory, and therefore can be backed up using normal mechanisms. See the [Backup](../maintenance.mdx#backups) section of the Maintenance page for more details.
## What's next?
Navigate to [Post-installation](../deploying.mdx#post-installation) for next steps.
@@ -270,12 +289,6 @@ Get a working Continuwuity server with an admin user in four steps:
Once configured, log in to your server with any Matrix client, and register for an account with the registration token from step 3. If you did not configure step 4., log in via the `http://<your_server_ip>:8008` address. You will be automatically invited to the admin room where you can [manage your server](../reference/admin).
### (Optional) Building Custom Images
For information on building your own Continuwuity Docker images, see the
[Building Docker Images](../development/index.mdx#building-docker-images)
section in the development documentation.
### Accessing the Server's Console
Before you can access the server's console and [send admin commands](../reference/admin/index.md) from the CLI, you will need to make the container interactive and allocate a pseudo-tty. Make sure you set `admin_console_automatic` to `true` in [the config](../reference/config.mdx) as well for Continuwuity to activate the CLI on startup.
@@ -297,3 +310,31 @@ From there you can access the server's console by running `docker attach <contai
Note that using `CTRL+c` within `docker attach`'s context will forward the signal to the server, stopping it. See [Docker's reference][docker-attach-reference] for more information.
[docker-attach-reference]: https://docs.docker.com/reference/cli/docker/container/attach/
### Using Docker volumes
The example compose files above utilizes [bind mounts][docker-bind-mounts]. If you want to use [Docker volumes][docker-volumes] instead, apply these changes to your compose file:
```diff
services:
continuwuity:
# ...
volumes:
- - ./continuwuity-data:/var/lib/continuwuity
+ - continuwuity-data:/var/lib/continuwuity
+volumes:
+ continuwuity-data:
```
Consult the [Docker docs][docker-volumes-backup-restore] for details on backing up and restoring Docker volumes
[docker-bind-mounts]: https://docs.docker.com/engine/storage/bind-mounts/
[docker-volumes]: https://docs.docker.com/engine/storage/volumes/
[docker-volumes-backup-restore]: https://docs.docker.com/engine/storage/volumes/#back-up-restore-or-migrate-data-volumes
### Building Custom Images
For information on building your own Continuwuity Docker images, see the
[Building Docker Images](../development/index.mdx#building-docker-images)
section in the development documentation.
+5
View File
@@ -199,6 +199,11 @@ header, making federation non-functional. If you find a workaround, please share
Furthermore, Nginx users need to increase the `client_max_body_size` setting (default is 1M) to match the `max_request_size` defined in conduwuit.toml.
- For HAProxy, ensure that the ACL for the `Host` header matches both the domain and the domain with the port, as federation requests are often sent with the port included. This can be done by using the `host_only` directive:
```
acl matrix-host hdr(host),host_only -i example.com
```
## Starting Your Server
Now you can start Continuwuity with:
+2 -2
View File
@@ -113,7 +113,7 @@ https://matrix.example.com {
### Tuning your trusted servers
:::info Vet your trusted servers!
:::important Important: Vet your trusted servers!
Trusted servers are your first point of contact when obtaining public keys from other servers, and they could theoretically impersonate other servers and cause significant harm to your deployment. Please thoroughly verify your trusted servers' credibility before adding them to your configuration.
If you need suggestions for trusted servers, ask in the Continuwuity main room.
@@ -128,7 +128,7 @@ trusted_servers = ["codestorm.net","starstruck.systems","unredacted.org","matrix
Avoid prioritising `matrix.org` as your primary trusted server, as it tends to be quite slow.
Some users have also reported that increasing `trusted_server_batch_size` has helped with faster joins for huge rooms. Start with doubling the default to `2048` until you find a suitable value.
Some users have also reported that increasing `trusted_server_batch_size` helps with faster joins for huge rooms. Start with doubling the default to `2048` until you find a suitable value.
### Enable HTTP/3 on your reverse proxy
@@ -6,7 +6,7 @@ services:
restart: unless-stopped
command: /sbin/conduwuit
volumes:
- db:/var/lib/continuwuity
- ./continuwuity-data:/var/lib/continuwuity
- ./continuwuity-resolv.conf:/etc/resolv.conf # use custom resolvers rather than Docker's
#- ./continuwuity.toml:/etc/continuwuity.toml
networks:
@@ -12,7 +12,7 @@ services:
- proxy
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./data:/data
- ./caddy-data:/data
restart: unless-stopped
labels:
caddy: example.com
@@ -23,7 +23,7 @@ services:
restart: unless-stopped
command: /sbin/conduwuit
volumes:
- db:/var/lib/continuwuity
- ./continuwuity-data:/var/lib/continuwuity
- ./continuwuity-resolv.conf:/etc/resolv.conf # use custom resolvers rather than Docker's
# - ./continuwuity.toml:/etc/continuwuity.toml
environment:
@@ -46,8 +46,5 @@ services:
caddy: matrix.example.com
caddy.reverse_proxy: "{{upstreams 8008}}"
volumes:
db:
networks:
proxy:
@@ -9,7 +9,7 @@ services:
networks:
- caddy
volumes:
- ./data:/data
- ./caddy-data:/data
# mount your created Caddyfile into the container
- ./Caddyfile:/etc/caddy/Caddyfile
restart: unless-stopped
@@ -19,7 +19,7 @@ services:
restart: unless-stopped
command: /sbin/conduwuit
volumes:
- db:/var/lib/continuwuity
- ./continuwuity-data:/var/lib/continuwuity
- ./continuwuity-resolv.conf:/etc/resolv.conf # use custom resolvers rather than Docker's
# - ./continuwuity.toml:/etc/continuwuity.toml
environment:
@@ -41,6 +41,3 @@ services:
networks:
proxy:
volumes:
db:
@@ -6,7 +6,7 @@ services:
restart: unless-stopped
command: /sbin/conduwuit
volumes:
- db:/var/lib/continuwuity
- ./continuwuity-data:/var/lib/continuwuity
- ./continuwuity-resolv.conf:/etc/resolv.conf # use custom resolvers rather than Docker's
#- ./continuwuity.toml:/etc/continuwuity.toml
networks:
@@ -40,7 +40,7 @@ services:
- "443:443"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "acme:/etc/traefik/acme"
- "./traefik-acme-data:/etc/traefik/acme"
labels:
- "traefik.enable=true"
@@ -77,9 +77,5 @@ services:
TRAEFIK_PROVIDERS_DOCKER_ENDPOINT: "unix:///var/run/docker.sock"
TRAEFIK_PROVIDERS_DOCKER_EXPOSEDBYDEFAULT: false
volumes:
db:
acme:
networks:
proxy:
@@ -6,7 +6,7 @@ services:
restart: unless-stopped
command: /sbin/conduwuit
volumes:
- db:/var/lib/continuwuity
- ./continuwuity-data:/var/lib/continuwuity
- ./continuwuity-resolv.conf:/etc/resolv.conf # use custom resolvers rather than Docker's
#- ./continuwuity.toml:/etc/continuwuity.toml
networks:
@@ -18,7 +18,7 @@ services:
- "traefik.http.routers.continuwuity.tls=true"
- "traefik.http.routers.continuwuity.service=continuwuity"
- "traefik.http.services.continuwuity.loadbalancer.server.port=8008"
# possibly, depending on your config:
# enable tls with the `letsencrypt` certificate resolver (actual name dependant on your static config)
# - "traefik.http.routers.continuwuity.tls.certresolver=letsencrypt"
environment:
CONTINUWUITY_SERVER_NAME: example.com
@@ -34,9 +34,6 @@ services:
server=example.com:443
}
volumes:
db:
networks:
# This must match the network name that Traefik listens on
proxy:
@@ -12,7 +12,7 @@ services:
- proxy
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./data:/data
- ./caddy-data:/data
restart: unless-stopped
homeserver:
@@ -20,7 +20,7 @@ services:
restart: unless-stopped
command: /sbin/conduwuit
volumes:
- db:/var/lib/continuwuity
- ./continuwuity-data:/var/lib/continuwuity
- ./continuwuity-resolv.conf:/etc/resolv.conf # use custom resolvers rather than Docker's
# - ./continuwuity.toml:/etc/continuwuity.toml
environment:
@@ -10,7 +10,7 @@ services:
networks:
- proxy
volumes:
- ./data:/data
- ./caddy-data:/data
# mount your created Caddyfile into the container
- ./Caddyfile:/etc/caddy/Caddyfile
restart: unless-stopped
@@ -20,7 +20,7 @@ services:
restart: unless-stopped
command: /sbin/conduwuit
volumes:
- db:/var/lib/continuwuity
- ./continuwuity-data:/var/lib/continuwuity
- ./continuwuity-resolv.conf:/etc/resolv.conf # use custom resolvers rather than Docker's
# - ./continuwuity.toml:/etc/continuwuity.toml
environment:
@@ -43,6 +43,3 @@ services:
networks:
proxy:
volumes:
db:
@@ -6,7 +6,7 @@ services:
restart: unless-stopped
command: /sbin/conduwuit
volumes:
- db:/var/lib/continuwuity
- ./continuwuity-data:/var/lib/continuwuity
- ./continuwuity-resolv.conf:/etc/resolv.conf # use custom resolvers rather than Docker's
#- ./continuwuity.toml:/etc/continuwuity.toml
networks:
@@ -40,7 +40,7 @@ services:
- "443:443"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "acme:/etc/traefik/acme"
- "./traefik-acme-data:/etc/traefik/acme"
labels:
- "traefik.enable=true"
@@ -77,9 +77,5 @@ services:
TRAEFIK_PROVIDERS_DOCKER_ENDPOINT: "unix:///var/run/docker.sock"
TRAEFIK_PROVIDERS_DOCKER_EXPOSEDBYDEFAULT: false
volumes:
db:
acme:
networks:
proxy:
+30 -33
View File
@@ -1,41 +1,38 @@
# Continuwuity - Bare Configuration (for other reverse proxies)
services:
homeserver:
image: "forgejo.ellis.link/continuwuation/continuwuity:latest"
restart: unless-stopped
command: /sbin/conduwuit
ports:
homeserver:
image: "forgejo.ellis.link/continuwuation/continuwuity:latest"
restart: unless-stopped
command: /sbin/conduwuit
ports:
# If your reverse proxy is on the host, use this
# and configure it to connect to `127.0.0.1:8008`
- 127.0.0.1:8008:8008
# If your reverse proxy is on the host, use this
# and configure it to connect to `127.0.0.1:8008`
- 127.0.0.1:8008:8008
# If your reverse proxy is on another machine, use this
# and configure it to connect to <this-machine-ip>:8008
# - 8008:8008
# If your reverse proxy is on another machine, use this
# and configure it to connect to <this-machine-ip>:8008
# - 8008:8008
# If your reverse proxy is a docker container on the same network,
# comment out the entire `ports` section, and configure it to connect to `continuwuity:8008`
# If your reverse proxy is a docker container on the same network,
# comment out the entire `ports` section, and configure it to connect to `continuwuity:8008`
volumes:
- db:/var/lib/continuwuity
- ./continuwuity-resolv.conf:/etc/resolv.conf # use custom resolvers rather than Docker's
#- ./continuwuity.toml:/etc/continuwuity.toml
environment:
CONTINUWUITY_SERVER_NAME: example.com # EDIT THIS
CONTINUWUITY_DATABASE_PATH: /var/lib/continuwuity
CONTINUWUITY_ADDRESS: 0.0.0.0
CONTINUWUITY_PORT: 8008
#CONTINUWUITY_CONFIG: '/etc/continuwuity.toml' # Uncomment if you mapped config toml above
volumes:
- ./continuwuity-data:/var/lib/continuwuity
- ./continuwuity-resolv.conf:/etc/resolv.conf # use custom resolvers rather than Docker's
#- ./continuwuity.toml:/etc/continuwuity.toml
environment:
CONTINUWUITY_SERVER_NAME: example.com # EDIT THIS
CONTINUWUITY_DATABASE_PATH: /var/lib/continuwuity
CONTINUWUITY_ADDRESS: 0.0.0.0
CONTINUWUITY_PORT: 8008
#CONTINUWUITY_CONFIG: '/etc/continuwuity.toml' # Uncomment if you mapped config toml above
## (Optional) Serve .well-known files to tell others to reach Continuwuity on port :443
## If you do this, remove all routes to port :8448 on your reverse proxy
# CONTINUWUITY_WELL_KNOWN: |
# {
# client=https://example.com,
# server=example.com:443
# }
volumes:
db:
## (Optional) Serve .well-known files to tell others to reach Continuwuity on port :443
## If you do this, remove all routes to port :8448 on your reverse proxy
# CONTINUWUITY_WELL_KNOWN: |
# {
# client=https://example.com,
# server=example.com:443
# }
+87 -17
View File
@@ -1,9 +1,9 @@
# Troubleshooting Continuwuity
:::warning{title="Docker users:"}
Docker can be difficult to use and debug. It's common for Docker
misconfigurations to cause issues, particularly with networking and permissions.
Please check that your issues are not due to problems with your Docker setup.
:::warning{title="For Docker users"}
It's common for Docker misconfigurations to cause issues, particularly with networking and
permissions. Before continuing, please first check that your issues are notdue Docker
problems. See the dedicated [**Docker issues**](#docker-issues) section for more details.
:::
## Continuwuity issues
@@ -13,9 +13,9 @@ Please check that your issues are not due to problems with your Docker setup.
Some slowness is to be expected if you're the first person on your homeserver to join a room (which will
always be the case for single-user homeservers). In this situation, your homeserver has to verify the signatures of
all of the state events sent by other servers before your join. To make this process as fast as possible, make sure you have
[multiple fast, trusted servers](./guides/performance.mdx#tuning-your-trusted-servers) listed in `trusted_servers` in your configuration, and ensure
`query_trusted_key_servers_first_on_join` is set to true (the default).
If you need suggestions for trusted servers, ask in the Continuwuity main room.
multiple fast, trusted servers listed in `trusted_servers` in your configuration, and ensure
`query_trusted_key_servers_first_on_join` is set to true (the default). Read the
[Tuning your trusted servers](./guides/performance.mdx#tuning-your-trusted-servers) section for more details on doing so.
However, _very_ slow joins, especially to rooms with only a few users in them or rooms created by another user
on your homeserver, may be caused by [issue !779](https://forgejo.ellis.link/continuwuation/continuwuity/issues/779),
@@ -119,11 +119,63 @@ much possible corruption is restored
- If all goes will, you should be able to restore back to using
`TolerateCorruptedTailRecords` and you have successfully recovered your database
## Docker issues
### Debugging Docker networking
The Continuwuity image does not ship with any shell or internal debugging utilities. To debug network conditions for Continuwuity, run another sidecar container that is attached to its network namespace. For example, using the `curl` container:
```bash
docker run --rm -it \
--network container:continuwuity \
docker.io/curlimages/curl \
curl https://continuwuity.org/.well-known/matrix/server
```
### Docker loopback networking issues
Some distros disallow Docker containers in bridge networks to reach out to their host's public IP by default. This can cause connectivity issues between Continuwuity and other services that are on the same host machine, such as LiveKit or a push server.
One can test if this is the case by cURLing those services with a sidecar container:
```bash
docker run --rm -it --network container:continuwuity docker.io/curlimages/curl curl https://push.example.com
# --- some timeout or refused connection errors ---
```
To fix this, use the `extra_hosts` parameter to map local service domains to `host-gateway` - a special Docker value that resolves to the internal IP address of the host.
```diff title="docker-compose.yaml"
services:
continuwuity:
...
# allow Continuwuity to reach out to the push server and livekit
# via the host gateway loopback address
+ extra_hosts:
+ - "push.example.com:host-gateway"
+ - "livekit.example.com:host-gateway"
lk-jwt-service:
...
# allow jwt service to reach out to Continuwuity and livekit
# via the host gateway loopback address
+ extra_hosts:
+ - "livekit.example.com:host-gateway"
+ - "matrix.example.com:host-gateway"
```
Reload the compose file, and connections between these services (as well as the sidecar container test above) should now work.
For more information about the `host-gateway` parameter, kindly consult the Docker docs on [custom DNS with `extra_hosts`][docker-custom-dns] and the [`--add-host` option][docker-add-host].
[docker-custom-dns]: https://docs.docker.com/compose/how-tos/networking/#custom-dns-with-extra_hosts
[docker-add-host]: https://docs.docker.com/reference/cli/docker/container/run/#add-host
## Debugging
Note that users should not really need to debug things. If you find yourself
debugging and find the issue, please let us know and/or how we can fix it.
Various debug commands can be [found in `!admin debug`](./reference/admin/debug).
Various debug commands can be found in [`!admin debug`](./reference/admin/debug).
### Debug/Trace log level
@@ -136,23 +188,34 @@ you need to access debug/trace log levels, you will need to build without the
Continuwuity supports changing the tracing log environment filter on-the-fly using
the admin command `!admin debug change-log-level <log env filter>`. This accepts
a string **without quotes** the same format as the `log` config option.
a string **without quotes** in the same format as the `log` config option. Complex
filters are also supported as well.
Example: `!admin debug change-log-level debug`
```bash
# set log level to debug
!admin debug change-log-level debug
This can also accept complex filters such as:
`!admin debug change-log-level info,conduit_service[{dest="example.com"}]=trace,ruma_state_res=trace`
`!admin debug change-log-level info,conduit_service[{dest="example.com"}]=trace,conduit_service[send{dest="example.org"}]=trace`
# trace logs for all outgoing federation to `example.com`
!admin debug change-log-level info,conduwuit_service::federation[{dest="example.com"}]=trace
And to reset the log level to the one that was set at startup / last config
load, simply pass the `--reset` flag.
# trace logs for client syncs
!admin debug change-log-level info,conduwuit_api::client=trace
`!admin debug change-log-level --reset`
# debug logs for everything except h2 and presence
!admin debug change-log-level trace,h2=off,conduwuit_service::presence=off
```
To reset the log level to the one that was set at last config
load, simply do:
```bash
!admin debug change-log-level --reset
```
### Pinging servers
Continuwuity can ping other servers using `!admin debug ping <server>`. This takes
a server name and goes through the server discovery process and queries
a server name, goes through the server discovery process, and queries
`/_matrix/federation/v1/version`. Errors are outputted.
While it does measure the latency of the request, it is not indicative of
@@ -198,3 +261,10 @@ and is not easy for non-developers to understand.
[unbound-tuning]: https://unbound.docs.nlnetlabs.nl/en/latest/topics/core/performance.html
[unbound-arch]: https://wiki.archlinux.org/title/Unbound
## Other troubleshooting topics
- [LiveKit troubleshooting](./calls/livekit.mdx#troubleshooting)
- [TURN server troubleshooting](./calls/turn.mdx#troubleshooting)
- [Delegation/split-domain troubleshooting](./guides/delegation.mdx#troubleshooting)
- [Push notifications troubleshooting](./guides/push.mdx#troubleshooting)
+1 -1
View File
@@ -12,7 +12,7 @@
target:
target.fromToolchainName {
name = (lib.importTOML "${inputs.self}/rust-toolchain.toml").toolchain.channel;
sha256 = "sha256-zm3dyIY2T414ZRR3EhLOvptzG6gta4WZUcawzMUWtqI=";
sha256 = "sha256-+xUr6Al1wZSqX8aEsq7DpuFOK4Ve/i+qTl+K5uWQ9GM=";
};
in
{
+1 -1
View File
@@ -10,7 +10,7 @@
[toolchain]
profile = "minimal"
channel = "1.99.0"
channel = "1.99.1"
components = [
# For rust-analyzer
"rust-src",
+6 -8
View File
@@ -1,4 +1,4 @@
use conduwuit::{Err, Result, checked};
use conduwuit::{Err, Result, checked, utils::ReadyExt};
use futures::{FutureExt, StreamExt, TryFutureExt};
impl crate::Context<'_> {
@@ -49,7 +49,6 @@ impl crate::Context<'_> {
.services
.appservice
.get_registration(&appservice_identifier)
.await
{
| None => return Err!("Appservice does not exist."),
| Some(config) => {
@@ -78,12 +77,11 @@ impl crate::Context<'_> {
self.services
.users
.stream_local_users()
.filter_map(async |user_id| {
if self.services.appservice.is_user_id(&user_id).await {
Some(user_id)
} else {
None
}
.ready_filter_map(|user_id| {
self.services
.appservice
.is_user_id(&user_id)
.then_some(user_id)
})
.for_each(async |user_id| {
self.services
+41 -1
View File
@@ -14,7 +14,7 @@ use conduwuit::{
state_res::EventTypeExt,
trace, utils,
utils::{
stream::{IterStream, ReadyExt},
stream::{BroadbandExt, IterStream, ReadyExt},
string::EMPTY,
to_canonical_object,
},
@@ -1207,6 +1207,46 @@ impl crate::Context<'_> {
.await
}
pub(super) async fn room_extremities(&self, room_id: OwnedRoomId) -> Result {
let mut extremities = self
.services
.rooms
.state
.get_forward_extremities(&room_id)
.broad_filter_map(|event_id| async move {
self.services.rooms.timeline.get_pdu(&event_id).await.ok()
})
.collect::<Vec<_>>()
.await;
extremities.sort_by_key(|pdu| (pdu.depth, pdu.origin_server_ts));
if extremities.is_empty() {
return Err!("No room extremities.");
}
self.write_str("| Event ID | Kind | Sender | Timestamp | Depth |\n")
.await?;
self.write_str("| -------- | ---- | ------ | --------- | ----- |\n")
.await?;
for pdu in extremities {
let url = format!(
"https://matrix.to/#/{}/{}?via={}",
room_id,
pdu.event_id(),
self.services.server.name
);
self.write_str(&format!(
"| [`{}`]({url}) | `{}` | `{}` | `{}` | `{}` |\n",
pdu.event_id(),
pdu.kind(),
pdu.sender(),
pdu.origin_server_ts,
pdu.depth
))
.await?;
}
Ok(())
}
pub(super) async fn servers_in_backoff(
&self,
room_id: Option<OwnedRoomId>,
+4
View File
@@ -234,6 +234,10 @@ pub enum DebugCommand {
page: Option<usize>,
},
RoomExtremities {
room_id: OwnedRoomId,
},
/// Lists remote servers that are currently in a "backoff" state.
///
/// Servers in this list will not be contacted until the retry time elapses,
+4 -8
View File
@@ -39,17 +39,13 @@ conduwuit::mod_dtor! {}
pub use crate::admin::AdminCommand;
/// Install the admin command processor
pub async fn init(admin_service: &service::admin::Service) {
pub fn init(admin_service: &service::admin::Service) {
_ = admin_service.complete.write().insert(processor::complete);
_ = admin_service
.handle
.write()
.await
.insert(processor::dispatch);
_ = admin_service.handle.write().insert(processor::dispatch);
}
/// Uninstall the admin command handler
pub async fn fini(admin_service: &service::admin::Service) {
_ = admin_service.handle.write().await.take();
pub fn fini(admin_service: &service::admin::Service) {
_ = admin_service.handle.write().take();
_ = admin_service.complete.write().take();
}
+1 -1
View File
@@ -24,7 +24,7 @@ pub(super) async fn process(subcommand: AppserviceCommand, context: &Context<'_>
match subcommand {
| AppserviceCommand::GetRegistration { appservice_id } => {
let timer = tokio::time::Instant::now();
let results = services.appservice.get_registration(&appservice_id).await;
let results = services.appservice.get_registration(&appservice_id);
let query_time = timer.elapsed();
-1
View File
@@ -135,7 +135,6 @@ pub(crate) async fn add_3pid_route(
let email = services
.threepid
.get_valid_session(&body.sid, &body.client_secret)
.await
.map_err(|message| err!(Request(ThreepidAuthFailed("{message}"))))?
.consume();
+7 -4
View File
@@ -117,10 +117,13 @@ async fn set_account_data(
data: &RawJsonValue,
) -> Result {
if event_type_s == "m.fully_read" {
return Err!(Request(BadJson(
"This endpoint cannot be used for marking a room as fully read (setting \
m.fully_read)"
)));
return Err!(Request(
BadJson(
"This endpoint cannot be used for marking a room as fully read (setting \
m.fully_read)"
),
METHOD_NOT_ALLOWED
));
}
let data: serde_json::Value = serde_json::from_str(data.get())
+2 -4
View File
@@ -20,8 +20,7 @@ pub(crate) async fn create_alias_route(
services
.rooms
.alias
.appservice_checks(&body.room_alias, body.identity.appservice_info())
.await?;
.appservice_checks(&body.room_alias, body.identity.appservice_info())?;
// this isn't apart of alias_checks or delete alias route because we should
// allow removing forbidden room aliases
@@ -69,8 +68,7 @@ pub(crate) async fn delete_alias_route(
services
.rooms
.alias
.appservice_checks(&body.room_alias, body.identity.appservice_info())
.await?;
.appservice_checks(&body.room_alias, body.identity.appservice_info())?;
services
.rooms
+2 -1
View File
@@ -46,7 +46,8 @@ pub(crate) async fn get_capabilities_route(
capabilities.get_login_token =
GetLoginTokenCapability::new(services.server.config.login_via_existing_session);
capabilities.forget_forced_upon_leave.enabled = true;
capabilities.forget_forced_upon_leave.enabled =
services.server.config.forget_forced_upon_leave;
if services.users.is_admin(sender_user).await {
capabilities.account_moderation.lock = true;
+15 -16
View File
@@ -1,4 +1,4 @@
use std::{borrow::Borrow, collections::HashMap, iter::once, sync::Arc};
use std::{borrow::Borrow, collections::HashMap, sync::Arc};
use axum::extract::State;
use conduwuit::{
@@ -461,14 +461,13 @@ async fn knock_room_helper_local(
services
.rooms
.timeline
.append_pdu(
&parsed_knock_pdu,
knock_event,
once(parsed_knock_pdu.event_id.borrow()),
&state_lock,
room_id,
)
.progress_extremities(&parsed_knock_pdu)
.await?;
services
.rooms
.timeline
.append_pdu(&parsed_knock_pdu, knock_event, room_id)
.await;
Ok(())
}
@@ -587,7 +586,7 @@ async fn knock_room_helper_remote(
let mut state_map: HashMap<u64, OwnedEventId> = HashMap::new();
for event in state {
for mut event in state {
let Some(state_key) = event.get("state_key") else {
debug_warn!("send_knock stripped state event missing state_key: {event:?}");
continue;
@@ -614,6 +613,7 @@ async fn knock_room_helper_remote(
.get_or_create_shortstatekey(&event_type, &state_key)
.await;
event.insert("event_id".into(), CanonicalJsonValue::String(event_id.to_string()));
services.rooms.outlier.add_pdu_outlier(&event_id, &event);
state_map.insert(shortstatekey, event_id.clone());
}
@@ -662,14 +662,13 @@ async fn knock_room_helper_remote(
services
.rooms
.timeline
.append_pdu(
&parsed_knock_pdu,
knock_event,
once(parsed_knock_pdu.event_id.borrow()),
&state_lock,
room_id,
)
.progress_extremities(&parsed_knock_pdu)
.await?;
services
.rooms
.timeline
.append_pdu(&parsed_knock_pdu, knock_event, room_id)
.await;
info!("Setting final room state for new room");
// We set the room state after inserting the pdu, so that we never have a
+1 -1
View File
@@ -61,7 +61,7 @@ pub(crate) async fn authorization_server_metadata(services: &Services) -> Value
"authorization_endpoint": endpoint_base.join(AUTH_CODE_PATH).unwrap(),
"code_challenge_methods_supported": ["S256"],
"device_authorization_endpoint": endpoint_base.join(DEVICE_AUTHORIZATION_PATH).unwrap(),
"grant_types_supported": ["authorization_code", "refresh_token", "urn:ietf:params:oauth:grant-type:device_code"],
"grant_types_supported": ["authorization_code", "refresh_token", "urn:ietf:params:oauth:grant-type:device_code", "client_credentials"],
"issuer": services.config.get_client_domain(),
"jwks_uri": endpoint_base.join(JWKS_URI_PATH).unwrap(),
"prompt_values_supported": prompt_values_supported,
+21 -9
View File
@@ -1,18 +1,21 @@
use std::collections::{BTreeMap, BTreeSet, HashSet};
use std::{
collections::{BTreeMap, BTreeSet, HashSet},
sync::atomic::{AtomicU64, Ordering::SeqCst},
};
use axum::extract::State;
use conduwuit::{
Err, Error, Result, debug, debug_info, err, info,
matrix::{StateKey, pdu::PartialPdu},
trace,
utils::to_canonical_object,
utils::{self, to_canonical_object},
warn,
};
use conduwuit_service::{Services, appservice::RegistrationInfo};
use futures::FutureExt;
use ruma::{
CanonicalJsonObject, CanonicalJsonValue, Int, MilliSecondsSinceUnixEpoch, OwnedRoomAliasId,
OwnedUserId, RoomAliasId, RoomId,
OwnedUserId, RoomAliasId, RoomId, UInt,
api::{
client::room::{
self,
@@ -46,6 +49,8 @@ use serde_json::value::to_raw_value;
use crate::{Ruma, client::invite_helper};
static LAST_CREATE_TS: AtomicU64 = AtomicU64::new(0);
// We use this to keep around extra data in the `creation_content`
// while still parsing and validating keys that we care about.
#[derive(Deserialize, Default)]
@@ -307,6 +312,17 @@ pub(crate) async fn create_room_route(
.map(MilliSecondsSinceUnixEpoch)
};
// v12+ room IDs are the create event's hash, so give each create event a
// unique timestamp to avoid collisions.
let create_timestamp = custom_origin_server_ts.or_else(|| {
room_id.is_none().then(|| {
let now = utils::millis_since_unix_epoch();
let next = |last: u64| now.max(last.saturating_add(1));
let prev = LAST_CREATE_TS.update(SeqCst, SeqCst, next);
MilliSecondsSinceUnixEpoch(UInt::new_saturating(next(prev)))
})
});
let mut create_event_content = to_canonical_object(create_event_content)
.expect("should be able to serialize create event content");
@@ -322,7 +338,7 @@ pub(crate) async fn create_room_route(
event_type: TimelineEventType::RoomCreate,
content: to_raw_value(&create_event_content)?,
state_key: Some(StateKey::new()),
timestamp: custom_origin_server_ts,
timestamp: create_timestamp,
..Default::default()
},
sender_user,
@@ -758,11 +774,7 @@ async fn room_alias_check(
if !info.aliases.is_match(full_room_alias.as_str()) {
return Err!(Request(Exclusive("Room alias is not in namespace.")));
}
} else if services
.appservice
.is_exclusive_alias(&full_room_alias)
.await
{
} else if services.appservice.is_exclusive_alias(&full_room_alias) {
return Err!(Request(Exclusive("Room alias reserved by appservice.",)));
}
+3 -2
View File
@@ -2,11 +2,12 @@ mod aliases;
mod create;
mod event;
mod initial_sync;
mod stripped_state;
mod summary;
mod upgrade;
pub(crate) use self::{
aliases::get_room_aliases_route, create::create_room_route, event::get_room_event_route,
initial_sync::room_initial_sync_route, summary::get_room_summary,
upgrade::upgrade_room_route,
initial_sync::room_initial_sync_route, stripped_state::get_stripped_state_route,
summary::get_room_summary, upgrade::upgrade_room_route,
};
+71
View File
@@ -0,0 +1,71 @@
use axum::extract::State;
use conduwuit::{Err, Result};
use ruma::{
api::client::state::get_stripped_state, assign, events::ALLOWED_STRIPPED_STATE_EVENTS,
};
use service::rooms::summary::{Accessibility, RoomStrippedState};
use crate::{Ruma, router::ClientIdentity};
/// # `POST /_matrix/client/unstable/org.continuwuity.msc4560.stripped_state/{room_id_or_alias}` ([MSC4560])
///
/// Returns a room's stripped state.
///
/// [MSC4560]: https://github.com/matrix-org/matrix-spec-proposals/pull/4560
#[tracing::instrument(skip_all, name = "stripped_state", level = "info")]
pub(crate) async fn get_stripped_state_route(
State(services): State<crate::State>,
body: Ruma<get_stripped_state::unstable::Request>,
) -> Result<get_stripped_state::unstable::Response> {
let user_id = body.identity.as_ref().and_then(ClientIdentity::sender_user);
if body.via.len() > get_stripped_state::unstable::MAX_VIAS {
return Err!(Request(TooLarge("Too many vias, please be less indecisive.")));
}
if let Some(forbidden_type) = body
.state
.iter()
.find(|event_type| !ALLOWED_STRIPPED_STATE_EVENTS.contains(event_type))
{
return Err!(Request(InvalidParam(
"Event type {forbidden_type} may not be requested as stripped state."
)));
}
let (room_id, _) = services
.rooms
.alias
.resolve_with_servers(&body.room_id_or_alias, Some(body.via.clone()))
.await?;
if services.rooms.metadata.is_banned(&room_id).await {
return Err!(Request(Forbidden("This room is banned on this homeserver.")));
}
match services
.rooms
.summary
.get_stripped_state_for_user(
user_id,
&room_id,
&body.via,
&body.state,
body.num_joined_members,
)
.await
{
| Accessibility::Accessible((
via,
RoomStrippedState { state, num_joined_members, .. },
)) => Ok(
assign!(get_stripped_state::unstable::Response::new(via), { state, num_joined_members }),
),
| Accessibility::Inaccessible => {
Err!(Request(Forbidden("You may not request this room's stripped state.")))
},
| Accessibility::NotFound => {
Err!(Request(NotFound("This room does not exist.")))
},
}
}
+3 -6
View File
@@ -13,7 +13,7 @@ pub(crate) async fn get_room_summary(
State(services): State<crate::State>,
body: Ruma<get_summary::v1::Request>,
) -> Result<get_summary::v1::Response> {
let (room_id, servers) = services
let (room_id, _) = services
.rooms
.alias
.resolve_with_servers(&body.room_id_or_alias, Some(body.via.clone()))
@@ -27,12 +27,9 @@ pub(crate) async fn get_room_summary(
.rooms
.summary
.get_room_summary_for_user(
body.identity
.as_ref()
.map(ClientIdentity::expect_sender_user)
.transpose()?,
body.identity.as_ref().and_then(ClientIdentity::sender_user),
&room_id,
&servers,
&body.via,
)
.await?;
+1 -1
View File
@@ -201,7 +201,7 @@ pub(crate) async fn sync_events_route(
.update_device_last_seen(sender_user, Some(sender_device), client_ip)
.await;
let mut wake_receiver = services.sync.subscribe_to_wake(sender_user).await;
let mut wake_receiver = services.sync.subscribe_to_wake(sender_user);
let response = build_sync_events(&services, &body).await?;
if body.body.full_state
|| !(response.rooms.is_empty()
+1 -1
View File
@@ -147,7 +147,7 @@ pub(crate) async fn sync_events_v5_route(
.sync
.update_snake_sync_request_with_cache(&snake_key, globalsince, &mut body);
let mut wake_receiver = services.sync.subscribe_to_wake(sender_user).await;
let mut wake_receiver = services.sync.subscribe_to_wake(sender_user);
let mut collection = collect_sync_response(
services,
sender_user,
+1 -1
View File
@@ -64,7 +64,7 @@ pub(crate) async fn continuwuity_local_user_count(
.stream_local_users()
.filter_map(async |user_id| {
if !services.users.status(&user_id).await.is_active()
|| services.appservice.is_exclusive_user_id(&user_id).await
|| services.appservice.is_exclusive_user_id(&user_id)
{
None
} else {
+2
View File
@@ -184,6 +184,7 @@ pub fn build(router: Router<State>, state: State) -> Router<State> {
.ruma_route(&client::get_mutual_rooms_unstable_route)
.ruma_route(&client::get_mutual_rooms_route)
.ruma_route(&client::get_room_summary)
.ruma_route(&client::get_stripped_state_route)
.ruma_route(&client::get_suspended_status)
.ruma_route(&client::put_suspended_status)
.ruma_route(&client::get_lock_status)
@@ -229,6 +230,7 @@ pub fn build(router: Router<State>, state: State) -> Router<State> {
.ruma_route(&server::get_keys_route)
.ruma_route(&server::claim_keys_route)
.ruma_route(&server::get_hierarchy_route)
.ruma_route(&server::get_stripped_state_route)
.ruma_route(&server::well_known_server)
.ruma_route(&server::get_content_route)
.ruma_route(&server::get_content_thumbnail_route)
+28 -7
View File
@@ -41,6 +41,7 @@ pub(crate) enum ClientIdentity {
sender_device: Option<OwnedDeviceId>,
appservice_info: Box<RegistrationInfo>,
},
StaticClient,
}
impl ClientIdentity {
@@ -48,6 +49,7 @@ impl ClientIdentity {
match self {
| Self::User { sender_user, .. } | Self::Appservice { sender_user, .. } =>
Some(sender_user),
| Self::StaticClient => None,
}
}
@@ -55,6 +57,8 @@ impl ClientIdentity {
match self {
| Self::User { sender_user, .. } | Self::Appservice { sender_user, .. } =>
Ok(sender_user),
| Self::StaticClient =>
Err!(Request(Forbidden("Static clients cannot use this endpoint."))),
}
}
@@ -62,6 +66,7 @@ impl ClientIdentity {
match self {
| Self::User { sender_device, .. } => Some(sender_device),
| Self::Appservice { sender_device, .. } => sender_device.as_deref(),
| Self::StaticClient => None,
}
}
@@ -71,12 +76,14 @@ impl ClientIdentity {
| Self::Appservice { sender_device: Some(sender_device), .. } => Ok(sender_device),
| Self::Appservice { sender_device: None, .. } =>
Err!(Request(Forbidden("Appservices must masquerade to use this endpoint."))),
| Self::StaticClient =>
Err!(Request(Forbidden("Static clients cannot use this endpoint."))),
}
}
pub(crate) fn appservice_info(&self) -> Option<&RegistrationInfo> {
match self {
| Self::User { .. } => None,
| Self::User { .. } | Self::StaticClient => None,
| Self::Appservice { appservice_info, .. } => Some(appservice_info),
}
}
@@ -346,7 +353,7 @@ async fn check_access_token(
}
Ok(ClientIdentity::User { sender_user, sender_device })
} else if let Ok(appservice_info) = services.appservice.find_from_token(token).await {
} else if let Ok(appservice_info) = services.appservice.find_from_token(token) {
let Ok(sender_user) = query.user_id.clone().map_or_else(
|| {
UserId::parse_with_server_name(
@@ -379,10 +386,7 @@ async fn check_access_token(
.await
.is_err()
{
return Err!(Request(Forbidden(
"Device does not exist for user or appservice cannot masquerade as this \
device."
)));
return Err!(Request(UnknownDevice("Device does not exist for this user.")));
}
Some(device_id.to_owned())
@@ -395,6 +399,23 @@ async fn check_access_token(
sender_device,
appservice_info: Box::new(appservice_info),
})
} else if let Some(session) = services.oauth.get_client_credentials_session(token).await {
if !required_scopes
.iter()
.any(|scope| session.scopes.contains(scope))
{
return Err(Error::Request(
ErrorKind::InsufficientUserAuthentication(Box::new(
assign!(InsufficientUserAuthenticationErrorData::new(), {
scope: required_scopes.iter().cloned().collect()
}),
)),
"You do not have permission to access this endpoint.".into(),
StatusCode::UNAUTHORIZED,
));
}
Ok(ClientIdentity::StaticClient)
} else {
Err(Error::Request(
ErrorKind::UnknownToken(UnknownTokenErrorData::new()),
@@ -405,7 +426,7 @@ async fn check_access_token(
}
async fn check_appservice_token(services: &Services, token: &str) -> Result<RegistrationInfo> {
let Ok(appservice_info) = services.appservice.find_from_token(token).await else {
let Ok(appservice_info) = services.appservice.find_from_token(token) else {
return Err!(Request(Unauthorized("Invalid appservice token.")));
};
+7 -2
View File
@@ -1,7 +1,10 @@
use std::{borrow::Borrow, iter::once};
use axum::extract::State;
use conduwuit::{Err, Event, Result, info, utils::stream::ReadyExt};
use conduwuit::{
Err, Event, Result, info,
utils::stream::{BroadbandExt, ReadyExt},
};
use futures::StreamExt;
use ruma::api::federation::authorization::get_event_authorization;
@@ -64,7 +67,9 @@ pub(crate) async fn get_event_authorization_route(
.auth_chain
.event_ids_iter(&body.room_id, once(body.event_id.borrow()))
.ready_filter_map(Result::ok)
.filter_map(|id| async move { services.rooms.timeline.get_pdu_json(&id).await.ok() })
.broad_filter_map(
|id| async move { services.rooms.timeline.get_pdu_json(&id).await.ok() },
)
.then(|pdu| services.sending.convert_to_outgoing_federation_event(pdu))
.collect()
.await;
+15 -2
View File
@@ -1,7 +1,7 @@
use std::collections::{HashSet, VecDeque};
use axum::extract::State;
use conduwuit::{Err, Event, Result, debug, info, trace, utils::to_canonical_object, warn};
use conduwuit::{Err, Event, Result, debug, debug_warn, info, trace, utils::to_canonical_object};
use ruma::{OwnedEventId, api::federation::event::get_missing_events};
use serde_json::value::RawValue;
use service::rooms::event_handler::GET_MISSING_EVENTS_MAX_BATCH_SIZE;
@@ -44,6 +44,13 @@ pub(crate) async fn get_missing_events_route(
.unwrap_or(10)
.min(GET_MISSING_EVENTS_MAX_BATCH_SIZE);
if body.latest_events.len() > limit {
return Err!(Request(InvalidParam("Too many latest_events")));
}
if body.earliest_events.len() > limit {
return Err!(Request(InvalidParam("Too many earliest_events")));
}
let room_version = services.rooms.state.get_room_version(&body.room_id).await?;
let mut queue: VecDeque<OwnedEventId> = VecDeque::from(body.latest_events.clone());
@@ -64,7 +71,9 @@ pub(crate) async fn get_missing_events_route(
let mut pdu = match services.rooms.timeline.get_pdu(&next_event_id).await {
| Ok(pdu) => pdu,
| Err(e) => {
warn!("could not find event {next_event_id} while walking missing events: {e}");
debug_warn!(
"could not find event {next_event_id} while walking missing events: {e}"
);
continue;
},
};
@@ -74,6 +83,10 @@ pub(crate) async fn get_missing_events_route(
body.room_id
)));
}
if pdu.depth < body.min_depth {
debug!(%next_event_id, %pdu.depth, %body.min_depth, "event is below minimum depth, not traversing");
continue;
}
if services
.rooms
.pdu_metadata
+27 -23
View File
@@ -209,31 +209,35 @@ async fn create_invite(
services.sync.wake(&recipient_user).await;
for appservice in services.appservice.read().await.values() {
if appservice.is_user_match(&recipient_user) {
let transaction_id = general_purpose::URL_SAFE_NO_PAD
.encode(sha256::hash(pdu.event_id.as_bytes()))
.into();
let matching_appservices: Vec<_> = services
.appservice
.read()
.values()
.filter(|appservice| appservice.is_user_match(&recipient_user))
.cloned()
.collect();
let request = ruma::api::appservice::event::push_events::v1::Request::new(
transaction_id,
vec![pdu.to_format()],
);
for appservice in matching_appservices {
let transaction_id = general_purpose::URL_SAFE_NO_PAD
.encode(sha256::hash(pdu.event_id.as_bytes()))
.into();
services
.sending
.send_appservice_request(appservice.registration.clone(), request)
.await
.map_err(|e| {
error!(
"failed to notify appservice {} about incoming invite: {e}",
appservice.registration.id
);
err!(BadServerResponse(
"Failed to notify appservice about incoming invite."
))
})?;
}
let request = ruma::api::appservice::event::push_events::v1::Request::new(
transaction_id,
vec![pdu.to_format()],
);
services
.sending
.send_appservice_request(appservice.registration.clone(), request)
.await
.map_err(|e| {
error!(
"failed to notify appservice {} about incoming invite: {e}",
appservice.registration.id
);
err!(BadServerResponse("Failed to notify appservice about incoming invite."))
})?;
}
}
+67 -185
View File
@@ -1,29 +1,19 @@
use std::{borrow::ToOwned, pin::pin};
use axum::extract::State;
use conduwuit::{
Err, Error, Result, debug, debug_info, info, matrix::pdu::PartialPdu, utils, warn,
};
use conduwuit_service::Services;
use futures::StreamExt;
use conduwuit::{Err, Error, Result, info, matrix::pdu::PartialPdu, utils};
use ruma::{
OwnedUserId, RoomId, UserId,
OwnedUserId,
api::{
error::{ErrorKind, IncompatibleRoomVersionErrorData},
federation::membership::prepare_join_event,
},
assign,
events::{
StateEventType,
room::{
join_rules::{AllowRule, JoinRule, RoomJoinRulesEventContent},
member::{MembershipState, RoomMemberEventContent},
},
events::room::{
join_rules::JoinRule,
member::{MembershipState, RoomMemberEventContent},
},
};
use serde_json::value::to_raw_value;
use service::rooms::state::RoomMutexGuard;
use tokio::join;
use service::rooms::membership::{JoinConditionEntity, JoinConditionResult};
use crate::Ruma;
@@ -35,9 +25,6 @@ pub(crate) async fn create_join_event_template_route(
State(services): State<crate::State>,
body: Ruma<prepare_join_event::v1::Request>,
) -> Result<prepare_join_event::v1::Response> {
if !services.rooms.metadata.exists(&body.room_id).await {
return Err!(Request(NotFound("Room is unknown to this server.")));
}
if !services
.rooms
.state_cache
@@ -63,18 +50,6 @@ pub(crate) async fn create_join_event_template_route(
.acl_check(&body.identity, &body.room_id)
.await?;
if services
.moderation
.is_remote_server_forbidden(&body.identity)
{
warn!(
"Server {} for remote user {} tried joining room ID {} which has a server name that \
is globally forbidden. Rejecting.",
body.identity, &body.user_id, &body.room_id,
);
return Err!(Request(Forbidden("Server is banned on this homeserver.")));
}
let room_version = services.rooms.state.get_room_version(&body.room_id).await?;
let room_version_rules = room_version.rules().unwrap();
if !body.ver.contains(&room_version) {
@@ -87,41 +62,78 @@ pub(crate) async fn create_join_event_template_route(
}
let state_lock = services.rooms.state.mutex.lock(body.room_id.as_str()).await;
let (is_invited, is_joined) = join!(
services
.rooms
.state_cache
.is_invited(&body.user_id, &body.room_id),
services
.rooms
.state_cache
.is_joined(&body.user_id, &body.room_id)
);
let current_membership = services
.rooms
.state_accessor
.get_member(&body.room_id, &body.user_id)
.await
.ok()
.map_or_else(|| MembershipState::Leave, |content| content.membership);
let join_authorized_via_users_server: Option<OwnedUserId> = {
if is_joined || is_invited {
// User is already joined or invited and consequently does not need
// an authorising user
if matches!(
current_membership,
MembershipState::Join | MembershipState::Invite | MembershipState::Knock
) {
// User is already joined, invited, or knocked, and consequently
// does not need an authorising user
None
} else if !room_version_rules.authorization.restricted_join_rule {
// room version does not support restricted join rules
// Room version does not support restricted join rules
None
} else if user_can_perform_restricted_join(&services, &body.user_id, &body.room_id)
.await?
{
Some(
select_authorising_user(&services, &body.room_id, &body.user_id, &state_lock)
.await?,
)
} else {
None
let join_rules = services
.rooms
.state_accessor
.get_join_rules(&body.room_id)
.await;
if let JoinRule::Restricted(conditions) | JoinRule::KnockRestricted(conditions) =
join_rules
{
match services
.rooms
.membership
.evaluate_join_conditions(
&body.room_id,
JoinConditionEntity::User(&body.user_id),
&conditions,
)
.await
{
| JoinConditionResult::Satisfied => {
// Try to find an authorizing user
services
.rooms
.membership
.select_authorizing_user(&body.room_id, &body.user_id, &state_lock)
.await
.map(Some)?
},
| JoinConditionResult::Unsatisfied => {
return Err!(Request(Forbidden(
"You do not satisfy this room's join conditions."
)));
},
| JoinConditionResult::UnableToAuthorizeJoin => {
return Err!(Request(UnableToAuthorizeJoin(
"This server cannot check this room's join conditions."
)));
},
}
} else {
None
}
}
};
if services.antispam.check_all_joins() && join_authorized_via_users_server.is_none() {
if services.antispam.check_all_joins() {
if services
.antispam
.meowlnir_accept_make_join(body.room_id.clone(), body.user_id.clone())
.await
.is_err()
!= JoinConditionResult::Satisfied
{
return Err!(Request(Forbidden("Antispam rejected join request.")));
}
@@ -153,133 +165,3 @@ pub(crate) async fn create_join_event_template_route(
}),
)
}
/// Attempts to find a user who is able to issue an invite in the target room.
pub(crate) async fn select_authorising_user<'a>(
services: &Services,
room_id: &'a RoomId,
user_id: &'a UserId,
state_lock: &'a RoomMutexGuard,
) -> Result<OwnedUserId> {
let candidates = services.rooms.state_cache.local_users_in_room(room_id);
let mut candidates = pin!(candidates);
while let Some(candidate) = candidates.next().await {
if services
.rooms
.state_accessor
.user_can_invite(room_id, &candidate, user_id, state_lock)
.await
{
return Ok(candidate);
}
}
Err!(Request(UnableToGrantJoin(
"No user on this server is able to assist in joining."
)))
}
/// Checks whether the given user can join the given room via a restricted join.
pub(crate) async fn user_can_perform_restricted_join(
services: &Services,
user_id: &UserId,
room_id: &RoomId,
) -> Result<bool> {
let Ok(join_rules_event_content) = services
.rooms
.state_accessor
.room_state_get_content::<RoomJoinRulesEventContent>(
room_id,
&StateEventType::RoomJoinRules,
"",
)
.await
else {
// No join rules means there's nothing to authorise (defaults to invite)
return Ok(false);
};
let (JoinRule::Restricted(r) | JoinRule::KnockRestricted(r)) =
join_rules_event_content.join_rule
else {
// This is not a restricted room
return Ok(false);
};
if r.allow.is_empty() {
// This will never be authorisable, return forbidden.
return Err!(Request(Forbidden("You are not invited to this room.")));
}
let mut could_satisfy = true;
for allow_rule in &r.allow {
match allow_rule {
| AllowRule::RoomMembership(membership) => {
if !services
.rooms
.state_cache
.server_in_room(services.globals.server_name(), &membership.room_id)
.await
{
// Since we can't check this room, mark could_satisfy as
// false so that we can return
// M_UNABLE_TO_AUTHORIZE_JOIN later.
could_satisfy = false;
continue;
}
if services
.rooms
.state_cache
.is_joined(user_id, &membership.room_id)
.await
{
debug!(
"User {} is allowed to join room {} via membership in room {}",
user_id, room_id, membership.room_id
);
return Ok(true);
}
},
| other if other.rule_type() == "fi.mau.spam_checker" =>
return match services
.antispam
.meowlnir_accept_make_join(room_id.to_owned(), user_id.to_owned())
.await
{
| Ok(()) => Ok(true),
| Err(_) => Err!(Request(Forbidden("Antispam rejected join request."))),
},
| _ => {
// We don't recognise this join rule, so we cannot satisfy the
// request.
could_satisfy = false;
debug_info!(
"Unsupported allow rule in restricted join for room {}: {:?}",
room_id,
allow_rule
);
},
}
}
if could_satisfy {
// We were able to check all the restrictions and can be certain that
// the prospective member is not permitted to join.
Err!(Request(Forbidden(
"You do not belong to any of the rooms or spaces required to join this room."
)))
} else {
// We were unable to check all the restrictions. This usually means we
// aren't in one of the rooms this one is restricted to, ergo can't
// check its state for the user's membership, and consequently the
// user *might* be able to join if they ask another server.
Err!(Request(UnableToAuthorizeJoin(
"You do not belong to any of the recognised rooms or spaces required to join this \
room, but this server is unable to verify every requirement. You may be able to \
join via another server."
)))
}
}
+2
View File
@@ -18,6 +18,7 @@ pub(super) mod send_knock;
pub(super) mod send_leave;
pub(super) mod state;
pub(super) mod state_ids;
pub(super) mod stripped_state;
pub(super) mod user;
pub(super) mod version;
pub(super) mod well_known;
@@ -42,6 +43,7 @@ pub(super) use send_knock::*;
pub(super) use send_leave::*;
pub(super) use state::*;
pub(super) use state_ids::*;
pub(super) use stripped_state::*;
pub(super) use user::*;
pub(super) use version::*;
pub(super) use well_known::*;
+50 -10
View File
@@ -16,9 +16,11 @@ use ruma::{
TimelineEventType,
room::member::{MembershipState, RoomMemberEventContent},
},
room::JoinRule,
room_version_rules::RoomVersionRules,
};
use serde_json::value::to_raw_value;
use service::rooms::membership::{JoinConditionEntity, JoinConditionResult};
use crate::{Ruma, server::utils::validate_any_membership_event};
@@ -108,18 +110,56 @@ async fn create_join_event(
they cannot authorise your join."
)));
}
if !super::user_can_perform_restricted_join(services, &sender, room_id).await? {
return Err!(Request(UnableToAuthorizeJoin(
"Joining user did not pass restricted room's rules."
// If the user is invited or joined we don't need to check the join
// conditions, but in that case the requesting server shouldn't
// have set `join_authorized_via_users_server` in the first place.
let join_rules = services.rooms.state_accessor.get_join_rules(room_id).await;
if let JoinRule::Restricted(conditions) | JoinRule::KnockRestricted(conditions) =
join_rules
{
match services
.rooms
.membership
.evaluate_join_conditions(
room_id,
JoinConditionEntity::User(&sender),
&conditions,
)
.await
{
| JoinConditionResult::Satisfied => {
// Sign the join to prove that we checked the conditions.
services
.server_keys
.hash_and_sign_event(&mut pdu, room_version_rules)
.map_err(|e| {
err!(Request(InvalidParam(warn!(
"Failed to sign send_join event: {e}"
))))
})?;
},
| JoinConditionResult::Unsatisfied => {
return Err!(Request(Forbidden(
"You do not satisfy this room's join conditions."
)));
},
| JoinConditionResult::UnableToAuthorizeJoin => {
return Err!(Request(UnableToAuthorizeJoin(
"This server cannot check this room's join conditions."
)));
},
}
} else {
// We can't sign this, and if we don't sign it our event will fail
// the auth check, so we have to bail out here.
return Err!(Request(InvalidParam(
"join_authorized_via_users_server was supplied for a room that is not restricted"
)));
}
services
.server_keys
.hash_and_sign_event(&mut pdu, room_version_rules)
.map_err(|e| {
err!(Request(InvalidParam(warn!("Failed to sign send_join event: {e}"))))
})?;
}
let mutex_lock = services
+54
View File
@@ -0,0 +1,54 @@
use axum::extract::State;
use conduwuit::{Err, Result};
use ruma::{
api::federation::event::get_stripped_state, assign, events::ALLOWED_STRIPPED_STATE_EVENTS,
};
use service::rooms::summary::{Accessibility, RoomStrippedState};
use crate::Ruma;
/// # `POST /_matrix/federation/unstable/org.continuwuity.msc4560.stripped_state/{room_id}` ([MSC4560])
///
/// Returns a room's stripped state.
///
/// [MSC4560]: https://github.com/matrix-org/matrix-spec-proposals/pull/4560
pub(crate) async fn get_stripped_state_route(
State(services): State<crate::State>,
body: Ruma<get_stripped_state::unstable::Request>,
) -> Result<get_stripped_state::unstable::Response> {
if let Some(forbidden_type) = body
.state
.iter()
.find(|event_type| !ALLOWED_STRIPPED_STATE_EVENTS.contains(event_type))
{
return Err!(Request(InvalidParam(
"Event type {forbidden_type} may not be requested as stripped state."
)));
}
if services.rooms.metadata.is_banned(&body.room_id).await {
return Err!(Request(Forbidden("This room is banned on this homeserver.")));
}
match services
.rooms
.summary
.get_local_stripped_state_for_server(
&body.identity,
&body.room_id,
&body.state,
body.num_joined_members,
)
.await
{
| Accessibility::Accessible(RoomStrippedState { state, num_joined_members, .. }) => Ok(
assign!(get_stripped_state::unstable::Response::default(), { state, num_joined_members }),
),
| Accessibility::Inaccessible => {
Err!(Request(Forbidden("You may not access this room's stripped state.")))
},
| Accessibility::NotFound => {
Err!(Request(NotFound("This room is not known to this server.")))
},
}
}
+63 -8
View File
@@ -1,5 +1,10 @@
use std::{
collections::BTreeMap, env, fmt::Write as FmtWrite, fs, io::Write, path::Path,
collections::BTreeMap,
env,
fmt::Write as FmtWrite,
fs,
io::Write,
path::{Path, PathBuf},
process::Command,
};
@@ -130,18 +135,68 @@ fn main() {
}
// --- Rerun Triggers ---
// TODO: The git rerun triggers seem to always run
// // Rerun if the git HEAD changes
// println!("cargo:rerun-if-changed=.git/HEAD");
// // Rerun if the ref pointed to by HEAD changes (e.g., new commit on
// branch) if let Some(ref_path) = run_git_command(&["symbolic-ref",
// "--quiet", "HEAD"]) { println!("cargo:rerun-if-changed=.git/{ref_path}"
// ); }
let resolve_git_path = |path_str: &str| -> PathBuf {
let p = Path::new(path_str);
if p.is_absolute() {
p.to_path_buf()
} else {
Path::new(&manifest_dir).join(p)
}
};
// If workspace root has a .git file (e.g., git worktree or submodule),
// watch it
let workspace_git = metadata.workspace_root.as_std_path().join(".git");
if workspace_git.is_file() {
println!("cargo:rerun-if-changed={}", workspace_git.display());
}
// Rerun if the git HEAD changes
if let Some(git_head) = run_git_command(&["rev-parse", "--git-path", "HEAD"]) {
let head_path = resolve_git_path(&git_head);
if head_path.exists() {
println!("cargo:rerun-if-changed={}", head_path.display());
}
}
// Rerun if the ref pointed to by HEAD changes (e.g., new commit on branch)
if let Some(ref_name) = run_git_command(&["symbolic-ref", "--quiet", "HEAD"]) {
if let Some(git_ref) = run_git_command(&["rev-parse", "--git-path", &ref_name]) {
let ref_path = resolve_git_path(&git_ref);
if ref_path.exists() {
println!("cargo:rerun-if-changed={}", ref_path.display());
} else {
// If the loose ref file does not exist (e.g. refs are packed),
// watch the nearest existing ancestor directory
// so newly created refs trigger rerun.
let mut dir = ref_path.parent();
while let Some(d) = dir {
if d.exists() {
println!("cargo:rerun-if-changed={}", d.display());
break;
}
dir = d.parent();
}
}
}
}
// If packed-refs exists, watch it so git pack-refs or updates to packed
// refs trigger rerun
if let Some(git_packed) = run_git_command(&["rev-parse", "--git-path", "packed-refs"]) {
let packed_path = resolve_git_path(&git_packed);
if packed_path.exists() {
println!("cargo:rerun-if-changed={}", packed_path.display());
}
}
println!("cargo:rerun-if-env-changed=GIT_COMMIT_HASH");
println!("cargo:rerun-if-env-changed=GIT_COMMIT_HASH_SHORT");
println!("cargo:rerun-if-env-changed=GIT_REMOTE_URL");
println!("cargo:rerun-if-env-changed=GIT_REMOTE_COMMIT_URL");
println!("cargo:rerun-if-env-changed=CONTINUWUITY_VERSION_EXTRA");
println!("cargo:rerun-if-env-changed=CONDUWUIT_VERSION_EXTRA");
println!("cargo:rerun-if-env-changed=CONDUIT_VERSION_EXTRA");
}
fn generate_features_code(features: &BTreeMap<String, Vec<String>>) -> String {
+9
View File
@@ -353,6 +353,15 @@ pub fn check(config: &Config) -> Result {
}
})?;
for (id, client) in &config.oauth.clients {
if client.scopes.is_empty() {
warn!(
"The static OAuth client `{id}` has no scopes configured. It will not be able \
to access any API endpoints."
);
}
}
Ok(())
}
+56 -2
View File
@@ -24,6 +24,7 @@ use ruma::{
OwnedRoomId, OwnedRoomOrAliasId, OwnedServerName, OwnedServerSigningKeyId, OwnedUserId,
RoomVersionId, ServerName,
api::{
OAuthClientScope,
client::{discovery::discover_support::ContactRole, rtc::RtcTransport},
federation::discovery::OldVerifyKey,
},
@@ -65,8 +66,8 @@ use crate::{Result, err, error::Error, utils::sys};
ignore = "config_paths catchall"
)]
pub struct Config {
// Paths to config file(s). Not supposed to be set manually in the config file,
// only updated dynamically from the --config option given at runtime.
// Paths to config file(s). Not supposed to be set manually in the config
// file, only updated dynamically from the --config option given at runtime.
pub config_paths: Option<Vec<PathBuf>>,
/// The server_name is the pretty name of this server. It is used as a
@@ -2746,7 +2747,12 @@ pub struct OauthConfig {
compatibility_mode: OAuthMode,
/// display: hidden
#[serde(default)]
pub oidc: Option<OidcConfig>,
/// display: hidden
#[serde(default)]
pub clients: HashMap<String, OAuthClient>,
}
impl OauthConfig {
@@ -2960,6 +2966,54 @@ impl TrustedServerConfig {
}
}
#[derive(Clone, Debug, Deserialize)]
#[config_example_generator(
filename = "conduwuit-example.toml",
section = "global.oauth.clients.\"$id\"",
optional = "true",
subheader = "\
# Use this section to add static OAuth clients for bots and automation.
# Clients added here may use the client credentials OAuth grant to authorize
# themselves with Continuwuity.
#
# Make sure to replace `$id` in the header with your client ID of choice! You can
# add more copies of this section with different IDs to add multiple clients.
#
# Because the client credentials grant authorizes the client as itself, without
# an attached user, clients that use it will not be able to access most of the Matrix
# client-server API. Administrative functionality that does not require a user
# will still be available."
)]
pub struct OAuthClient {
/// The client's client secret.
///
/// This must be supplied as the `client_secret` parameter when requesting
/// an access token with the OAuth 2.0 token endpoint. Continuwuity does
/// not check the `Authorization` header for requests to this endpoint.
pub client_secret: String,
/// A list of scopes that the client may request. Continuwuity allows static
/// clients to request the following scopes:
///
/// - "urn:matrix:client:cc.c10y.msc4484.server_administration" (MSC4484):
/// This scope grants access to the Matrix server administration APIs, as
/// well as Continuwuity's internal admin API (currently a work in
/// progress).
/// - "urn:matrix:client:api:*": This scope grants access to the Matrix
/// client-server API. Most endpoints require an authenticated Matrix user
/// and thus will not be usable by static clients.
///
/// The `urn:matrix:client:device:<id>` scope may not be requested by static
/// clients.
///
/// Scopes listed here are not granted by default. The client must
/// explicitly include them in the `scope` parameter of its access token
/// request.
///
/// default: []
pub scopes: BTreeSet<OAuthClientScope>,
}
const DEPRECATED_KEYS: &[&str] = &[
"cache_capacity",
"conduit_cache_capacity_modifier",
+66 -4
View File
@@ -39,7 +39,7 @@ use crate::{
debug, debug_error, err,
matrix::{Event, StateKey},
trace,
utils::stream::{BroadbandExt, IterStream, ReadyExt, TryBroadbandExt, WidebandExt},
utils::stream::{BroadbandExt, IterStream, ReadyExt, TryWidebandExt, WidebandExt},
warn,
};
@@ -590,8 +590,8 @@ where
.find(|aev| is_type_and_key(*aev, &TimelineEventType::RoomPowerLevels, ""));
let content: PowerLevelsContentFields = match pl {
// With no m.room.power_levels in scope the create event's defaults apply,
// under which the room creator holds 100 and everyone else 0.
// With no m.room.power_levels in scope the create event's defaults
// apply, under which the room creator holds 100 and everyone else 0.
| None => return Ok(if sender_is_creator { int!(100) } else { int!(0) }),
| Some(ev) => from_json_str(ev.content().get())?,
};
@@ -706,7 +706,7 @@ where
let events_to_check: Vec<_> = events_to_check
.map(Result::Ok)
.broad_and_then(async |event_id| {
.wide_and_then(async |event_id| {
fetch_event(event_id.to_owned())
.await
.ok_or_else(|| Error::NotFound(format!("Failed to find {event_id}")))
@@ -1123,6 +1123,68 @@ mod tests {
utils::stream::IterStream,
};
#[tokio::test]
async fn iterative_auth_check_keeps_event_order() {
let mut events = INITIAL_EVENTS();
let initial_state = ["CREATE", "IPOWER", "IJR", "IMB"]
.into_iter()
.map(|id| {
let event = &events[&event_id(id)];
(
event
.event_type()
.with_state_key(event.state_key().unwrap()),
event.event_id.clone(),
)
})
.collect();
let leave = to_pdu_event(
"LEAVE",
bob(),
TimelineEventType::RoomMember,
Some(bob().as_str()),
to_raw_json_value(&json!({ "membership": "leave" })).unwrap(),
&["CREATE", "IPOWER", "IMB"],
&["IMB"],
);
let rejoin = to_pdu_event(
"REJOIN",
bob(),
TimelineEventType::RoomMember,
Some(bob().as_str()),
member_content_join(),
&["CREATE", "IPOWER", "IJR", "LEAVE"],
&["LEAVE"],
);
let ordered_events = [leave.event_id.clone(), rejoin.event_id.clone()];
for event in [leave, rejoin] {
events.insert(event.event_id.clone(), event);
}
let fetcher = |id: OwnedEventId| {
let events = &events;
async move {
// Let the rejoin fetch finish before the leave.
if id == event_id("LEAVE") {
tokio::task::yield_now().await;
}
events.get(&id).cloned()
}
};
let resolved = super::iterative_auth_check(
&RoomVersionRules::V6,
ordered_events.iter().map(AsRef::as_ref).stream(),
initial_state,
&fetcher,
)
.await
.unwrap();
assert_eq!(
resolved[&StateEventType::RoomMember.with_state_key(bob().as_str())],
event_id("REJOIN"),
);
}
/// Events at the start of a room have no `m.room.power_levels` in their
/// auth events, so the sender's power for sort ordering comes from the
/// create event instead.
+2
View File
@@ -50,5 +50,7 @@ pub fn unstable_features() -> BTreeMap<String, bool> {
("uk.timedout.msc4494".to_owned(), true),
// server administration OAuth scope (https://github.com/matrix-org/matrix-spec-proposals/pull/4484)
("org.continuwuity.msc4484.unstable".to_owned(), true),
// stripped state over federation (https://github.com/matrix-org/matrix-spec-proposals/pull/4560)
("org.continuwuity.msc4560".to_owned(), true),
])
}
+4 -3
View File
@@ -14,6 +14,8 @@ use tokio_metrics::TaskMonitor;
use tokio_metrics::{RuntimeIntervals, RuntimeMonitor};
pub use self::instruments::{Instruments, duration_buckets};
#[cfg(tokio_unstable)]
use crate::SyncMutex;
use crate::{Err, Result};
pub struct Metrics {
@@ -27,7 +29,7 @@ pub struct Metrics {
_runtime_monitor: Option<RuntimeMonitor>,
#[cfg(tokio_unstable)]
runtime_intervals: std::sync::Mutex<Option<RuntimeIntervals>>,
runtime_intervals: SyncMutex<Option<RuntimeIntervals>>,
// TODO: move stats
pub requests_handle_active: AtomicU32,
@@ -69,7 +71,7 @@ impl Metrics {
_runtime_monitor: runtime_monitor,
#[cfg(tokio_unstable)]
runtime_intervals: std::sync::Mutex::new(runtime_intervals),
runtime_intervals: SyncMutex::new(runtime_intervals),
requests_handle_active: AtomicU32::new(0),
requests_handle_finished: AtomicU32::new(0),
@@ -81,7 +83,6 @@ impl Metrics {
pub fn runtime_interval(&self) -> Option<tokio_metrics::RuntimeMetrics> {
self.runtime_intervals
.lock()
.expect("locked")
.as_mut()
.map(Iterator::next)
.expect("next interval")
+4 -1
View File
@@ -36,7 +36,10 @@ pub use config::Config;
pub use error::Error;
pub use info::version::*;
pub use matrix::{Event, EventTypeExt, Pdu, PduCount, PduEvent, PduId, pdu, state_res};
pub use parking_lot::{Mutex as SyncMutex, RwLock as SyncRwLock};
pub use parking_lot::{
Mutex as SyncMutex, RwLock as SyncRwLock, RwLockReadGuard as SyncRwLockReadGuard,
RwLockWriteGuard as SyncRwLockWriteGuard,
};
pub use server::Server;
pub use utils::{result, result::Result};
+1 -1
View File
@@ -171,7 +171,7 @@ pub(super) static MAPS: &[Descriptor] = &[
},
Descriptor {
name: "referencedevents",
..descriptor::RANDOM
..descriptor::DROPPED
},
Descriptor {
name: "refreshtoken_refreshtokeninfo",
+5 -2
View File
@@ -69,7 +69,7 @@ pub(crate) async fn run(server: &Arc<Server>, starts: bool) -> Result<(bool, boo
let reloads = server.server.reloading.swap(false, Ordering::AcqRel);
let stops = !reloads || stale(server).await? <= restart_thresh();
let stops = !reloads || stale_from_mods(&main_lock)? <= restart_thresh();
let starts = reloads && stops;
if stops {
let stop = main_mod.get::<StopFuncProto>("stop")?;
@@ -140,7 +140,10 @@ async fn stale_count(server: &Arc<Server>) -> usize {
async fn stale(server: &Arc<Server>) -> Result<usize, Error> {
let mods_lock = server.mods.read().await;
let mods: &Vec<mods::Module> = &mods_lock;
stale_from_mods(&mods_lock)
}
fn stale_from_mods(mods: &[mods::Module]) -> Result<usize, Error> {
for (i, module) in mods.iter().enumerate() {
if module.deleted()? {
return Ok(i);
+16 -24
View File
@@ -1,19 +1,12 @@
#![cfg(feature = "sentry_telemetry")]
use std::{
borrow::Cow,
str::FromStr,
sync::{Arc, OnceLock},
};
use std::{borrow::Cow, sync::OnceLock};
use conduwuit_build_metadata as build;
use conduwuit_core::{config::Config, debug, trace};
use sentry::{
Breadcrumb, ClientOptions, Level,
types::{
Dsn,
protocol::v7::{Context, Event},
},
types::protocol::v7::{Context, Event},
};
static SEND_PANIC: OnceLock<bool> = OnceLock::new();
@@ -37,22 +30,21 @@ fn options(config: &Config) -> ClientOptions {
.expect("init_sentry should only be called if sentry is enabled and this is not None")
.as_str();
let server_name = config
.sentry_send_server_name
.then(|| config.server_name.to_string().into());
let options = ClientOptions::new()
.dsn(dsn)
.traces_sample_rate(config.sentry_traces_sample_rate)
.debug(cfg!(debug_assertions))
.maybe_release(release_name())
.user_agent(conduwuit_core::user_agent())
.attach_stacktrace(config.sentry_attach_stacktrace)
.before_send(before_send)
.before_breadcrumb(before_breadcrumb);
ClientOptions {
dsn: Some(Dsn::from_str(dsn).expect("sentry_endpoint must be a valid URL")),
server_name,
traces_sample_rate: config.sentry_traces_sample_rate,
debug: cfg!(debug_assertions),
release: release_name(),
user_agent: conduwuit_core::user_agent().into(),
attach_stacktrace: config.sentry_attach_stacktrace,
before_send: Some(Arc::new(before_send)),
before_breadcrumb: Some(Arc::new(before_breadcrumb)),
..Default::default()
}
config
.sentry_send_server_name
.then(|| config.server_name.to_string())
.into_iter()
.fold(options, ClientOptions::server_name)
}
fn before_send(event: Event<'static>) -> Option<Event<'static>> {
+2 -2
View File
@@ -25,7 +25,7 @@ pub(crate) async fn run(services: Arc<Services>) -> Result<()> {
debug!("Start");
// Install the admin room callback here for now
admin::init(&services.admin).await;
admin::init(&services.admin);
// Setup shutdown/signal handling
let handle = ServerHandle::new();
@@ -60,7 +60,7 @@ pub(crate) async fn run(services: Arc<Services>) -> Result<()> {
_ = sigs.await;
// Remove the admin room callback
admin::fini(&services.admin).await;
admin::fini(&services.admin);
debug_info!("Finish");
res
+7 -5
View File
@@ -27,7 +27,6 @@ use ruma::{
},
},
};
use tokio::sync::RwLock;
use crate::{
Dep, account_data, config, globals,
@@ -38,7 +37,7 @@ use crate::{
pub struct Service {
services: Services,
channel: (Sender<CommandInput>, Receiver<CommandInput>),
pub handle: RwLock<Option<Processor>>,
pub handle: SyncRwLock<Option<Processor>>,
pub complete: SyncRwLock<Option<Completer>>,
#[cfg(feature = "console")]
pub console: Arc<console::Console>,
@@ -131,7 +130,7 @@ impl crate::Service for Service {
media: args.depend::<crate::media::Service>("media"),
},
channel: loole::bounded(COMMAND_QUEUE_LIMIT),
handle: RwLock::new(None),
handle: SyncRwLock::new(None),
complete: SyncRwLock::new(None),
#[cfg(feature = "console")]
console: console::Console::new(&args),
@@ -372,8 +371,11 @@ impl Service {
}
async fn process_command(&self, command: CommandInput) -> ProcessorResult {
let handle_guard = self.handle.read().await;
let handle = handle_guard.as_ref().expect("Admin module is not loaded");
let handle = *self
.handle
.read()
.as_ref()
.expect("Admin module is not loaded");
let services = self
.services
+19 -13
View File
@@ -8,7 +8,7 @@ use ruma::{
};
use ruminuwuity::{draupnir_antispam, meowlnir_antispam};
use crate::{client, config, sending, service::Dep};
use crate::{client, config, rooms::membership::JoinConditionResult, sending, service::Dep};
struct Services {
server: Arc<Server>,
@@ -103,7 +103,7 @@ impl Service {
} else {
Ok(())
};
self.record("user_may_invite", &result);
self.record("user_may_invite", if result.is_ok() { "allowed" } else { "denied" });
return result;
}
Ok(())
@@ -149,7 +149,7 @@ impl Service {
} else {
Ok(())
};
self.record("user_may_join_room", &result);
self.record("user_may_join_room", if result.is_ok() { "allowed" } else { "denied" });
return result;
}
Ok(())
@@ -161,10 +161,10 @@ impl Service {
&self,
room_id: OwnedRoomId,
user_id: OwnedUserId,
) -> Result<()> {
) -> JoinConditionResult {
if let Some(Antispam { meowlnir: Some(meowlnir), .. }) = &self.services.config.antispam {
debug!(?room_id, ?user_id, "Asking meowlnir for accept_make_join");
let result = self
match self
.send_antispam_request(
meowlnir.base_url.as_str(),
&meowlnir.secret,
@@ -175,18 +175,24 @@ impl Service {
),
)
.await
.inspect(|_| debug!("meowlnir allowed the make_join"))
.inspect_err(|e| debug!("meowlnir denied the make_join: {e:?}"))
.map(|_| ());
self.record("accept_make_join", &result);
result
{
| Ok(_) => {
debug!("meowlnir allowed the make_join");
self.record("accept_make_join", "allowed");
JoinConditionResult::Satisfied
},
| Err(err) => {
debug!("meowlnir denied the make_join: {err:?}");
self.record("accept_make_join", "denied");
JoinConditionResult::Unsatisfied
},
}
} else {
Ok(())
JoinConditionResult::UnableToAuthorizeJoin
}
}
fn record(&self, check: &'static str, result: &Result) {
let outcome = if result.is_ok() { "allowed" } else { "denied" };
fn record(&self, check: &'static str, outcome: &'static str) {
self.services
.server
.metrics
+16 -32
View File
@@ -1,20 +1,19 @@
mod namespace_regex;
mod registration_info;
use std::{collections::BTreeMap, iter::IntoIterator, sync::Arc};
use std::{collections::BTreeMap, sync::Arc};
use async_trait::async_trait;
use conduwuit::{Err, Result, err, utils::stream::IterStream};
use conduwuit::{Err, Result, SyncRwLock, SyncRwLockReadGuard, err, utils::stream::IterStream};
use database::Map;
use futures::{Future, FutureExt, Stream, TryStreamExt};
use futures::{Stream, TryStreamExt};
use ruma::{RoomAliasId, RoomId, UserId, api::appservice::Registration};
use tokio::sync::{RwLock, RwLockReadGuard};
pub use self::{namespace_regex::NamespaceRegex, registration_info::RegistrationInfo};
use crate::{Dep, globals, sending, users};
pub struct Service {
registration_info: RwLock<Registrations>,
registration_info: SyncRwLock<Registrations>,
services: Services,
db: Data,
}
@@ -35,7 +34,7 @@ type Registrations = BTreeMap<String, RegistrationInfo>;
impl crate::Service for Service {
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
Ok(Arc::new(Self {
registration_info: RwLock::new(BTreeMap::new()),
registration_info: SyncRwLock::new(BTreeMap::new()),
services: Services {
globals: args.depend::<globals::Service>("globals"),
sending: args.depend::<sending::Service>("sending"),
@@ -123,7 +122,6 @@ impl Service {
self.registration_info
.write()
.await
.insert(id, registration.try_into()?);
Ok(())
@@ -139,7 +137,7 @@ impl Service {
// Check for token collision with other appservices (allow
// re-registration of same appservice)
if let Ok(existing) = self.find_from_token(&registration.as_token).await {
if let Ok(existing) = self.find_from_token(&registration.as_token) {
if existing.registration.id != registration.id {
return Err(err!(Request(InvalidParam(
"Cannot register appservice: Token is already used by appservice '{}'. \
@@ -182,7 +180,6 @@ impl Service {
// removes the appservice registration info
self.registration_info
.write()
.await
.remove(appservice_id)
.ok_or_else(|| err!("Appservice not found"))?;
@@ -197,19 +194,17 @@ impl Service {
.await
}
pub async fn get_registration(&self, id: &str) -> Option<Registration> {
pub fn get_registration(&self, id: &str) -> Option<Registration> {
self.registration_info
.read()
.await
.get(id)
.cloned()
.map(|info| info.registration)
}
/// Returns Result to match users::find_from_token for select_ok usage
pub async fn find_from_token(&self, token: &str) -> Result<RegistrationInfo> {
pub fn find_from_token(&self, token: &str) -> Result<RegistrationInfo> {
self.read()
.await
.values()
.find(|info| info.registration.as_token == token)
.cloned()
@@ -217,26 +212,21 @@ impl Service {
}
/// Checks if a given user id matches any exclusive appservice regex
pub async fn is_exclusive_user_id(&self, user_id: &UserId) -> bool {
pub fn is_exclusive_user_id(&self, user_id: &UserId) -> bool {
self.read()
.await
.values()
.any(|info| info.is_exclusive_user_match(user_id))
}
/// Checks if a given user id matches any appservice regex, exclusive or
/// otherwise
pub async fn is_user_id(&self, user_id: &UserId) -> bool {
self.read()
.await
.values()
.any(|info| info.is_user_match(user_id))
pub fn is_user_id(&self, user_id: &UserId) -> bool {
self.read().values().any(|info| info.is_user_match(user_id))
}
/// Checks if a given room alias matches any exclusive appservice regex
pub async fn is_exclusive_alias(&self, alias: &RoomAliasId) -> bool {
pub fn is_exclusive_alias(&self, alias: &RoomAliasId) -> bool {
self.read()
.await
.values()
.any(|info| info.aliases.is_exclusive_match(alias.as_str()))
}
@@ -245,19 +235,15 @@ impl Service {
///
/// TODO: use this?
#[allow(dead_code)]
pub async fn is_exclusive_room_id(&self, room_id: &RoomId) -> bool {
pub fn is_exclusive_room_id(&self, room_id: &RoomId) -> bool {
self.read()
.await
.values()
.any(|info| info.rooms.is_exclusive_match(room_id.as_str()))
}
pub fn iter_ids(&self) -> impl Stream<Item = String> + Send {
self.read()
.map(|info| info.keys().cloned().collect::<Vec<_>>())
.map(IntoIterator::into_iter)
.map(IterStream::stream)
.flatten_stream()
let ids: Vec<String> = self.read().keys().cloned().collect();
ids.stream()
}
pub fn iter_db_ids(&self) -> impl Stream<Item = Result<(String, Registration)>> + Send {
@@ -281,7 +267,5 @@ impl Service {
})
}
pub fn read(&self) -> impl Future<Output = RwLockReadGuard<'_, Registrations>> + Send {
self.registration_info.read()
}
pub fn read(&self) -> SyncRwLockReadGuard<'_, Registrations> { self.registration_info.read() }
}
+2 -2
View File
@@ -146,8 +146,8 @@ impl crate::Service for Service {
.redirect(redirect::Policy::limited(2))
.build()?,
// MSC4174 recommends against following redirects, since the destination
// is only checked before the request is sent.
// MSC4174 recommends against following redirects, since the
// destination is only checked before the request is sent.
webpush: base(config)?
.connect_timeout(Duration::from_secs(config.pusher_conn_timeout))
.timeout(Duration::from_secs(config.pusher_timeout))
Loaded 100 of 143 files, more files were not shown because too many files have changed in this diff. Show more