mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-12-04 22:31:47 +00:00
Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f28c1cef93 | ||
|
|
a2e9c1c964 | ||
|
|
c9a3f9f907 | ||
|
|
d97c2d7038 | ||
|
|
fbc7ffff5e | ||
|
|
4552bb4c7a | ||
|
|
4b3d206a09 | ||
|
|
c5ed289952 |
No files matched your search
@@ -17,7 +17,7 @@ go to "files changed", and click on the "+" symbol in the line number gutter,
|
||||
and attach comments to the lines that you think would benefit from some clarification.
|
||||
-->
|
||||
|
||||
This pull request... <!-- do not forget to write here! -->
|
||||
This pull request...
|
||||
|
||||
<!-- Example:
|
||||
This pull request allows us to warp through time and space ten times faster than before by
|
||||
@@ -26,8 +26,8 @@ efficient. This resolves the common issue where we have to wait more than 10 mil
|
||||
engage, use, and disengage the warp drive when travelling between galaxies.
|
||||
-->
|
||||
|
||||
<!-- Closes #... -->
|
||||
<!-- Fixes #... -->
|
||||
<!-- Closes: #... -->
|
||||
<!-- Fixes: #... -->
|
||||
<!-- Uncomment the above line(s) if your pull request fixes an issue or closes another pull request
|
||||
by superseding it. Replace `#...` with the issue/pr number, such as `#123`. -->
|
||||
|
||||
@@ -73,7 +73,6 @@ Notes on these requirements:
|
||||
main, it's difficult to get out cleanly, so put on your best dress, smile for the cameras!
|
||||
-->
|
||||
|
||||
<!-- Do not delete below this line -->
|
||||
[c1]: https://forgejo.ellis.link/continuwuation/continuwuity/src/branch/main/CONTRIBUTING.md
|
||||
[c2]: https://forgejo.ellis.link/continuwuation/continuwuity/src/branch/main/docs/development/code_style.mdx
|
||||
[c1pc]: https://forgejo.ellis.link/continuwuation/continuwuity/src/branch/main/CONTRIBUTING.md#pre-commit-checks
|
||||
|
||||
@@ -5,6 +5,8 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- "v*"
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
|
||||
@@ -24,7 +24,7 @@ repos:
|
||||
- id: check-added-large-files
|
||||
|
||||
- repo: https://github.com/crate-ci/typos
|
||||
rev: v1.53.0
|
||||
rev: v1.52.2
|
||||
hooks:
|
||||
- id: typos
|
||||
- id: typos
|
||||
@@ -62,11 +62,3 @@ repos:
|
||||
types: [ rust ]
|
||||
stages:
|
||||
- pre-push
|
||||
|
||||
- repo: https://code.forgejo.org/forgejo/runner
|
||||
rev: v13.3.0
|
||||
hooks:
|
||||
- id: forgejo-runner-validate
|
||||
stages:
|
||||
- pre-commit
|
||||
files: ".forgejo/*"
|
||||
Generated
+576
-119
File diff suppressed because it is too large.
Load diff
+15
-3
@@ -166,6 +166,15 @@ features = [
|
||||
"form",
|
||||
]
|
||||
|
||||
# Needed for as long as openidconnect is on an outdated reqwest
|
||||
[workspace.dependencies.reqwest_0_12]
|
||||
package = "reqwest"
|
||||
version = "0.12"
|
||||
default-features = false
|
||||
features = [
|
||||
"rustls-tls-native-roots-no-provider",
|
||||
]
|
||||
|
||||
[workspace.dependencies.serde]
|
||||
version = "1.0.229"
|
||||
default-features = false
|
||||
@@ -260,6 +269,9 @@ features = [
|
||||
[workspace.dependencies.tokio-metrics]
|
||||
version = "0.5.2"
|
||||
|
||||
[workspace.dependencies.tokio-stream]
|
||||
version = "0.1.19"
|
||||
|
||||
[workspace.dependencies.wildmatch]
|
||||
version = "2.7.0"
|
||||
|
||||
@@ -389,7 +401,6 @@ features = [
|
||||
"unstable-msc4484",
|
||||
"unstable-msc4540",
|
||||
"unstable-msc4560",
|
||||
"unstable-msc4563",
|
||||
"unstable-extensible-events",
|
||||
]
|
||||
|
||||
@@ -413,9 +424,10 @@ default-features = false
|
||||
version = "0.11.0"
|
||||
default-features = false
|
||||
|
||||
[workspace.dependencies.openid]
|
||||
version = "0.26.0"
|
||||
[workspace.dependencies.openidconnect]
|
||||
version = "4.1.0"
|
||||
default-features = false
|
||||
features = ["reqwest"]
|
||||
|
||||
# optional opentelemetry, performance measurements, flamegraphs, etc for performance measurements and monitoring
|
||||
[workspace.dependencies.opentelemetry]
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
Fixed read receipts for all but one of a user's threads not being sent over federation. Contributed by @eleboucher.
|
||||
@@ -0,0 +1 @@
|
||||
Add a new parallel room handler queue system. Slow rooms no longer bog down federation across the entire server. Contributed by @nex.
|
||||
@@ -1 +0,0 @@
|
||||
Added server-side support for [MSC4563: direct_message push rule](https://github.com/matrix-org/matrix-spec-proposals/pull/4563). Contributed by @nex.
|
||||
@@ -1 +0,0 @@
|
||||
The `element_hacks` build feature, which has done almost nothing for many versions, has been removed completely. Contributed by @ginger.
|
||||
@@ -2808,18 +2808,6 @@
|
||||
# env: CONTINUWUITY_EXPERIMENTS__MSC4560
|
||||
#msc4560 = false
|
||||
|
||||
# MSC4563: `direct_message` push rule
|
||||
#
|
||||
# Creates a new kind of push rule that creates a notification if a message
|
||||
# is received in a room that is in the user's direct message list. This
|
||||
# more accurately identifies direct messages, rather than relying on a "DM
|
||||
# room" only consisting of two members.
|
||||
#
|
||||
# https://github.com/matrix-org/matrix-spec-proposals/pull/4563
|
||||
#
|
||||
# env: CONTINUWUITY_EXPERIMENTS__MSC4563
|
||||
#msc4563 = false
|
||||
|
||||
#[global.experiments.msc2815]
|
||||
# MSC2815: Proposal to allow room moderators to view redacted event content
|
||||
#
|
||||
|
||||
@@ -102,7 +102,7 @@ look like this:
|
||||
RUSTFLAGS="--cfg tokio_unstable" cargo +nightly build \
|
||||
--release \
|
||||
--no-default-features \
|
||||
--features=systemd,gzip_compression,brotli_compression,zstd_compression,tokio_console
|
||||
--features=systemd,element_hacks,gzip_compression,brotli_compression,zstd_compression,tokio_console
|
||||
```
|
||||
|
||||
You will also need to enable the `tokio_console` config option in Continuwuity
|
||||
|
||||
+1
-1
@@ -146,7 +146,7 @@ cargo clippy \
|
||||
--locked \
|
||||
--profile test \
|
||||
--no-default-features \
|
||||
--features=console,systemd,direct_tls,perf_measurements,brotli_compression \
|
||||
--features=console,systemd,element_hacks,direct_tls,perf_measurements,brotli_compression \
|
||||
--color=always \
|
||||
-- \
|
||||
-D warnings
|
||||
|
||||
Generated
+95
-132
@@ -16,38 +16,35 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@emnapi/core": {
|
||||
"version": "1.11.3",
|
||||
"resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.11.3.tgz",
|
||||
"integrity": "sha512-zLpS5asjEb7lq8jYLq37N6XKaE41DIexlY1rF/z4/tIl3wo13Sqm28fRyfIsKZD+NZ8mM5RoKkpW/rBcuoSZSg==",
|
||||
"version": "2.0.0-beta.3",
|
||||
"resolved": "https://registry.npmjs.org/@emnapi/core/-/core-2.0.0-beta.3.tgz",
|
||||
"integrity": "sha512-KA+gOBtbifRATmUa/Gpf5C2B2EJ0r4brHUT3XSgACeHREcuiObXH56xd+B3fFsEFbUT04VBEe6MuZiCtMp0tQg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@emnapi/wasi-threads": "1.2.3",
|
||||
"@emnapi/wasi-threads": "2.2.0",
|
||||
"tslib": "^2.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@emnapi/runtime": {
|
||||
"version": "1.11.3",
|
||||
"resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.11.3.tgz",
|
||||
"integrity": "sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA==",
|
||||
"version": "2.0.0-beta.3",
|
||||
"resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-2.0.0-beta.3.tgz",
|
||||
"integrity": "sha512-ayb/PyyLzpwRyFVxeC0uoEHu59QlB1iWGcGsOpXQcaB/Dc+uGfBmNmpCHp3HmTT0t8lSsMmg3j7+tdJW/TlHjQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"tslib": "^2.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@emnapi/wasi-threads": {
|
||||
"version": "1.2.3",
|
||||
"resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.3.tgz",
|
||||
"integrity": "sha512-ELEBe8PsLvvJ6QMr0zLt8ffvOHW/dc1m3CEzNMg7aJUv3bMaoDtw2TXyDAwkYBuroxxuHEwhRTLJSe5sya547g==",
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-2.2.0.tgz",
|
||||
"integrity": "sha512-JP7OYH38Q7+pyTAe14raZHLQIK7BDKbdwji+Xi3pcd/6QkJYQH3SX4wu6EplGrGJWRepoNzedfm0G3B9Z4e9Rw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"tslib": "^2.4.0"
|
||||
}
|
||||
@@ -131,13 +128,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rsbuild/core": {
|
||||
"version": "2.3.7",
|
||||
"resolved": "https://registry.npmjs.org/@rsbuild/core/-/core-2.3.7.tgz",
|
||||
"integrity": "sha512-IvJZFEeVGcjeSiSHfMlRxJbyL5+xLGcvkNmD34wmIXo85n0va6b8cnqShmprdUKjvXyzE4dPPB9trRunaUY+mA==",
|
||||
"version": "2.3.6",
|
||||
"resolved": "https://registry.npmjs.org/@rsbuild/core/-/core-2.3.6.tgz",
|
||||
"integrity": "sha512-IVuWh/0DO6XT8075eCAzxWIcVGA7c4xKggf/VEePq3yXqEiU302n6OVGD7uCxQwPaB4R9ViX4cAqalcQV/sxKQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@rspack/core": "~2.3.5",
|
||||
"@rspack/core": "~2.3.4",
|
||||
"@swc/helpers": "^0.5.24"
|
||||
},
|
||||
"bin": {
|
||||
@@ -175,32 +172,32 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rspack/binding": {
|
||||
"version": "2.3.5",
|
||||
"resolved": "https://registry.npmjs.org/@rspack/binding/-/binding-2.3.5.tgz",
|
||||
"integrity": "sha512-W3x7zw5d/mIH9WhWt4pO9RKYURoqgdUxeLSV5IhDCajnhXdRr7R59u5S2j5ZXzSk3eMGUC0PenfKIIdW7t0ufQ==",
|
||||
"version": "2.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@rspack/binding/-/binding-2.3.4.tgz",
|
||||
"integrity": "sha512-wSOT16LVITL/IKeIiLXgN5Q5jZIDqnQ7Gmk+wzKOSZ6OHYNfEBXAKhSJuYtCBq8ovJuGl8cJjdqatAlHE5XKIA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optionalDependencies": {
|
||||
"@rspack/binding-darwin-arm64": "2.3.5",
|
||||
"@rspack/binding-darwin-x64": "2.3.5",
|
||||
"@rspack/binding-linux-arm64-gnu": "2.3.5",
|
||||
"@rspack/binding-linux-arm64-musl": "2.3.5",
|
||||
"@rspack/binding-linux-ppc64-gnu": "2.3.5",
|
||||
"@rspack/binding-linux-riscv64-gnu": "2.3.5",
|
||||
"@rspack/binding-linux-riscv64-musl": "2.3.5",
|
||||
"@rspack/binding-linux-s390x-gnu": "2.3.5",
|
||||
"@rspack/binding-linux-x64-gnu": "2.3.5",
|
||||
"@rspack/binding-linux-x64-musl": "2.3.5",
|
||||
"@rspack/binding-wasm32-wasi": "2.3.5",
|
||||
"@rspack/binding-win32-arm64-msvc": "2.3.5",
|
||||
"@rspack/binding-win32-ia32-msvc": "2.3.5",
|
||||
"@rspack/binding-win32-x64-msvc": "2.3.5"
|
||||
"@rspack/binding-darwin-arm64": "2.3.4",
|
||||
"@rspack/binding-darwin-x64": "2.3.4",
|
||||
"@rspack/binding-linux-arm64-gnu": "2.3.4",
|
||||
"@rspack/binding-linux-arm64-musl": "2.3.4",
|
||||
"@rspack/binding-linux-ppc64-gnu": "2.3.4",
|
||||
"@rspack/binding-linux-riscv64-gnu": "2.3.4",
|
||||
"@rspack/binding-linux-riscv64-musl": "2.3.4",
|
||||
"@rspack/binding-linux-s390x-gnu": "2.3.4",
|
||||
"@rspack/binding-linux-x64-gnu": "2.3.4",
|
||||
"@rspack/binding-linux-x64-musl": "2.3.4",
|
||||
"@rspack/binding-wasm32-wasi": "2.3.4",
|
||||
"@rspack/binding-win32-arm64-msvc": "2.3.4",
|
||||
"@rspack/binding-win32-ia32-msvc": "2.3.4",
|
||||
"@rspack/binding-win32-x64-msvc": "2.3.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@rspack/binding-darwin-arm64": {
|
||||
"version": "2.3.5",
|
||||
"resolved": "https://registry.npmjs.org/@rspack/binding-darwin-arm64/-/binding-darwin-arm64-2.3.5.tgz",
|
||||
"integrity": "sha512-A5XnBdSoJvcYV4t2Y+XJiCF0UZ42nOKE2D0ZlegfErGhzlQG1t3hDOzskSB2fPD3z+w5QeREoclqQ0zFOZyBpw==",
|
||||
"version": "2.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@rspack/binding-darwin-arm64/-/binding-darwin-arm64-2.3.4.tgz",
|
||||
"integrity": "sha512-eBD71fbmoJKnxcHD03bukbAIOP5r7nD0Ehs+mUrUQlZ6N53EhuJsTeJ1oYdg5L4GoSeQ+KecCqME81Nm0COLrA==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
@@ -212,9 +209,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@rspack/binding-darwin-x64": {
|
||||
"version": "2.3.5",
|
||||
"resolved": "https://registry.npmjs.org/@rspack/binding-darwin-x64/-/binding-darwin-x64-2.3.5.tgz",
|
||||
"integrity": "sha512-iZrweqTIj2cM4f0ADRj6FXn9a0FOpD1Mx/++zrsbrQzmnY0c8wmfpvZ5xA5Zfcq9O6nuUBS6GnhkmoFTgviHwQ==",
|
||||
"version": "2.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@rspack/binding-darwin-x64/-/binding-darwin-x64-2.3.4.tgz",
|
||||
"integrity": "sha512-CqdfzTLPVFQCniOy/GDVWbg+rqg31qfdzbFf8NYCzdDkCQg+p15hU2HsckD/1sLsaNB8Y55EjGz4ZyGDny0cHg==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
@@ -226,9 +223,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@rspack/binding-linux-arm64-gnu": {
|
||||
"version": "2.3.5",
|
||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-2.3.5.tgz",
|
||||
"integrity": "sha512-aWE9V0ZhmclKsJNuO37cxUMLtXMjhLtFzrWDWC82mksUX6qM2rzOpPuye9i/c9NGqyrIH7EFQre8bskJvNHGuQ==",
|
||||
"version": "2.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-2.3.4.tgz",
|
||||
"integrity": "sha512-T/Y1FYiSegcNc+oHuDOLRGIcc+eSdBnfbS70d51EWQj4+0TG/tlfuqFKeAIL3mnKUV5lDLaTz3vsoD0Sws5Fxw==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
@@ -243,9 +240,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@rspack/binding-linux-arm64-musl": {
|
||||
"version": "2.3.5",
|
||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-arm64-musl/-/binding-linux-arm64-musl-2.3.5.tgz",
|
||||
"integrity": "sha512-I8ENTXdv7Th/OHEYhL7uu3B7DA9r1oTWSifkGHJtuT1XJ0KDsxoA6ORpYz1R2qIs87l+8+5QUnRH7iWyZrnroA==",
|
||||
"version": "2.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-arm64-musl/-/binding-linux-arm64-musl-2.3.4.tgz",
|
||||
"integrity": "sha512-WZHCzZ532UfXFXNU8XyM8jb+I6wddegbs/7IXsyw7xiPwwZX1D/M6iKFVpBYdvKcupUM8bS8Uw2REirR/cERVw==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
@@ -260,9 +257,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@rspack/binding-linux-ppc64-gnu": {
|
||||
"version": "2.3.5",
|
||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-2.3.5.tgz",
|
||||
"integrity": "sha512-ps5do0cKf4aTBWd+LHqvwm8Gdn7J/gvzmx9pWJhAIThvzii45wJREFjGOzJNxdQl+pzKq8JFuzbShNskCN9k2w==",
|
||||
"version": "2.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-2.3.4.tgz",
|
||||
"integrity": "sha512-WeizqeI6HIh7Ax9w2tlmpTtipJWxXcdgt3QqI3N9LOixymlMD5yMBMZNPqwZ6cHXT9gOQ69SvPcVgMwxsdmceQ==",
|
||||
"cpu": [
|
||||
"ppc64"
|
||||
],
|
||||
@@ -277,9 +274,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@rspack/binding-linux-riscv64-gnu": {
|
||||
"version": "2.3.5",
|
||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-riscv64-gnu/-/binding-linux-riscv64-gnu-2.3.5.tgz",
|
||||
"integrity": "sha512-3XXIEMS4SSr1/9wIAGgPT1oj1SzhnlejAG5xeVbGJR5y6iFp/oFKYzUPqyuuzZCkWph2/hJ+Q16sa+BJn1YIkg==",
|
||||
"version": "2.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-riscv64-gnu/-/binding-linux-riscv64-gnu-2.3.4.tgz",
|
||||
"integrity": "sha512-h+001Vbq8LyGwPMNkeRWidPOVKwlAbwNPskY3CjNlSw3euHkVchfhM3uo6+1h0GyTtb3rzsWqsfm1kar7m/tiQ==",
|
||||
"cpu": [
|
||||
"riscv64"
|
||||
],
|
||||
@@ -294,9 +291,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@rspack/binding-linux-riscv64-musl": {
|
||||
"version": "2.3.5",
|
||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-riscv64-musl/-/binding-linux-riscv64-musl-2.3.5.tgz",
|
||||
"integrity": "sha512-z2DbQNcLbUEY9OvUa3gahsHey+dW4acLc9d3QlyJm7TJE//rL9C/XBk4kETvCgtdhqrwBSfWrZfislBPKODjvA==",
|
||||
"version": "2.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-riscv64-musl/-/binding-linux-riscv64-musl-2.3.4.tgz",
|
||||
"integrity": "sha512-S1rlaCnNVG5s4WZ9odLsqN3ySh5TEdNTLXWapEK8x3iQl56aLtdvqXTfbJWHWnYLJuS7M1WqnQGdJNdjy2NDsA==",
|
||||
"cpu": [
|
||||
"riscv64"
|
||||
],
|
||||
@@ -311,9 +308,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@rspack/binding-linux-s390x-gnu": {
|
||||
"version": "2.3.5",
|
||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-2.3.5.tgz",
|
||||
"integrity": "sha512-n2UudDpzt9G2AOmycVS7uWRMcNMd2k4ubU4b4SX3FfU/uT6mfSNzuwhBhCi0RSZQAGBU0ombJ+sqw8vKXjGGbw==",
|
||||
"version": "2.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-2.3.4.tgz",
|
||||
"integrity": "sha512-0SkgGrgulVMam3xel5dMNKQ+U7BEpCczhF1avGT1DzDVIbMfIOsbb32gApQNSz0E7RfAQ/Pa5eWiA9oyRq7ZMQ==",
|
||||
"cpu": [
|
||||
"s390x"
|
||||
],
|
||||
@@ -328,9 +325,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@rspack/binding-linux-x64-gnu": {
|
||||
"version": "2.3.5",
|
||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-x64-gnu/-/binding-linux-x64-gnu-2.3.5.tgz",
|
||||
"integrity": "sha512-1sxASGJXg9luaYsFSmAQxSFbUbnMnPA5Mr94yIlLsq4q94sHUIn5YjG1XGcT+cPhUYF9fHkCsKRmQlzrN9fR8A==",
|
||||
"version": "2.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-x64-gnu/-/binding-linux-x64-gnu-2.3.4.tgz",
|
||||
"integrity": "sha512-q7E6x3rJJ/9fJyLuRe5+KyEPi23BF/xkAU4xCM5VwLkTf+rVyOkDZfu0qOkxmILjrxllQPV+b/ojBL/ZaIeQPw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
@@ -345,9 +342,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@rspack/binding-linux-x64-musl": {
|
||||
"version": "2.3.5",
|
||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-x64-musl/-/binding-linux-x64-musl-2.3.5.tgz",
|
||||
"integrity": "sha512-/S4pe1wAo8CBTs0X8DNKu1ZOJ2vQcnThLBKS2CxOPiuQXI7UfAsJCEABBoa8yCrZANWh63fJ90UwLb/s245Gsw==",
|
||||
"version": "2.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-x64-musl/-/binding-linux-x64-musl-2.3.4.tgz",
|
||||
"integrity": "sha512-rey4Tyasui/WeMn6KfhH5xyZGOMt+Ny+GDK7nGh9TSz/cb3/bisxqGzpbu6GJK8leDmTUDD5ZdpODexytA5rzQ==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
@@ -362,9 +359,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@rspack/binding-wasm32-wasi": {
|
||||
"version": "2.3.5",
|
||||
"resolved": "https://registry.npmjs.org/@rspack/binding-wasm32-wasi/-/binding-wasm32-wasi-2.3.5.tgz",
|
||||
"integrity": "sha512-GQnswrv6AyBdDCcTy8dTVhD0JqnvmgewzPz6qnOYWGKxpCY99Bv6FL4jvxI1yh64Uk3ykEfbwhrPnaA8Px4KJA==",
|
||||
"version": "2.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@rspack/binding-wasm32-wasi/-/binding-wasm32-wasi-2.3.4.tgz",
|
||||
"integrity": "sha512-sDt2MSXZrIaMBa6UaEqmXEqebwpTOPAXLdo9CYJ2Fa9FJWP4TCYbn30mbvV38ZC2n5YX411DRbjck+s97CceIg==",
|
||||
"cpu": [
|
||||
"wasm32"
|
||||
],
|
||||
@@ -372,49 +369,15 @@
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"@emnapi/core": "2.0.0-beta.4",
|
||||
"@emnapi/runtime": "2.0.0-beta.4",
|
||||
"@emnapi/core": "2.0.0-beta.3",
|
||||
"@emnapi/runtime": "2.0.0-beta.3",
|
||||
"@napi-rs/wasm-runtime": "1.2.7"
|
||||
}
|
||||
},
|
||||
"node_modules/@rspack/binding-wasm32-wasi/node_modules/@emnapi/core": {
|
||||
"version": "2.0.0-beta.4",
|
||||
"resolved": "https://registry.npmjs.org/@emnapi/core/-/core-2.0.0-beta.4.tgz",
|
||||
"integrity": "sha512-AhU/vMMXtGgLCrWsL3PjZGSpCWXlGETabnyyB2pBUd6h7AMy2toffJO2T7yXOYXtw8FyD6dYK/5b3u5eRK3yhw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"@emnapi/wasi-threads": "2.2.0",
|
||||
"tslib": "^2.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@rspack/binding-wasm32-wasi/node_modules/@emnapi/runtime": {
|
||||
"version": "2.0.0-beta.4",
|
||||
"resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-2.0.0-beta.4.tgz",
|
||||
"integrity": "sha512-UKxc3beuftD67T1mPCVf0mnwRKOBsq9XrhLCDGGQKsbG9jx6osvGyjIbJm9DsucyUtFSMTV2ZxsjiuTMjEqWkA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"tslib": "^2.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@rspack/binding-wasm32-wasi/node_modules/@emnapi/wasi-threads": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-2.2.0.tgz",
|
||||
"integrity": "sha512-JP7OYH38Q7+pyTAe14raZHLQIK7BDKbdwji+Xi3pcd/6QkJYQH3SX4wu6EplGrGJWRepoNzedfm0G3B9Z4e9Rw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"tslib": "^2.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@rspack/binding-win32-arm64-msvc": {
|
||||
"version": "2.3.5",
|
||||
"resolved": "https://registry.npmjs.org/@rspack/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-2.3.5.tgz",
|
||||
"integrity": "sha512-XVKu3Zs5KGr+P5Seh6NtSNU0UQ1GSgSDFANQRZlT1uFZ1NpBCX+9NB8FVZB0hBBoBKI1kU4b0Cr6Df1Xx0K4nQ==",
|
||||
"version": "2.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@rspack/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-2.3.4.tgz",
|
||||
"integrity": "sha512-24YC1YSodLAJ8VsMQJmJSHCNvHTqK9JP5hj50T50WE8lCHNsNl/rIYXO9V0VlCYT/HshE6EHHzAeKdahiEOtcw==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
@@ -426,9 +389,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@rspack/binding-win32-ia32-msvc": {
|
||||
"version": "2.3.5",
|
||||
"resolved": "https://registry.npmjs.org/@rspack/binding-win32-ia32-msvc/-/binding-win32-ia32-msvc-2.3.5.tgz",
|
||||
"integrity": "sha512-ejCqSuctPcOev2dyi0ayZyfIUY3fJdYHYvrTfSVrrGC19TspuRATXu+RLyu3xvB6TrQF3+JEF4KeG4/ZeWuXOg==",
|
||||
"version": "2.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@rspack/binding-win32-ia32-msvc/-/binding-win32-ia32-msvc-2.3.4.tgz",
|
||||
"integrity": "sha512-xmUNu6kgV9lLEkRP1Zb+t6i1Z1ZMEWXmLlMalPx8tHqndz2RflNMBBx6kjB2nAPQBIZgWufwm7dVGS0HKomCmw==",
|
||||
"cpu": [
|
||||
"ia32"
|
||||
],
|
||||
@@ -440,9 +403,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@rspack/binding-win32-x64-msvc": {
|
||||
"version": "2.3.5",
|
||||
"resolved": "https://registry.npmjs.org/@rspack/binding-win32-x64-msvc/-/binding-win32-x64-msvc-2.3.5.tgz",
|
||||
"integrity": "sha512-IPvkjM3xAwL1z2N4Jp/GBcZUme703uDy5vrP1IMtXJEl/EOLLfwl7cRb4sSzdeOYGDDHs5dPYDcpgP5eRSRauA==",
|
||||
"version": "2.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@rspack/binding-win32-x64-msvc/-/binding-win32-x64-msvc-2.3.4.tgz",
|
||||
"integrity": "sha512-WY+AkJqpbLtLEZiG1fE7CVJZ54y0qHeCiVmLxGBsh4OOGIDCs6v2Ub5COcPrYVzGJFGyeHUS29dV7JAs93qIHw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
@@ -454,13 +417,13 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@rspack/core": {
|
||||
"version": "2.3.5",
|
||||
"resolved": "https://registry.npmjs.org/@rspack/core/-/core-2.3.5.tgz",
|
||||
"integrity": "sha512-4TG6zGTemEU/FU7bymDgeFOO7CRdd7ucn0CmXo+3cG6EhYmY5+hpAFYBRgxDbDuL4Bwo/s5GsgUvZuI7rLqVbQ==",
|
||||
"version": "2.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@rspack/core/-/core-2.3.4.tgz",
|
||||
"integrity": "sha512-T8HGkIjPVDlGlIN8st/ICe8Gfixq8te75g/8crSdNSf8F+6884sBcKNky0CRdfPxao1C5SXV+Vjv1XJTjyu83w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@rspack/binding": "2.3.5"
|
||||
"@rspack/binding": "2.3.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^20.19.0 || >=22.12.0"
|
||||
@@ -495,22 +458,22 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rspress/core": {
|
||||
"version": "2.1.6",
|
||||
"resolved": "https://registry.npmjs.org/@rspress/core/-/core-2.1.6.tgz",
|
||||
"integrity": "sha512-a+CBJcslana9Zmr6j2o3RP6O19y+rcyfa8jeDToC1b29e/RGiD+xpAQJF2eBvnjNUHouXARTaFa7pE1myyV0Rg==",
|
||||
"version": "2.1.5",
|
||||
"resolved": "https://registry.npmjs.org/@rspress/core/-/core-2.1.5.tgz",
|
||||
"integrity": "sha512-kzTqrfJ4UiW+RLLHLunoW/rET5Vjb6Qz4YjhEhiWEp4HYM+KxLVhfyYB5aL8af9+mdnwiTaqlu1s+BZGrMD2zw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@mdx-js/mdx": "^3.1.1",
|
||||
"@mdx-js/react": "^3.1.1",
|
||||
"@rsbuild/core": "^2.3.7",
|
||||
"@rsbuild/core": "^2.3.3",
|
||||
"@rsbuild/plugin-react": "~2.1.1",
|
||||
"@rspress/shared": "2.1.6",
|
||||
"@rspress/shared": "2.1.5",
|
||||
"@shikijs/rehype": "^4.2.0",
|
||||
"@shikijs/transformers": "^4.2.0",
|
||||
"@types/mdast": "^4.0.4",
|
||||
"@types/react": "^19.3.3",
|
||||
"@unhead/react": "^2.1.19",
|
||||
"@types/react": "^19.3.0",
|
||||
"@unhead/react": "^2.1.18",
|
||||
"body-scroll-lock": "4.0.0-beta.0",
|
||||
"clsx": "2.1.1",
|
||||
"copy-to-clipboard": "^3.3.3",
|
||||
@@ -527,7 +490,7 @@
|
||||
"react-dom": "^19.3.1",
|
||||
"react-lazy-with-preload": "^2.2.1",
|
||||
"react-render-to-markdown": "19.2.0",
|
||||
"react-router-dom": "^7.18.7",
|
||||
"react-router-dom": "^7.18.6",
|
||||
"rehype-external-links": "^3.0.0",
|
||||
"rehype-raw": "^7.0.0",
|
||||
"remark-cjk-friendly": "^2.3.4",
|
||||
@@ -551,9 +514,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rspress/plugin-client-redirects": {
|
||||
"version": "2.1.6",
|
||||
"resolved": "https://registry.npmjs.org/@rspress/plugin-client-redirects/-/plugin-client-redirects-2.1.6.tgz",
|
||||
"integrity": "sha512-lnSIA3oD44PZa0o0r4gvTBBGWeImD3T7D28FRJlzCdrWQX3kOHpyhxd9fCcK9mE32DYItlu/ipsmpSozmDN9ZA==",
|
||||
"version": "2.1.5",
|
||||
"resolved": "https://registry.npmjs.org/@rspress/plugin-client-redirects/-/plugin-client-redirects-2.1.5.tgz",
|
||||
"integrity": "sha512-vqAi7ynOgVsuwJi7cXwWEF5UgoNhXqGOyBfQubeZHZKWRtdNHRU42P9rG9DZLTss2dZUiDKlVrM2/vNY40t5hw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -564,15 +527,15 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rspress/shared": {
|
||||
"version": "2.1.6",
|
||||
"resolved": "https://registry.npmjs.org/@rspress/shared/-/shared-2.1.6.tgz",
|
||||
"integrity": "sha512-ecHmNItlMsMU5FEf0CeBKZa4XNCE5fpwCED+1/lmcwIhozyBvd4j4Ook/8IyTT3UqgruJDZ2DwQqfyvCW7zmLg==",
|
||||
"version": "2.1.5",
|
||||
"resolved": "https://registry.npmjs.org/@rspress/shared/-/shared-2.1.5.tgz",
|
||||
"integrity": "sha512-XXxegxRZ7VPADS2veN9FTNmmLlA65ieydKH0tOhOZbMJC4OJpKbr/d/JS2jxxAO4u+ZmZxbDyEEir83NQHLKIw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@rsbuild/core": "^2.3.7",
|
||||
"@rsbuild/core": "^2.3.3",
|
||||
"@shikijs/rehype": "^4.2.0",
|
||||
"@types/react": "^19.3.3",
|
||||
"@types/react": "^19.3.0",
|
||||
"mdast-util-mdx-jsx": "^3.2.2",
|
||||
"unified": "^11.0.5"
|
||||
}
|
||||
|
||||
@@ -21,6 +21,9 @@ brotli_compression = [
|
||||
"conduwuit-service/brotli_compression",
|
||||
"reqwest/brotli",
|
||||
]
|
||||
element_hacks = [
|
||||
"conduwuit-service/element_hacks",
|
||||
]
|
||||
gzip_compression = [
|
||||
"conduwuit-core/gzip_compression",
|
||||
"conduwuit-service/gzip_compression",
|
||||
|
||||
+27
-52
@@ -44,7 +44,10 @@ use ruma::{
|
||||
to_device::DeviceIdOrAllDevices,
|
||||
};
|
||||
use service::{
|
||||
rooms::event_handler::{DagBuilderTree, build_local_dag},
|
||||
rooms::{
|
||||
event_handler::{DagBuilderTree, build_local_dag},
|
||||
queue::QueueJob,
|
||||
},
|
||||
transactions::{FederationTxnState, TransactionError, TxnKey, WrappedTransactionResponse},
|
||||
};
|
||||
use tokio::sync::watch::{Receiver, Sender};
|
||||
@@ -332,14 +335,6 @@ async fn handle_room(
|
||||
room_id: OwnedRoomId,
|
||||
pdus: impl Iterator<Item = Pdu> + Send,
|
||||
) -> std::result::Result<Vec<(OwnedEventId, Result)>, TransactionError> {
|
||||
let arrived = millis_since_unix_epoch();
|
||||
let _room_lock = services
|
||||
.rooms
|
||||
.event_handler
|
||||
.mutex_federation
|
||||
.lock(room_id.as_str())
|
||||
.await;
|
||||
|
||||
let room_id = &room_id;
|
||||
let mut pdu_map: HashMap<OwnedEventId, CanonicalJsonObject> = pdus
|
||||
.into_iter()
|
||||
@@ -359,50 +354,30 @@ async fn handle_room(
|
||||
let value = pdu_map
|
||||
.remove(&event_id)
|
||||
.expect("sorted event IDs must be from the original map");
|
||||
services
|
||||
.server
|
||||
.check_running()
|
||||
.map_err(|_| TransactionError::ShuttingDown)?;
|
||||
let event_type = KeyValue::new(
|
||||
"type",
|
||||
pdu_type_label(value.get("type").and_then(CanonicalJsonValue::as_str)),
|
||||
);
|
||||
let origin_server_ts = value
|
||||
.get("origin_server_ts")
|
||||
.and_then(CanonicalJsonValue::as_integer)
|
||||
.and_then(|ts| u64::try_from(i64::from(ts)).ok());
|
||||
let room_id = match value
|
||||
.get("room_id")
|
||||
.and_then(CanonicalJsonValue::as_str)
|
||||
.map(|v| v.try_into().map_err(Into::into))
|
||||
{
|
||||
| Some(Ok(v)) => v,
|
||||
| Some(Err(e)) => {
|
||||
results.push((event_id, Err(e)));
|
||||
continue;
|
||||
},
|
||||
| None => {
|
||||
results
|
||||
.push((event_id, Err!(Request(BadJson("PDU is missing a room_id field")))));
|
||||
continue;
|
||||
},
|
||||
};
|
||||
let job = QueueJob {
|
||||
room_id,
|
||||
event_id: event_id.clone(),
|
||||
origin: origin.to_owned(),
|
||||
object: value,
|
||||
};
|
||||
|
||||
let start = Instant::now();
|
||||
let result = services
|
||||
.rooms
|
||||
.event_handler
|
||||
.handle_incoming_pdu(origin, room_id, &event_id, value, false)
|
||||
.boxed()
|
||||
.await
|
||||
.map(|_| ());
|
||||
|
||||
let outcome = KeyValue::new("outcome", match &result {
|
||||
| Ok(()) => "accepted",
|
||||
| Err(Error::BadRequest(ErrorKind::Forbidden, ..)) => "forbidden",
|
||||
| Err(Error::BadRequest(ErrorKind::InvalidParam | ErrorKind::BadJson, ..)) =>
|
||||
"invalid",
|
||||
| Err(_) => "error",
|
||||
});
|
||||
let instruments = &services.server.metrics.instruments;
|
||||
instruments
|
||||
.federation_incoming_pdu_duration
|
||||
.record(start.elapsed().as_secs_f64(), std::slice::from_ref(&outcome));
|
||||
if let (Ok(()), Some(ts)) = (&result, origin_server_ts) {
|
||||
let lag = arrived.saturating_sub(ts);
|
||||
instruments
|
||||
.federation_incoming_pdu_lag
|
||||
.record(Duration::from_millis(lag).as_secs_f64(), &[]);
|
||||
}
|
||||
instruments
|
||||
.federation_incoming_pdus
|
||||
.add(1, &[event_type, outcome]);
|
||||
|
||||
results.push((event_id, result));
|
||||
results.push((event_id, services.rooms.queue.new_job(job).await));
|
||||
}
|
||||
Ok(results)
|
||||
}
|
||||
|
||||
+1
-1
@@ -117,7 +117,7 @@ prometheus.workspace = true
|
||||
lock_api.workspace = true
|
||||
hyper-util.workspace = true
|
||||
resolvematrix.workspace = true
|
||||
openid.workspace = true
|
||||
openidconnect.workspace = true
|
||||
libmimalloc-sys.optional = true
|
||||
libmimalloc-sys.workspace = true
|
||||
mimalloc.optional = true
|
||||
|
||||
@@ -146,19 +146,6 @@ pub struct Experiments {
|
||||
/// default: false
|
||||
#[serde(default)]
|
||||
pub msc4560: SimpleExperiment,
|
||||
|
||||
/// MSC4563: `direct_message` push rule
|
||||
///
|
||||
/// Creates a new kind of push rule that creates a notification if a message
|
||||
/// is received in a room that is in the user's direct message list. This
|
||||
/// more accurately identifies direct messages, rather than relying on a "DM
|
||||
/// room" only consisting of two members.
|
||||
///
|
||||
/// https://github.com/matrix-org/matrix-spec-proposals/pull/4563
|
||||
///
|
||||
/// default: false
|
||||
#[serde(default)]
|
||||
pub msc4563: SimpleExperiment,
|
||||
}
|
||||
|
||||
/// Represents a "simple" experiment, which is either disabled or enabled.
|
||||
|
||||
+18
-5
@@ -23,6 +23,7 @@ use figment::providers::{Env, Format, Toml};
|
||||
pub use figment::{Figment, value::Value as FigmentValue};
|
||||
use governor::{DefaultKeyedRateLimiter, Quota, RateLimiter};
|
||||
use lettre::message::Mailbox;
|
||||
use openidconnect::{Audience, ClientId, ClientSecret, Scope};
|
||||
use regex::RegexSet;
|
||||
use ruma::{
|
||||
OwnedRoomId, OwnedRoomOrAliasId, OwnedServerName, OwnedServerSigningKeyId, OwnedUserId,
|
||||
@@ -2801,15 +2802,15 @@ pub struct OidcConfig {
|
||||
/// automatically fetch the identity provider's metadata from this URL.
|
||||
/// Generally you should set this to the base domain your identity provider
|
||||
/// runs on.
|
||||
pub discovery_url: Url,
|
||||
pub discovery_url: String,
|
||||
|
||||
/// The OAuth client ID for Continuwuity to use when communicating with the
|
||||
/// identity provider.
|
||||
pub client_id: String,
|
||||
pub client_id: ClientId,
|
||||
|
||||
/// The OAuth client secret for Continuwuity to use when communicating with
|
||||
/// the identity provider.
|
||||
pub client_secret: Option<String>,
|
||||
pub client_secret: Option<ClientSecret>,
|
||||
|
||||
/// A path to a file which Continuwuity will read the client secret from.
|
||||
/// If this option is set, it will override `client_secret`.
|
||||
@@ -2825,7 +2826,19 @@ pub struct OidcConfig {
|
||||
///
|
||||
/// default: ["profile"]
|
||||
#[serde(default = "default_additional_scopes")]
|
||||
pub additional_scopes: Vec<String>,
|
||||
pub additional_scopes: Vec<Scope>,
|
||||
|
||||
/// Additional trusted audiences that Continuwuity will accept in the `aud`
|
||||
/// claim of the OIDC token returned by the IDP. If your identity
|
||||
/// provider includes other values in the `aud` claim in addition to the
|
||||
/// client ID, they must be listed here for Continuwuity to accept them.
|
||||
///
|
||||
/// Most deployments will not need to set this, because most identity
|
||||
/// providers only include the client ID in the `aud` claim by default.
|
||||
///
|
||||
/// default: []
|
||||
#[serde(default)]
|
||||
pub additional_trusted_audiences: BTreeSet<Audience>,
|
||||
|
||||
/// The name of the identity provider. If this is set, the login page's
|
||||
/// button reads "Continue with <name>" instead of just "Continue".
|
||||
@@ -3431,7 +3444,7 @@ fn default_unauthenticated_request_ratelimit<K: Hash + Eq + Clone>() -> PerMinut
|
||||
PerMinuteRatelimiter::new(Quota::per_minute(30.try_into().unwrap()))
|
||||
}
|
||||
|
||||
fn default_additional_scopes() -> Vec<String> { vec!["profile".to_owned()] }
|
||||
fn default_additional_scopes() -> Vec<Scope> { vec![Scope::new("profile".to_owned())] }
|
||||
|
||||
// NOTE: This must be declared *after* every config struct in this file. The
|
||||
// example config generator writes sections in macro expansion order, and the
|
||||
|
||||
@@ -395,6 +395,10 @@ pub(super) static MAPS: &[Descriptor] = &[
|
||||
block_size: 512,
|
||||
..descriptor::RANDOM
|
||||
},
|
||||
Descriptor {
|
||||
name: "txn_jobid_job",
|
||||
..descriptor::RANDOM
|
||||
},
|
||||
Descriptor {
|
||||
name: "url_previews",
|
||||
..descriptor::RANDOM
|
||||
|
||||
@@ -55,6 +55,7 @@ default = [
|
||||
standard = [
|
||||
"brotli_compression",
|
||||
"direct_tls",
|
||||
"element_hacks",
|
||||
"gzip_compression",
|
||||
"io_uring",
|
||||
"jemalloc_conf",
|
||||
@@ -85,6 +86,10 @@ console = [
|
||||
direct_tls = [
|
||||
"conduwuit-router/direct_tls"
|
||||
]
|
||||
element_hacks = [
|
||||
"conduwuit-service/element_hacks",
|
||||
"conduwuit-router/element_hacks",
|
||||
]
|
||||
gzip_compression = [
|
||||
"conduwuit-core/gzip_compression",
|
||||
"conduwuit-router/gzip_compression",
|
||||
|
||||
@@ -27,6 +27,9 @@ direct_tls = [
|
||||
"axum-server/tls-rustls-no-provider",
|
||||
"dep:axum-server-dual-protocol",
|
||||
]
|
||||
element_hacks = [
|
||||
"conduwuit-api/element_hacks",
|
||||
]
|
||||
gzip_compression = [
|
||||
"conduwuit-admin/gzip_compression",
|
||||
"conduwuit-api/gzip_compression",
|
||||
|
||||
+39
-30
@@ -11,8 +11,8 @@ version.workspace = true
|
||||
[lib]
|
||||
path = "mod.rs"
|
||||
crate-type = [
|
||||
"rlib",
|
||||
# "dylib",
|
||||
"rlib",
|
||||
# "dylib",
|
||||
]
|
||||
|
||||
[features]
|
||||
@@ -23,60 +23,61 @@ bindgen-static = [
|
||||
"conduwuit-database/bindgen-static"
|
||||
]
|
||||
brotli_compression = [
|
||||
"conduwuit-core/brotli_compression",
|
||||
"reqwest/brotli",
|
||||
"conduwuit-core/brotli_compression",
|
||||
"reqwest/brotli",
|
||||
]
|
||||
console = [
|
||||
"dep:rustyline-async",
|
||||
"dep:termimad",
|
||||
"dep:rustyline-async",
|
||||
"dep:termimad",
|
||||
]
|
||||
element_hacks = []
|
||||
gzip_compression = [
|
||||
"conduwuit-core/gzip_compression",
|
||||
"reqwest/gzip",
|
||||
"conduwuit-core/gzip_compression",
|
||||
"reqwest/gzip",
|
||||
]
|
||||
http3 = [
|
||||
"reqwest/http3"
|
||||
]
|
||||
io_uring = [
|
||||
"conduwuit-database/io_uring",
|
||||
"conduwuit-database/io_uring",
|
||||
]
|
||||
jemalloc = [
|
||||
"conduwuit-core/jemalloc",
|
||||
"conduwuit-database/jemalloc",
|
||||
"conduwuit-core/jemalloc",
|
||||
"conduwuit-database/jemalloc",
|
||||
]
|
||||
jemalloc_conf = [
|
||||
"conduwuit-core/jemalloc_conf",
|
||||
"conduwuit-database/jemalloc_conf",
|
||||
"conduwuit-core/jemalloc_conf",
|
||||
"conduwuit-database/jemalloc_conf",
|
||||
]
|
||||
jemalloc_prof = [
|
||||
"conduwuit-core/jemalloc_prof",
|
||||
"conduwuit-database/jemalloc_prof",
|
||||
"conduwuit-core/jemalloc_prof",
|
||||
"conduwuit-database/jemalloc_prof",
|
||||
]
|
||||
jemalloc_stats = [
|
||||
"conduwuit-core/jemalloc_stats",
|
||||
"conduwuit-database/jemalloc_stats",
|
||||
"conduwuit-core/jemalloc_stats",
|
||||
"conduwuit-database/jemalloc_stats",
|
||||
]
|
||||
media_thumbnail = [
|
||||
"dep:image",
|
||||
"dep:image",
|
||||
]
|
||||
release_max_log_level = [
|
||||
"conduwuit-core/release_max_log_level",
|
||||
"conduwuit-database/release_max_log_level",
|
||||
"log/max_level_trace",
|
||||
"log/release_max_level_info",
|
||||
"tracing/max_level_trace",
|
||||
"tracing/release_max_level_info",
|
||||
"conduwuit-core/release_max_log_level",
|
||||
"conduwuit-database/release_max_log_level",
|
||||
"log/max_level_trace",
|
||||
"log/release_max_level_info",
|
||||
"tracing/max_level_trace",
|
||||
"tracing/release_max_level_info",
|
||||
]
|
||||
systemd = [
|
||||
"dep:sd-notify",
|
||||
"dep:sd-notify",
|
||||
]
|
||||
url_preview = [
|
||||
"dep:image",
|
||||
"dep:webpage",
|
||||
"dep:image",
|
||||
"dep:webpage",
|
||||
]
|
||||
zstd_compression = [
|
||||
"conduwuit-core/zstd_compression",
|
||||
"conduwuit-database/zstd_compression",
|
||||
"conduwuit-core/zstd_compression",
|
||||
"conduwuit-database/zstd_compression",
|
||||
"reqwest/zstd",
|
||||
]
|
||||
|
||||
@@ -121,6 +122,7 @@ sha2.workspace = true
|
||||
termimad.workspace = true
|
||||
termimad.optional = true
|
||||
tokio.workspace = true
|
||||
tokio-stream.workspace = true
|
||||
tracing.workspace = true
|
||||
url.workspace = true
|
||||
web-push-native.workspace = true
|
||||
@@ -130,8 +132,12 @@ yansi.workspace = true
|
||||
lettre.workspace = true
|
||||
resolvematrix.workspace = true
|
||||
serde_urlencoded.workspace = true
|
||||
openid.workspace = true
|
||||
openidconnect.workspace = true
|
||||
# We use this to set TLS backend features on the outdated reqwest bundled by openidconnect,
|
||||
# which is necessary to call `danger_accept_invalid_certs`.
|
||||
reqwest_0_12.workspace = true
|
||||
rand.workspace = true
|
||||
opentelemetry.workspace = true
|
||||
|
||||
[target.'cfg(all(unix, target_os = "linux"))'.dependencies]
|
||||
sd-notify.workspace = true
|
||||
@@ -140,6 +146,9 @@ sd-notify.optional = true
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[package.metadata.cargo-shear]
|
||||
ignored = ["reqwest_0_12"]
|
||||
|
||||
[dev-dependencies]
|
||||
opentelemetry.workspace = true
|
||||
rustls = { workspace = true, features = ["ring"] }
|
||||
@@ -44,3 +44,18 @@ impl reqwest::dns::Resolve for DnsResolver {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// openidconnect is weird and vendors reqwest (?), therefore we have to
|
||||
// completely re-implement Resolve with different types
|
||||
impl openidconnect::reqwest::dns::Resolve for DnsResolver {
|
||||
fn resolve(&self, name: openidconnect::reqwest::dns::Name) -> Resolving {
|
||||
let resolver = self.resolver.clone();
|
||||
Box::pin(async move {
|
||||
let lookup = resolver.lookup_ip(name.as_str()).await?;
|
||||
let addrs: Addrs = Box::new(SocketAddrs {
|
||||
iter: lookup.iter().collect::<Vec<_>>().into_iter(),
|
||||
});
|
||||
Ok(addrs)
|
||||
})
|
||||
}
|
||||
}
|
||||
+169
-159
@@ -1,19 +1,26 @@
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
net::IpAddr,
|
||||
str::FromStr,
|
||||
sync::Arc,
|
||||
};
|
||||
use std::{collections::HashMap, net::IpAddr, str::FromStr, sync::Arc, time::Duration};
|
||||
|
||||
use async_trait::async_trait;
|
||||
use conduwuit::{
|
||||
Result, SyncRwLock,
|
||||
config::{OidcConfig, OidcProfileKeyImportMode},
|
||||
debug, err, error, info, utils, warn,
|
||||
debug, err, error, info, warn,
|
||||
};
|
||||
use database::{Deserialized, Map};
|
||||
use lettre::Address;
|
||||
use openid::{Claims as _, Options, StandardClaims, Token};
|
||||
use openidconnect::{
|
||||
AdditionalClaims, AuthorizationCode, ClaimsVerificationError, ClientSecret, CsrfToken,
|
||||
EmptyExtraTokenFields, EndpointMaybeSet, EndpointNotSet, EndpointSet, IdTokenClaims,
|
||||
IdTokenFields, IssuerUrl, Nonce, PkceCodeChallenge, PkceCodeVerifier, RedirectUrl,
|
||||
SignatureVerificationError, StandardErrorResponse, StandardTokenResponse, TokenResponse,
|
||||
core::{
|
||||
CoreAuthDisplay, CoreAuthPrompt, CoreAuthenticationFlow, CoreErrorResponseType,
|
||||
CoreGenderClaim, CoreJsonWebKey, CoreJweContentEncryptionAlgorithm,
|
||||
CoreJwsSigningAlgorithm, CoreProviderMetadata, CoreRevocableToken,
|
||||
CoreRevocationErrorResponse, CoreTokenIntrospectionResponse, CoreTokenType,
|
||||
},
|
||||
reqwest,
|
||||
};
|
||||
use ruma::{
|
||||
OwnedUserId, UserId,
|
||||
api::client::profile::PropagateTo,
|
||||
@@ -43,7 +50,6 @@ struct Data {
|
||||
openidsubjectprofilefield_url: Arc<Map>,
|
||||
}
|
||||
struct Services {
|
||||
client: Dep<client::Service>,
|
||||
config: Dep<config::Service>,
|
||||
globals: Dep<globals::Service>,
|
||||
media: Dep<media::Service>,
|
||||
@@ -52,61 +58,56 @@ struct Services {
|
||||
}
|
||||
|
||||
struct OidcClient {
|
||||
client_secret: String,
|
||||
config: OidcConfig,
|
||||
client: SetOnce<SyncRwLock<Arc<IdpClient>>>,
|
||||
client_secret: ClientSecret,
|
||||
machine: SetOnce<SyncRwLock<Arc<OidcClientMachine>>>,
|
||||
client: reqwest::Client,
|
||||
}
|
||||
|
||||
type IdpClient = openid::Client<openid::Discovered, Claims>;
|
||||
type OidcClientMachine = openidconnect::Client<
|
||||
AllClaims,
|
||||
CoreAuthDisplay,
|
||||
CoreGenderClaim,
|
||||
CoreJweContentEncryptionAlgorithm,
|
||||
CoreJsonWebKey,
|
||||
CoreAuthPrompt,
|
||||
StandardErrorResponse<CoreErrorResponseType>,
|
||||
StandardTokenResponse<
|
||||
IdTokenFields<
|
||||
AllClaims,
|
||||
EmptyExtraTokenFields,
|
||||
CoreGenderClaim,
|
||||
CoreJweContentEncryptionAlgorithm,
|
||||
CoreJwsSigningAlgorithm,
|
||||
>,
|
||||
CoreTokenType,
|
||||
>,
|
||||
CoreTokenIntrospectionResponse,
|
||||
CoreRevocableToken,
|
||||
CoreRevocationErrorResponse,
|
||||
EndpointSet,
|
||||
EndpointNotSet,
|
||||
EndpointNotSet,
|
||||
EndpointNotSet,
|
||||
EndpointMaybeSet,
|
||||
EndpointMaybeSet,
|
||||
>;
|
||||
|
||||
pub type Claims = IdTokenClaims<AllClaims, CoreGenderClaim>;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct Claims {
|
||||
pub struct AllClaims {
|
||||
#[serde(flatten)]
|
||||
standard_claims: StandardClaims,
|
||||
|
||||
#[serde(flatten)]
|
||||
other_claims: HashMap<String, Value>,
|
||||
pub claims: HashMap<String, Value>,
|
||||
}
|
||||
|
||||
impl Claims {
|
||||
fn get(&self, key: &str) -> Option<&Value> { self.other_claims.get(key) }
|
||||
}
|
||||
|
||||
macro_rules! standard {
|
||||
($($field:ident: $type:ty),*$(,)?) => {
|
||||
$(
|
||||
fn $field(&self) -> $type {
|
||||
self.standard_claims.$field()
|
||||
}
|
||||
)*
|
||||
}
|
||||
}
|
||||
|
||||
impl openid::Claims for Claims {
|
||||
standard! {
|
||||
userinfo: &openid::Userinfo,
|
||||
c_hash: Option<&String>,
|
||||
at_hash: Option<&String>,
|
||||
iss: &Url,
|
||||
sub: &str,
|
||||
aud: &openid::SingleOrMultiple<String>,
|
||||
exp: i64,
|
||||
iat: i64,
|
||||
auth_time: Option<i64>,
|
||||
nonce: Option<&String>,
|
||||
acr: Option<&String>,
|
||||
amr: Option<&Vec<String>>,
|
||||
azp: Option<&String>,
|
||||
}
|
||||
}
|
||||
|
||||
impl openid::CompactJson for Claims {}
|
||||
impl AdditionalClaims for AllClaims {}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub struct PendingSession {
|
||||
pkce_verifier: String,
|
||||
nonce: String,
|
||||
csrf_token: String,
|
||||
pkce_verifier: PkceCodeVerifier,
|
||||
nonce: Nonce,
|
||||
csrf_token: CsrfToken,
|
||||
}
|
||||
|
||||
pub enum SessionCompletionStatus {
|
||||
@@ -134,33 +135,54 @@ impl crate::Service for Service {
|
||||
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
|
||||
Ok(Arc::new(Self {
|
||||
services: Services {
|
||||
client: args.depend::<client::Service>("client"),
|
||||
config: args.depend::<config::Service>("config"),
|
||||
globals: args.depend::<globals::Service>("globals"),
|
||||
globals: args.depend::<globals::Service>("globals"),
|
||||
media: args.depend::<media::Service>("media"),
|
||||
threepid: args.depend::<threepid::Service>("threepid"),
|
||||
users: args.depend::<users::Service>("users"),
|
||||
threepid: args.depend::<threepid::Service>("threepid"),
|
||||
users: args.depend::<users::Service>("users"),
|
||||
},
|
||||
runtime: args.server.runtime().clone(),
|
||||
db: Data {
|
||||
openidsubject_localpart: args.db["openidsubject_localpart"].clone(),
|
||||
db: Data {
|
||||
openidsubject_localpart: args.db["openidsubject_localpart"].clone(),
|
||||
openidsubjectprofilefield_url: args.db["openidsubjectprofilefield_url"].clone(),
|
||||
},
|
||||
client: args
|
||||
.server
|
||||
.config
|
||||
.oauth
|
||||
.oidc
|
||||
.clone()
|
||||
.map(Self::create_client)
|
||||
.transpose()?,
|
||||
},
|
||||
client: args.server.config.oauth.oidc.as_ref().map(|config| -> Result<OidcClient> {
|
||||
Ok(OidcClient {
|
||||
config: config.clone(),
|
||||
client_secret: if let Some(client_secret_file) = &config.client_secret_file {
|
||||
std::fs::read_to_string(client_secret_file)
|
||||
.map(|client_secret| client_secret.trim().to_owned())
|
||||
.map(ClientSecret::new)
|
||||
.map_err(|err| err!("Failed to read OIDC client secret file: {err}"))?
|
||||
} else if let Some(client_secret) = &config.client_secret {
|
||||
client_secret.clone()
|
||||
} else {
|
||||
// The config check function should cause an early exit before this happens
|
||||
panic!("neither client secret or client secret file were set");
|
||||
},
|
||||
machine: SetOnce::new(),
|
||||
// This isn't in the client service because it has to use the `reqwest` shipped by `openidconnect`
|
||||
client: reqwest::ClientBuilder::new()
|
||||
.dns_resolver(args.depend::<client::Service>("client").reqwest_resolver.clone())
|
||||
.connect_timeout(Duration::from_secs(args.server.config.request_conn_timeout))
|
||||
.read_timeout(Duration::from_secs(args.server.config.request_timeout))
|
||||
.timeout(Duration::from_secs(args.server.config.request_total_timeout))
|
||||
.pool_idle_timeout(Duration::from_secs(args.server.config.request_idle_timeout))
|
||||
.pool_max_idle_per_host(args.server.config.request_idle_per_host.into())
|
||||
.user_agent(conduwuit::user_agent())
|
||||
.redirect(reqwest::redirect::Policy::none())
|
||||
.danger_accept_invalid_certs(args.server.config.allow_invalid_tls_certificates_yes_i_know_what_the_fuck_i_am_doing_with_this_and_i_know_this_is_insecure)
|
||||
.build()
|
||||
.expect("client should build")
|
||||
})}
|
||||
).transpose()?,
|
||||
}))
|
||||
}
|
||||
|
||||
async fn worker(self: Arc<Self>) -> Result {
|
||||
if let Some(OidcClient { client, .. }) = &self.client {
|
||||
if let Some(OidcClient { machine, .. }) = &self.client {
|
||||
let discovered = self.discover().await?;
|
||||
client
|
||||
machine
|
||||
.set(SyncRwLock::new(Arc::new(discovered)))
|
||||
.expect("machine should be empty");
|
||||
}
|
||||
@@ -176,36 +198,13 @@ impl Service {
|
||||
// into the media repository. Keep this synced with the list in the
|
||||
// doc comment for `profile_key_map` in the config.
|
||||
const IMAGE_PROFILE_KEYS: &[&str] = &["avatar_url", "chat.commet.profile_banner"];
|
||||
const NONCE_SIZE: usize = 32;
|
||||
const SERVER_MISCONFIGURED: &str =
|
||||
"Identity server is misconfigured. Contact your homeserver's administrator.";
|
||||
|
||||
fn create_nonce() -> String { utils::random_string(Self::NONCE_SIZE) }
|
||||
|
||||
fn create_client(config: OidcConfig) -> Result<OidcClient> {
|
||||
let client_secret = if let Some(client_secret_file) = &config.client_secret_file {
|
||||
std::fs::read_to_string(client_secret_file)
|
||||
.map(|client_secret| client_secret.trim().to_owned())
|
||||
.map_err(|err| err!("Failed to read OIDC client secret file: {err}"))?
|
||||
} else if let Some(client_secret) = &config.client_secret {
|
||||
client_secret.clone()
|
||||
} else {
|
||||
// The config check function should cause an early exit before this
|
||||
// happens
|
||||
panic!("neither client secret or client secret file were set");
|
||||
};
|
||||
|
||||
Ok(OidcClient {
|
||||
client_secret,
|
||||
config,
|
||||
client: SetOnce::new(),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn enabled(&self) -> bool { self.client.is_some() }
|
||||
|
||||
async fn discover(&self) -> Result<IdpClient> {
|
||||
let OidcClient { config, client_secret, .. } =
|
||||
async fn discover(&self) -> Result<OidcClientMachine> {
|
||||
let OidcClient { config, client_secret, client, .. } =
|
||||
self.client.as_ref().expect("oidc should be configured");
|
||||
|
||||
let redirect_url = self
|
||||
@@ -215,15 +214,20 @@ impl Service {
|
||||
.join(&format!("{}/oidc/complete", conduwuit::ROUTE_PREFIX))
|
||||
.expect("redirect url should be valid");
|
||||
|
||||
IdpClient::discover_with_client(
|
||||
self.services.client.external_resource.clone(),
|
||||
config.client_id.clone(),
|
||||
Some(client_secret.clone()),
|
||||
Some(redirect_url.to_string()),
|
||||
config.discovery_url.clone(),
|
||||
let provider_metadata = CoreProviderMetadata::discover_async(
|
||||
IssuerUrl::new(config.discovery_url.clone())
|
||||
.map_err(|err| err!("Failed to parse OIDC discovery URL: {err}"))?,
|
||||
client,
|
||||
)
|
||||
.await
|
||||
.map_err(|err| err!("Failed to discover OIDC provider metadata: {err}"))
|
||||
.map_err(|err| err!("Failed to discover OIDC provider metadata: {err}"))?;
|
||||
|
||||
Ok(OidcClientMachine::from_provider_metadata(
|
||||
provider_metadata,
|
||||
config.client_id.clone(),
|
||||
Some(client_secret.clone()),
|
||||
)
|
||||
.set_redirect_uri(RedirectUrl::from_url(redirect_url)))
|
||||
}
|
||||
|
||||
pub fn provider_name(&self) -> Option<String> {
|
||||
@@ -252,32 +256,29 @@ impl Service {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn begin_session(&self, prompt: Option<openid::Prompt>) -> (PendingSession, Url) {
|
||||
let OidcClient { client, config, .. } =
|
||||
pub async fn begin_session(&self, prompt: Option<CoreAuthPrompt>) -> (PendingSession, Url) {
|
||||
let OidcClient { machine, config, .. } =
|
||||
self.client.as_ref().expect("oidc should be configured");
|
||||
let client = client.wait().await.read().clone();
|
||||
let machine = machine.wait().await.read().clone();
|
||||
|
||||
let csrf_token = Self::create_nonce();
|
||||
let nonce = Self::create_nonce();
|
||||
let (pkce_challenge, pkce_verifier) = PkceCodeChallenge::new_random_sha256();
|
||||
|
||||
let (auth_url, pkce) = client.auth_url_with_new_pkce(&Options {
|
||||
// The client will add the `openid` scope for us.
|
||||
scope: Some(config.additional_scopes.join(" ")),
|
||||
state: Some(csrf_token.clone()),
|
||||
nonce: Some(nonce.clone()),
|
||||
prompt: prompt.map(|prompt| HashSet::from_iter([prompt])),
|
||||
let mut auth_url = machine
|
||||
.authorize_url(
|
||||
CoreAuthenticationFlow::AuthorizationCode,
|
||||
CsrfToken::new_random,
|
||||
Nonce::new_random,
|
||||
)
|
||||
.add_scopes(config.additional_scopes.iter().cloned())
|
||||
.set_pkce_challenge(pkce_challenge);
|
||||
|
||||
..Default::default()
|
||||
});
|
||||
if let Some(prompt) = prompt {
|
||||
auth_url = auth_url.add_prompt(prompt);
|
||||
}
|
||||
|
||||
(
|
||||
PendingSession {
|
||||
pkce_verifier: pkce.code_verifier().to_owned(),
|
||||
nonce,
|
||||
csrf_token,
|
||||
},
|
||||
auth_url,
|
||||
)
|
||||
let (auth_url, csrf_token, nonce) = auth_url.url();
|
||||
|
||||
(PendingSession { pkce_verifier, nonce, csrf_token }, auth_url)
|
||||
}
|
||||
|
||||
pub async fn exchange_code(
|
||||
@@ -285,77 +286,78 @@ impl Service {
|
||||
session: PendingSession,
|
||||
response: AuthorizationCodeResponse,
|
||||
) -> Result<Claims, &'static str> {
|
||||
let Some(OidcClient { client, .. }) = self.client.as_ref() else {
|
||||
let Some(OidcClient { machine, client, config, .. }) = self.client.as_ref() else {
|
||||
return Err("Delegated authentication is not enabled on this server.");
|
||||
};
|
||||
|
||||
let current = client.wait().await.read().clone();
|
||||
let current = machine.wait().await.read().clone();
|
||||
|
||||
if session.csrf_token != response.state {
|
||||
if session.csrf_token.into_secret() != response.state {
|
||||
return Err("State mismatch.");
|
||||
}
|
||||
|
||||
let token_response = current
|
||||
.request_token_pkce(&response.code, Some(&session.pkce_verifier))
|
||||
.exchange_code(AuthorizationCode::new(response.code))
|
||||
.expect("machine should be configured correctly")
|
||||
.set_pkce_verifier(session.pkce_verifier)
|
||||
.request_async(client)
|
||||
.await
|
||||
.map(Token::<Claims>::from)
|
||||
.map_err(|err| {
|
||||
error!(error=?err, "Failed to exchange OIDC authorization code");
|
||||
"Code exchange failed. The identity provider may be unreachable. Contact your \
|
||||
homeserver's administrator."
|
||||
})?;
|
||||
|
||||
let Some(mut id_token) = token_response.id_token else {
|
||||
let Some(id_token) = token_response.id_token() else {
|
||||
error!("Identity server did not return an id token");
|
||||
return Err(Self::SERVER_MISCONFIGURED);
|
||||
};
|
||||
|
||||
if let Err(err) = current.decode_token(&mut id_token) {
|
||||
error!(error=?err, "Failed to decode ID token");
|
||||
return Err(Self::SERVER_MISCONFIGURED);
|
||||
}
|
||||
let verify = |machine: &OidcClientMachine| {
|
||||
let verifier =
|
||||
machine
|
||||
.id_token_verifier()
|
||||
.set_other_audience_verifier_fn(|audience| {
|
||||
config.additional_trusted_audiences.contains(audience)
|
||||
});
|
||||
|
||||
let verify = |client: &IdpClient| {
|
||||
client.validate_token(&id_token, Some(session.nonce.as_str()), None)
|
||||
id_token
|
||||
.claims(&verifier, &session.nonce)
|
||||
.map(ToOwned::to_owned)
|
||||
};
|
||||
|
||||
let mut result = verify(¤t);
|
||||
|
||||
if matches!(
|
||||
result,
|
||||
Err(openid::error::Error::Jose(openid::error::Jose::ValidationError(
|
||||
openid::biscuit::errors::ValidationError::KeyNotFound
|
||||
)))
|
||||
Err(ClaimsVerificationError::SignatureVerification(
|
||||
SignatureVerificationError::NoMatchingKey
|
||||
))
|
||||
) {
|
||||
match self.discover().await {
|
||||
| Ok(discovered) => {
|
||||
info!("Refreshed OIDC provider metadata after an unknown signing key");
|
||||
result = verify(&discovered);
|
||||
*client.wait().await.write() = Arc::new(discovered);
|
||||
*machine.wait().await.write() = Arc::new(discovered);
|
||||
},
|
||||
| Err(err) => warn!("Failed to refresh OIDC provider metadata: {err}"),
|
||||
}
|
||||
}
|
||||
|
||||
match result {
|
||||
| Ok(()) => {
|
||||
let (_, claims) = id_token.unwrap_decoded();
|
||||
let claims = result.map_err(|err| {
|
||||
error!("Failed to verify id token claims: {err}");
|
||||
Self::SERVER_MISCONFIGURED
|
||||
})?;
|
||||
|
||||
info!(subject = claims.sub(), "Authenticated subject");
|
||||
info!(subject = claims.subject().as_str(), "Authenticated subject");
|
||||
|
||||
Ok(claims)
|
||||
},
|
||||
| Err(err) => {
|
||||
error!("Failed to verify id token claims: {err}");
|
||||
Err(Self::SERVER_MISCONFIGURED)
|
||||
},
|
||||
}
|
||||
Ok(claims)
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self, claims), fields(subject = claims.sub().to_owned()))]
|
||||
#[tracing::instrument(skip(self, claims), fields(subject = claims.subject().to_string()))]
|
||||
pub async fn complete_session(
|
||||
&self,
|
||||
claims: Claims,
|
||||
claims: &Claims,
|
||||
supplied_user_id: Option<OwnedUserId>,
|
||||
client_ip: &IpAddr,
|
||||
) -> Result<SessionCompletionStatus, &'static str> {
|
||||
@@ -363,14 +365,21 @@ impl Service {
|
||||
return Err("Delegated authentication is not enabled on this server.");
|
||||
};
|
||||
|
||||
debug!(claims = ?claims.other_claims, "Got claims from the identity provider");
|
||||
// this is a truly awful hack but we really need all the claims in a map
|
||||
let all_claims = serde_json::to_value(claims)
|
||||
.expect("should be able to serialize claims")
|
||||
.as_object()
|
||||
.expect("claims should be an object")
|
||||
.to_owned();
|
||||
|
||||
let subject = claims.sub().to_owned();
|
||||
debug!(?all_claims, "Got claims from the identity provider");
|
||||
|
||||
let subject = claims.subject().as_str();
|
||||
|
||||
let user_id = if let Ok(localpart) = self
|
||||
.db
|
||||
.openidsubject_localpart
|
||||
.get(&subject)
|
||||
.get(subject)
|
||||
.await
|
||||
.deserialized::<String>()
|
||||
{
|
||||
@@ -382,7 +391,7 @@ impl Service {
|
||||
} else {
|
||||
return Ok(SessionCompletionStatus::NeedsUserId);
|
||||
}
|
||||
} else if let Some(preferred_username) = claims
|
||||
} else if let Some(preferred_username) = all_claims
|
||||
.get(&config.preferred_username_claim)
|
||||
.and_then(|claim| claim.as_str())
|
||||
{
|
||||
@@ -426,7 +435,7 @@ impl Service {
|
||||
},
|
||||
};
|
||||
|
||||
self.link_user(&user_id, &subject);
|
||||
self.link_user(&user_id, subject);
|
||||
|
||||
// Import profile fields
|
||||
if matches!(config.profile_key_import_mode, OidcProfileKeyImportMode::OnLogin)
|
||||
@@ -436,7 +445,7 @@ impl Service {
|
||||
) && new_account_registered)
|
||||
{
|
||||
if let Some(email_claim) = &config.email_claim {
|
||||
if let Some(email) = claims.get(email_claim).and_then(|email| email.as_str())
|
||||
if let Some(email) = claims.email().map(|email| email.as_str())
|
||||
&& let Ok(address) = Address::from_str(email)
|
||||
{
|
||||
if let Err(err) = self
|
||||
@@ -456,6 +465,7 @@ impl Service {
|
||||
}
|
||||
|
||||
let user_id = user_id.clone();
|
||||
let subject = claims.subject().to_string();
|
||||
let profile_key_map = config.profile_key_map.clone();
|
||||
let openidsubjectprofilefield_url = self.db.openidsubjectprofilefield_url.clone();
|
||||
let users = self.services.users.clone();
|
||||
@@ -465,7 +475,7 @@ impl Service {
|
||||
// TODO: once we get support for full profile replacement, use
|
||||
// that logic instead
|
||||
for (field, claim) in &profile_key_map {
|
||||
let Some(value) = claims.get(claim).cloned() else {
|
||||
let Some(value) = all_claims.get(claim).cloned() else {
|
||||
warn!(?field, ?claim, "IDP provided no value for this mapped claim");
|
||||
continue;
|
||||
};
|
||||
|
||||
@@ -2,7 +2,6 @@ mod webpush;
|
||||
|
||||
use std::{fmt::Debug, mem, net::IpAddr, sync::Arc};
|
||||
|
||||
use assign::assign;
|
||||
use bytes::BytesMut;
|
||||
use conduwuit::{config::experiments::ToggledExperiment, utils::response::LimitReadExt};
|
||||
use conduwuit_core::{
|
||||
@@ -24,10 +23,7 @@ use ruma::{
|
||||
v1::{Device, Notification, NotificationCounts, NotificationPriority},
|
||||
},
|
||||
},
|
||||
events::{
|
||||
AnySyncTimelineEvent, GlobalAccountDataEvent, GlobalAccountDataEventType,
|
||||
TimelineEventType, direct::DirectEventContent, room::power_levels::RoomPowerLevels,
|
||||
},
|
||||
events::{AnySyncTimelineEvent, TimelineEventType, room::power_levels::RoomPowerLevels},
|
||||
push::{
|
||||
Action, HighlightTweakValue, PushConditionPowerLevelsCtx, PushConditionRoomCtx,
|
||||
PushFormat, Ruleset, Tweak,
|
||||
@@ -40,7 +36,7 @@ use url::Host;
|
||||
|
||||
pub use self::webpush::ActivationOutcome;
|
||||
use self::webpush::Vapid;
|
||||
use crate::{Dep, account_data, client, config, globals, rooms, sending, users};
|
||||
use crate::{Dep, client, config, globals, rooms, sending, users};
|
||||
|
||||
const PUSH_GATEWAY_SCHEMES: &[&str] = &["http", "https"];
|
||||
const WEBPUSH_SCHEMES: &[&str] = &["https"];
|
||||
@@ -61,7 +57,6 @@ pub struct Service {
|
||||
struct Services {
|
||||
server: Arc<Server>,
|
||||
globals: Dep<globals::Service>,
|
||||
account_data: Dep<account_data::Service>,
|
||||
config: Dep<config::Service>,
|
||||
client: Dep<client::Service>,
|
||||
state_accessor: Dep<rooms::state_accessor::Service>,
|
||||
@@ -91,7 +86,6 @@ impl crate::Service for Service {
|
||||
services: Services {
|
||||
server: args.server.clone(),
|
||||
globals: args.depend::<globals::Service>("globals"),
|
||||
account_data: args.depend::<account_data::Service>("account_data"),
|
||||
client: args.depend::<client::Service>("client"),
|
||||
config: args.depend::<config::Service>("config"),
|
||||
state_accessor: args
|
||||
@@ -494,34 +488,11 @@ impl Service {
|
||||
.await
|
||||
.unwrap_or_else(|_| user.localpart().to_owned());
|
||||
|
||||
let is_direct = self.services.config.experiments.msc4563.is_enabled()
|
||||
&& self
|
||||
.services
|
||||
.account_data
|
||||
.get_global::<GlobalAccountDataEvent<DirectEventContent>>(
|
||||
user,
|
||||
GlobalAccountDataEventType::Direct,
|
||||
)
|
||||
.await
|
||||
.ok()
|
||||
.and_then(|direct| {
|
||||
direct
|
||||
.content
|
||||
.values()
|
||||
.flatten()
|
||||
.any(|dm_room_id| dm_room_id == room_id)
|
||||
.then_some(())
|
||||
})
|
||||
.is_some();
|
||||
|
||||
assign!(
|
||||
PushConditionRoomCtx::new(
|
||||
room_id.to_owned(),
|
||||
room_joined_count,
|
||||
user.to_owned(),
|
||||
user_display_name,
|
||||
),
|
||||
{ is_direct }
|
||||
PushConditionRoomCtx::new(
|
||||
room_id.to_owned(),
|
||||
room_joined_count,
|
||||
user.to_owned(),
|
||||
user_display_name,
|
||||
)
|
||||
.with_power_levels(power_levels)
|
||||
}
|
||||
|
||||
@@ -75,7 +75,8 @@ impl Service {
|
||||
"lazy loading should be enabled by your options"
|
||||
);
|
||||
|
||||
let include_redundant = ctx.options.is_some_and(Options::include_redundant_members);
|
||||
let include_redundant = cfg!(feature = "element_hacks")
|
||||
|| ctx.options.is_some_and(Options::include_redundant_members);
|
||||
|
||||
let witness = self
|
||||
.witness(ctx, senders.iter().map(AsRef::as_ref))
|
||||
|
||||
@@ -7,6 +7,7 @@ pub mod membership;
|
||||
pub mod metadata;
|
||||
pub mod outlier;
|
||||
pub mod pdu_metadata;
|
||||
pub mod queue;
|
||||
pub mod read_receipt;
|
||||
pub mod search;
|
||||
pub mod short;
|
||||
@@ -32,6 +33,7 @@ pub struct Service {
|
||||
pub metadata: Arc<metadata::Service>,
|
||||
pub outlier: Arc<outlier::Service>,
|
||||
pub pdu_metadata: Arc<pdu_metadata::Service>,
|
||||
pub queue: Arc<queue::Service>,
|
||||
pub read_receipt: Arc<read_receipt::Service>,
|
||||
pub search: Arc<search::Service>,
|
||||
pub short: Arc<short::Service>,
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use conduwuit::{Result, utils::stream::TryIgnore};
|
||||
use database::{Deserialized, Json, Map};
|
||||
|
||||
pub(super) struct Data {
|
||||
pub global: Arc<Map>,
|
||||
jobcounter_mutex: tokio::sync::RwLock<()>,
|
||||
pub txn_jobid_job: Arc<Map>,
|
||||
}
|
||||
|
||||
impl Data {
|
||||
pub(super) fn new(services: &crate::Args<'_>) -> Self {
|
||||
Self {
|
||||
global: services.db["global"].clone(),
|
||||
jobcounter_mutex: tokio::sync::RwLock::new(()),
|
||||
txn_jobid_job: services.db["txn_jobid_job"].clone(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the current job counter value.
|
||||
#[must_use]
|
||||
pub(super) async fn current_job_id(&self) -> u64 {
|
||||
let _lock = self.jobcounter_mutex.read().await;
|
||||
self.global
|
||||
.get("txn_jobcounter")
|
||||
.await
|
||||
.deserialized()
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Increments the global job counter, returning the new value.
|
||||
#[must_use]
|
||||
pub(super) async fn next_job_id(&self) -> u64 {
|
||||
let _lock = self.jobcounter_mutex.write().await;
|
||||
let current = self
|
||||
.global
|
||||
.get("txn_jobcounter")
|
||||
.await
|
||||
.deserialized::<u64>()
|
||||
.unwrap_or_default();
|
||||
let next = current.checked_add(1).unwrap_or(current);
|
||||
self.global.insert("txn_jobcounter", next.to_be_bytes());
|
||||
next
|
||||
}
|
||||
|
||||
/// Saves a job and returns its ID.
|
||||
pub(super) async fn save_job(&self, job: &super::QueueJob) -> Result<u64> {
|
||||
let job_id = self.next_job_id().await;
|
||||
self.txn_jobid_job.raw_put(job_id.to_be_bytes(), Json(job));
|
||||
Ok(job_id)
|
||||
}
|
||||
|
||||
/// Removes a job from the database.
|
||||
#[inline]
|
||||
pub(super) fn finish_job(&self, job_id: u64) {
|
||||
self.txn_jobid_job.remove(&job_id.to_be_bytes());
|
||||
}
|
||||
|
||||
pub(super) fn stream_all_pending_jobs(
|
||||
&self,
|
||||
) -> impl futures::Stream<Item = (u64, super::QueueJob)> + '_ {
|
||||
self.txn_jobid_job.stream().ignore_err()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,259 @@
|
||||
mod data;
|
||||
|
||||
use std::{
|
||||
collections::{HashMap, hash_map::Entry},
|
||||
sync::{Arc, OnceLock},
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
|
||||
use async_trait::async_trait;
|
||||
use conduwuit::{
|
||||
Error, Result, Server, SyncMutex, debug, err, error, info, utils::millis_since_unix_epoch,
|
||||
};
|
||||
use futures::StreamExt;
|
||||
use opentelemetry::KeyValue;
|
||||
use ruma::{
|
||||
CanonicalJsonObject, CanonicalJsonValue, OwnedEventId, OwnedRoomId, OwnedServerName,
|
||||
api::error::ErrorKind, events::TimelineEventType,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tokio::{
|
||||
sync::{
|
||||
Notify, mpsc,
|
||||
mpsc::{Sender, UnboundedReceiver, UnboundedSender},
|
||||
},
|
||||
task::JoinSet,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
rooms,
|
||||
service::{Args, Dep},
|
||||
};
|
||||
|
||||
pub struct Services {
|
||||
event_handler: Dep<rooms::event_handler::Service>,
|
||||
server: Arc<Server>,
|
||||
}
|
||||
|
||||
pub struct Service {
|
||||
data: data::Data,
|
||||
queues: SyncMutex<HashMap<OwnedRoomId, UnboundedSender<(u64, QueueJob)>>>,
|
||||
send: OnceLock<Sender<(u64, QueueJob)>>,
|
||||
shutdown: Notify,
|
||||
services: Services,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl crate::Service for Service {
|
||||
fn build(args: Args<'_>) -> Result<Arc<Self>>
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
Ok(Arc::new(Self {
|
||||
data: data::Data::new(&args),
|
||||
queues: SyncMutex::new(HashMap::new()),
|
||||
shutdown: Notify::new(),
|
||||
send: OnceLock::new(),
|
||||
services: Services {
|
||||
event_handler: args.depend("rooms::event_handler"),
|
||||
server: args.server.clone(),
|
||||
},
|
||||
}))
|
||||
}
|
||||
|
||||
async fn worker(self: Arc<Self>) -> Result<()> {
|
||||
let (send, recv) = mpsc::channel(5);
|
||||
self.send
|
||||
.set(send)
|
||||
.expect("send channel cannot already be set during worker init");
|
||||
let mut recv = tokio_stream::wrappers::ReceiverStream::new(recv);
|
||||
let mut handles = JoinSet::new();
|
||||
let (yielder, mut yielding) = mpsc::channel(5);
|
||||
|
||||
let latest_job_id = self.data.current_job_id().await;
|
||||
let backlog_count = self.data.txn_jobid_job.count().await;
|
||||
debug!(latest_job_id, backlog_count, "Starting room queue worker");
|
||||
|
||||
let backlog = std::pin::pin!(self.data.stream_all_pending_jobs());
|
||||
let mut combined_recv = backlog.chain(&mut recv);
|
||||
|
||||
loop {
|
||||
let Some((job_id, job)) = tokio::select! (
|
||||
() = self.shutdown.notified() => {
|
||||
info!("Shutting down");
|
||||
yielding.close();
|
||||
recv.close();
|
||||
break;
|
||||
},
|
||||
room_id = yielding.recv() => {
|
||||
if let Some(room_id) = room_id {
|
||||
self.queues.lock().remove(&room_id);
|
||||
}
|
||||
continue;
|
||||
},
|
||||
job = combined_recv.next() => job,
|
||||
) else {
|
||||
debug!("Room queue worker channel closed without shutdown?");
|
||||
break;
|
||||
};
|
||||
|
||||
let mut queues = self.queues.lock();
|
||||
match queues.entry(job.room_id.clone()) {
|
||||
| Entry::Occupied(entry) => {
|
||||
entry.get().send((job_id, job)).unwrap();
|
||||
// TODO: handle error
|
||||
// It might be possible for a self-reaping worker to close
|
||||
// at the same time we try to send to it, which will cause
|
||||
// this send to return a "channel closed" error.
|
||||
},
|
||||
| Entry::Vacant(entry) => {
|
||||
let room_id = entry.key().to_owned();
|
||||
let (sender, receiver) = mpsc::unbounded_channel();
|
||||
sender.send((job_id, job)).unwrap(); // TODO: handle error
|
||||
|
||||
handles.spawn_on(
|
||||
Self::room_worker(self.clone(), room_id, receiver, yielder.clone()),
|
||||
self.services.server.runtime(),
|
||||
);
|
||||
entry.insert(sender);
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// If the loop broke, make sure that the shutdown signal was sent, so
|
||||
// that any room workers are guaranteed to shut down as soon as
|
||||
// possible.
|
||||
self.interrupt();
|
||||
|
||||
while let Some(ret) = handles.join_next_with_id().await {
|
||||
match ret {
|
||||
| Ok((id, ())) => {
|
||||
debug!(?id, "room queue worker finished");
|
||||
},
|
||||
| Err(error) => {
|
||||
error!(id = ?error.id(), ?error, "room queue worker failed");
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn interrupt(&self) { self.shutdown.notify_waiters(); }
|
||||
|
||||
fn name(&self) -> &'static str { module_path!() }
|
||||
}
|
||||
|
||||
impl Service {
|
||||
pub async fn new_job(&self, job: QueueJob) -> Result<()> {
|
||||
let job_id = self.data.save_job(&job).await?;
|
||||
self.send
|
||||
.get()
|
||||
.expect("send channel must be set before new_job is called")
|
||||
.send((job_id, job))
|
||||
.await
|
||||
.map_err(|e| err!("failed to send PDU to worker: {e}"))
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self,channel,yielder), fields(%room_id))]
|
||||
async fn room_worker(
|
||||
self: Arc<Self>,
|
||||
room_id: OwnedRoomId,
|
||||
mut channel: UnboundedReceiver<(u64, QueueJob)>,
|
||||
yielder: Sender<OwnedRoomId>,
|
||||
) {
|
||||
debug!("Room worker starting up");
|
||||
loop {
|
||||
let job = tokio::select! {
|
||||
() = self.shutdown.notified() => {
|
||||
debug!("Room worker shutting down");
|
||||
channel.close();
|
||||
return;
|
||||
},
|
||||
() = tokio::time::sleep(Duration::from_mins(5)) => {
|
||||
debug!("Room worker self-reaping (no activity in 5 minutes)");
|
||||
yielder.send(room_id).await.ok();
|
||||
debug!("Room worker reaped. Goodbye.");
|
||||
return;
|
||||
},
|
||||
job = channel.recv() => job
|
||||
};
|
||||
let Some((job_id, job)) = job else {
|
||||
debug!("Room worker channel closed without shutdown?");
|
||||
break;
|
||||
};
|
||||
debug!(
|
||||
%job_id,
|
||||
event_id=%job.event_id,
|
||||
origin=%job.origin,
|
||||
backpressure=%channel.len(),
|
||||
"Handling incoming job"
|
||||
);
|
||||
let _room_lock = self
|
||||
.services
|
||||
.event_handler
|
||||
.mutex_federation
|
||||
.lock(room_id.as_str())
|
||||
.await;
|
||||
debug!(%job_id, event_id=%job.event_id, origin=%job.origin, "Acquired room federation lock");
|
||||
|
||||
let event_type = KeyValue::new(
|
||||
"type",
|
||||
pdu_type_label(job.object.get("type").and_then(CanonicalJsonValue::as_str)),
|
||||
);
|
||||
let origin_server_ts = job
|
||||
.object
|
||||
.get("origin_server_ts")
|
||||
.and_then(CanonicalJsonValue::as_integer)
|
||||
.and_then(|ts| u64::try_from(i64::from(ts)).ok());
|
||||
|
||||
let start = Instant::now();
|
||||
|
||||
let result = self
|
||||
.services
|
||||
.event_handler
|
||||
.handle_incoming_pdu(&job.origin, &job.room_id, &job.event_id, job.object, false)
|
||||
.await;
|
||||
self.data.finish_job(job_id);
|
||||
|
||||
let outcome = KeyValue::new("outcome", match &result {
|
||||
| Ok(_) => "accepted",
|
||||
| Err(Error::BadRequest(ErrorKind::Forbidden, ..)) => "forbidden",
|
||||
| Err(Error::BadRequest(ErrorKind::InvalidParam | ErrorKind::BadJson, ..)) =>
|
||||
"invalid",
|
||||
| Err(_) => "error",
|
||||
});
|
||||
let instruments = &self.services.server.metrics.instruments;
|
||||
instruments
|
||||
.federation_incoming_pdu_duration
|
||||
.record(start.elapsed().as_secs_f64(), std::slice::from_ref(&outcome));
|
||||
if let (Ok(_), Some(ts)) = (&result, origin_server_ts) {
|
||||
let lag = millis_since_unix_epoch().saturating_sub(ts);
|
||||
instruments
|
||||
.federation_incoming_pdu_lag
|
||||
.record(Duration::from_millis(lag).as_secs_f64(), &[]);
|
||||
}
|
||||
instruments
|
||||
.federation_incoming_pdus
|
||||
.add(1, &[event_type, outcome]);
|
||||
debug!(event_id=%job.event_id, origin=%job.origin, "Job finished");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||
pub struct QueueJob {
|
||||
pub origin: OwnedServerName,
|
||||
pub event_id: OwnedEventId,
|
||||
pub room_id: OwnedRoomId,
|
||||
pub object: CanonicalJsonObject,
|
||||
}
|
||||
|
||||
/// Known event types, or `other`, so remote servers cannot create new
|
||||
/// attribute values.
|
||||
fn pdu_type_label(event_type: Option<&str>) -> String {
|
||||
match event_type.map(TimelineEventType::from) {
|
||||
| Some(TimelineEventType::_Custom(_)) | None => "other".to_owned(),
|
||||
| Some(event_type) => event_type.to_string(),
|
||||
}
|
||||
}
|
||||
@@ -522,6 +522,13 @@ impl Service {
|
||||
let device_changes =
|
||||
self.select_edus_device_changes(server_name, batch, &max_edu_count, &events_len);
|
||||
|
||||
let receipts: OptionFuture<_> = self
|
||||
.server
|
||||
.config
|
||||
.allow_outgoing_read_receipts
|
||||
.then(|| self.select_edus_receipts(server_name, batch, &max_edu_count))
|
||||
.into();
|
||||
|
||||
let presence: OptionFuture<_> = self
|
||||
.server
|
||||
.config
|
||||
@@ -529,20 +536,11 @@ impl Service {
|
||||
.then(|| self.select_edus_presence(server_name, batch, &max_edu_count))
|
||||
.into();
|
||||
|
||||
let (device_changes, presence) = join!(device_changes, presence);
|
||||
let (device_changes, receipts, presence) = join!(device_changes, receipts, presence);
|
||||
|
||||
let mut events = device_changes;
|
||||
events.extend(presence.into_iter().flatten());
|
||||
|
||||
// leave a slot for the queued event, but always allow one receipt EDU
|
||||
let edu_limit = (EDU_LIMIT - 1).saturating_sub(events.len()).max(1);
|
||||
if self.server.config.allow_outgoing_read_receipts {
|
||||
// must be selected last, as it may lower max_edu_count
|
||||
events.extend(
|
||||
self.select_edus_receipts(server_name, batch, &max_edu_count, edu_limit)
|
||||
.await,
|
||||
);
|
||||
}
|
||||
events.extend(receipts.into_iter().flatten());
|
||||
|
||||
// TODO(nex): some EDUs like typing need flattening
|
||||
|
||||
@@ -618,11 +616,9 @@ impl Service {
|
||||
server_name: &ServerName,
|
||||
since: (u64, u64),
|
||||
max_edu_count: &AtomicU64,
|
||||
edu_limit: usize,
|
||||
) -> EduVec {
|
||||
) -> Option<EduBuf> {
|
||||
let num = AtomicUsize::new(0);
|
||||
let deferred = AtomicU64::new(u64::MAX);
|
||||
let rooms: Vec<_> = self
|
||||
let receipts: BTreeMap<OwnedRoomId, ReceiptMap> = self
|
||||
.services
|
||||
.state_cache
|
||||
.server_rooms(server_name)
|
||||
@@ -631,54 +627,33 @@ impl Service {
|
||||
return None;
|
||||
}
|
||||
|
||||
let maps = self
|
||||
.select_edus_receipts_room(
|
||||
&room_id,
|
||||
since,
|
||||
max_edu_count,
|
||||
&num,
|
||||
edu_limit,
|
||||
&deferred,
|
||||
)
|
||||
let receipt_map = self
|
||||
.select_edus_receipts_room(&room_id, since, max_edu_count, &num)
|
||||
.await;
|
||||
|
||||
(!maps.is_empty()).then_some((room_id, maps))
|
||||
(!receipt_map.read.is_empty()).then_some((room_id, receipt_map))
|
||||
})
|
||||
.collect()
|
||||
.await;
|
||||
|
||||
// the next transaction starts at the first receipt that did not fit
|
||||
max_edu_count
|
||||
.fetch_min(deferred.load(Ordering::Relaxed).saturating_sub(1), Ordering::Relaxed);
|
||||
|
||||
let mut contents = Vec::<BTreeMap<OwnedRoomId, ReceiptMap>>::new();
|
||||
for (room_id, maps) in rooms {
|
||||
for (index, read) in maps.into_iter().enumerate() {
|
||||
if index == contents.len() {
|
||||
contents.push(BTreeMap::new());
|
||||
}
|
||||
contents[index].insert(room_id.clone(), ReceiptMap::new(read));
|
||||
}
|
||||
if receipts.is_empty() {
|
||||
return None;
|
||||
}
|
||||
|
||||
contents
|
||||
.into_iter()
|
||||
.map(|content| {
|
||||
let edu = Edu::Receipt(ReceiptContent::new(content));
|
||||
let receipt_content = Edu::Receipt(ReceiptContent::new(receipts));
|
||||
|
||||
let mut buf = EduBuf::new();
|
||||
serde_json::to_writer(&mut buf, &edu)
|
||||
.expect("Failed to serialize Receipt EDU to JSON vec");
|
||||
buf
|
||||
})
|
||||
.collect()
|
||||
let mut buf = EduBuf::new();
|
||||
serde_json::to_writer(&mut buf, &receipt_content)
|
||||
.expect("Failed to serialize Receipt EDU to JSON vec");
|
||||
|
||||
Some(buf)
|
||||
}
|
||||
|
||||
/// Look for read receipts in this room
|
||||
#[tracing::instrument(
|
||||
name = "receipts",
|
||||
level = "trace",
|
||||
skip(self, since, max_edu_count, num, deferred)
|
||||
skip(self, since, max_edu_count, num)
|
||||
)]
|
||||
async fn select_edus_receipts_room(
|
||||
&self,
|
||||
@@ -686,16 +661,14 @@ impl Service {
|
||||
since: (u64, u64),
|
||||
max_edu_count: &AtomicU64,
|
||||
num: &AtomicUsize,
|
||||
edu_limit: usize,
|
||||
deferred: &AtomicU64,
|
||||
) -> Vec<BTreeMap<OwnedUserId, ReceiptData>> {
|
||||
) -> ReceiptMap {
|
||||
let receipts = self
|
||||
.services
|
||||
.read_receipt
|
||||
.readreceipts_since(room_id, Some(since.0));
|
||||
|
||||
pin_mut!(receipts);
|
||||
let mut maps = Vec::new();
|
||||
let mut read = BTreeMap::<OwnedUserId, ReceiptData>::new();
|
||||
while let Some((user_id, count, read_receipt)) = receipts.next().await {
|
||||
if count > since.1 {
|
||||
break;
|
||||
@@ -731,20 +704,14 @@ impl Service {
|
||||
|
||||
let receipt_data = ReceiptData::new(receipt, vec![event_id]);
|
||||
|
||||
let Some(index) = add_receipt(&mut maps, user_id, receipt_data, edu_limit) else {
|
||||
deferred.fetch_min(count, Ordering::Relaxed);
|
||||
break;
|
||||
};
|
||||
|
||||
// only a user's first receipt counts towards the limit
|
||||
if index == 0
|
||||
&& num.fetch_add(1, Ordering::Relaxed).saturating_add(1) >= SELECT_RECEIPT_LIMIT
|
||||
{
|
||||
break;
|
||||
if read.insert(user_id, receipt_data).is_none() {
|
||||
if num.fetch_add(1, Ordering::Relaxed).saturating_add(1) >= SELECT_RECEIPT_LIMIT {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
maps
|
||||
ReceiptMap::new(read)
|
||||
}
|
||||
|
||||
/// Look for presence
|
||||
@@ -1143,27 +1110,3 @@ impl Service {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// Adds the receipt to the first map without one from the user and returns
|
||||
/// that map's index, or `None` if all `limit` maps have one.
|
||||
fn add_receipt(
|
||||
maps: &mut Vec<BTreeMap<OwnedUserId, ReceiptData>>,
|
||||
user_id: OwnedUserId,
|
||||
receipt: ReceiptData,
|
||||
limit: usize,
|
||||
) -> Option<usize> {
|
||||
let index = maps
|
||||
.iter()
|
||||
.position(|map| !map.contains_key(&user_id))
|
||||
.unwrap_or(maps.len());
|
||||
if index >= limit {
|
||||
return None;
|
||||
}
|
||||
|
||||
if index == maps.len() {
|
||||
maps.push(BTreeMap::new());
|
||||
}
|
||||
maps[index].insert(user_id, receipt);
|
||||
|
||||
Some(index)
|
||||
}
|
||||
@@ -1,19 +1,14 @@
|
||||
use std::{collections::BTreeMap, iter::once};
|
||||
use std::iter::once;
|
||||
|
||||
use conduwuit::{
|
||||
Error,
|
||||
matrix::{PartialPdu, pdu::sticky},
|
||||
};
|
||||
use futures::{StreamExt, stream::FuturesUnordered};
|
||||
use ruma::{
|
||||
RoomId, UserId,
|
||||
api::federation::transactions::edu::ReceiptData,
|
||||
events::{receipt::Receipt, sticky::StickyDurationMs},
|
||||
server_name, user_id,
|
||||
};
|
||||
use ruma::{RoomId, UserId, events::sticky::StickyDurationMs, server_name};
|
||||
use serde_json::{json, value::to_raw_value};
|
||||
|
||||
use super::{CurTransactionStatus, TransactionStatus, add_receipt};
|
||||
use super::{CurTransactionStatus, TransactionStatus};
|
||||
use crate::{
|
||||
sending::{Destination, EduBuf, SendingEvent},
|
||||
test_utils::{test_services, test_services_with},
|
||||
@@ -201,17 +196,3 @@ async fn restarted_worker_keeps_sticky_events_when_startup_netburst_is_disabled(
|
||||
assert_eq!(active_after_startup, 0);
|
||||
assert_eq!(sending_after_startup, 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn add_receipt_separates_receipts_of_one_user() {
|
||||
let alice = user_id!("@alice:example.org");
|
||||
let bob = user_id!("@bob:example.org");
|
||||
let receipt = || ReceiptData::new(Receipt::default(), vec![]);
|
||||
let mut maps = Vec::new();
|
||||
|
||||
assert_eq!(add_receipt(&mut maps, alice.to_owned(), receipt(), 2), Some(0));
|
||||
assert_eq!(add_receipt(&mut maps, alice.to_owned(), receipt(), 2), Some(1));
|
||||
assert_eq!(add_receipt(&mut maps, bob.to_owned(), receipt(), 2), Some(0));
|
||||
assert_eq!(add_receipt(&mut maps, alice.to_owned(), receipt(), 2), None);
|
||||
assert_eq!(maps.iter().map(BTreeMap::len).collect::<Vec<_>>(), [2, 1]);
|
||||
}
|
||||
@@ -101,6 +101,7 @@ impl Services {
|
||||
metadata: build!(rooms::metadata::Service),
|
||||
outlier: build!(rooms::outlier::Service),
|
||||
pdu_metadata: build!(rooms::pdu_metadata::Service),
|
||||
queue: build!(rooms::queue::Service),
|
||||
read_receipt: build!(rooms::read_receipt::Service),
|
||||
search: build!(rooms::search::Service),
|
||||
short: build!(rooms::short::Service),
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ form_urlencoded = "1.2.2"
|
||||
futures.workspace = true
|
||||
lettre.workspace = true
|
||||
memory-serve = "2.4.0"
|
||||
openid.workspace = true
|
||||
openidconnect.workspace = true
|
||||
ruma.workspace = true
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
|
||||
@@ -7,7 +7,7 @@ use axum::{
|
||||
routing::{get, on},
|
||||
};
|
||||
use conduwuit_api::client::handle_login;
|
||||
use openid::Prompt;
|
||||
use openidconnect::core::CoreAuthPrompt;
|
||||
use ruma::{
|
||||
OwnedUserId,
|
||||
api::client::uiaa::{EmailUserIdentifier, MatrixUserIdentifier, UserIdentifier},
|
||||
@@ -86,8 +86,8 @@ async fn route_login(
|
||||
let (session, redirect_url) = services
|
||||
.oidc
|
||||
.begin_session(match intent {
|
||||
| Some(LoginIntent::SwitchAccounts) => Some(Prompt::SelectAccount),
|
||||
| _ if reauthenticate => Some(Prompt::Consent),
|
||||
| Some(LoginIntent::SwitchAccounts) => Some(CoreAuthPrompt::SelectAccount),
|
||||
| _ if reauthenticate => Some(CoreAuthPrompt::Consent),
|
||||
| _ => None,
|
||||
})
|
||||
.await;
|
||||
|
||||
@@ -106,7 +106,10 @@ async fn route_complete(
|
||||
.await
|
||||
.expect("should be able to serialize oidc session");
|
||||
|
||||
Box::pin(services.oidc.complete_session(claims, None, &client_ip)).await
|
||||
services
|
||||
.oidc
|
||||
.complete_session(&claims, None, &client_ip)
|
||||
.await
|
||||
},
|
||||
| OidcSessionState::Authorized { claims } => {
|
||||
let supplied_user_id = if let Some(form) = form {
|
||||
@@ -163,12 +166,10 @@ async fn route_complete(
|
||||
None
|
||||
};
|
||||
|
||||
Box::pin(
|
||||
services
|
||||
.oidc
|
||||
.complete_session(*claims, supplied_user_id, &client_ip),
|
||||
)
|
||||
.await
|
||||
services
|
||||
.oidc
|
||||
.complete_session(&claims, supplied_user_id, &client_ip)
|
||||
.await
|
||||
},
|
||||
}
|
||||
.map_err(|err| WebError::BadRequest(err.to_owned()))?;
|
||||
|
||||
Reference in new issue
Block a user