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 | |
|---|---|---|---|
|
|
76d90f09f2 | ||
|
|
2f356eaa91 | ||
|
|
e6afb63648 | ||
|
|
ac7f79bd26 | ||
|
|
5f2b73db9d | ||
|
|
1a616146d0 | ||
|
|
1e74e1b445 | ||
|
|
91d64e63e4 |
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.
|
and attach comments to the lines that you think would benefit from some clarification.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
This pull request...
|
This pull request... <!-- do not forget to write here! -->
|
||||||
|
|
||||||
<!-- Example:
|
<!-- Example:
|
||||||
This pull request allows us to warp through time and space ten times faster than before by
|
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.
|
engage, use, and disengage the warp drive when travelling between galaxies.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<!-- Closes: #... -->
|
<!-- Closes #... -->
|
||||||
<!-- Fixes: #... -->
|
<!-- Fixes #... -->
|
||||||
<!-- Uncomment the above line(s) if your pull request fixes an issue or closes another pull request
|
<!-- 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`. -->
|
by superseding it. Replace `#...` with the issue/pr number, such as `#123`. -->
|
||||||
|
|
||||||
@@ -73,6 +73,7 @@ Notes on these requirements:
|
|||||||
main, it's difficult to get out cleanly, so put on your best dress, smile for the cameras!
|
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
|
[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
|
[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
|
[c1pc]: https://forgejo.ellis.link/continuwuation/continuwuity/src/branch/main/CONTRIBUTING.md#pre-commit-checks
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ repos:
|
|||||||
- pre-push
|
- pre-push
|
||||||
|
|
||||||
- repo: https://code.forgejo.org/forgejo/runner
|
- repo: https://code.forgejo.org/forgejo/runner
|
||||||
rev: v13.2.1
|
rev: v13.3.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: forgejo-runner-validate
|
- id: forgejo-runner-validate
|
||||||
stages:
|
stages:
|
||||||
|
|||||||
Generated
+119
-575
File diff suppressed because it is too large.
Load diff
+2
-12
@@ -166,15 +166,6 @@ features = [
|
|||||||
"form",
|
"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]
|
[workspace.dependencies.serde]
|
||||||
version = "1.0.229"
|
version = "1.0.229"
|
||||||
default-features = false
|
default-features = false
|
||||||
@@ -422,10 +413,9 @@ default-features = false
|
|||||||
version = "0.11.0"
|
version = "0.11.0"
|
||||||
default-features = false
|
default-features = false
|
||||||
|
|
||||||
[workspace.dependencies.openidconnect]
|
[workspace.dependencies.openid]
|
||||||
version = "4.1.0"
|
version = "0.26.0"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["reqwest"]
|
|
||||||
|
|
||||||
# optional opentelemetry, performance measurements, flamegraphs, etc for performance measurements and monitoring
|
# optional opentelemetry, performance measurements, flamegraphs, etc for performance measurements and monitoring
|
||||||
[workspace.dependencies.opentelemetry]
|
[workspace.dependencies.opentelemetry]
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
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.
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Fixed read receipts for all but one of a user's threads not being sent over federation. Contributed by @eleboucher.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
The `element_hacks` build feature, which has done almost nothing for many versions, has been removed completely. Contributed by @ginger.
|
||||||
@@ -2675,48 +2675,6 @@
|
|||||||
# env: CONTINUWUITY_OAUTH__OIDC__PROFILE_KEY_IMPORT_MODE
|
# env: CONTINUWUITY_OAUTH__OIDC__PROFILE_KEY_IMPORT_MODE
|
||||||
#profile_key_import_mode = "on_registration"
|
#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 = []
|
|
||||||
|
|
||||||
[global.experiments]
|
[global.experiments]
|
||||||
# Continuwuity's experimental features are frequently updated.
|
# Continuwuity's experimental features are frequently updated.
|
||||||
# If you got this configuration via a package manager, chances are it's outdated.
|
# If you got this configuration via a package manager, chances are it's outdated.
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ look like this:
|
|||||||
RUSTFLAGS="--cfg tokio_unstable" cargo +nightly build \
|
RUSTFLAGS="--cfg tokio_unstable" cargo +nightly build \
|
||||||
--release \
|
--release \
|
||||||
--no-default-features \
|
--no-default-features \
|
||||||
--features=systemd,element_hacks,gzip_compression,brotli_compression,zstd_compression,tokio_console
|
--features=systemd,gzip_compression,brotli_compression,zstd_compression,tokio_console
|
||||||
```
|
```
|
||||||
|
|
||||||
You will also need to enable the `tokio_console` config option in Continuwuity
|
You will also need to enable the `tokio_console` config option in Continuwuity
|
||||||
|
|||||||
+1
-1
@@ -146,7 +146,7 @@ cargo clippy \
|
|||||||
--locked \
|
--locked \
|
||||||
--profile test \
|
--profile test \
|
||||||
--no-default-features \
|
--no-default-features \
|
||||||
--features=console,systemd,element_hacks,direct_tls,perf_measurements,brotli_compression \
|
--features=console,systemd,direct_tls,perf_measurements,brotli_compression \
|
||||||
--color=always \
|
--color=always \
|
||||||
-- \
|
-- \
|
||||||
-D warnings
|
-D warnings
|
||||||
|
|||||||
Generated
+132
-95
@@ -16,35 +16,38 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@emnapi/core": {
|
"node_modules/@emnapi/core": {
|
||||||
"version": "2.0.0-beta.3",
|
"version": "1.11.3",
|
||||||
"resolved": "https://registry.npmjs.org/@emnapi/core/-/core-2.0.0-beta.3.tgz",
|
"resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.11.3.tgz",
|
||||||
"integrity": "sha512-KA+gOBtbifRATmUa/Gpf5C2B2EJ0r4brHUT3XSgACeHREcuiObXH56xd+B3fFsEFbUT04VBEe6MuZiCtMp0tQg==",
|
"integrity": "sha512-zLpS5asjEb7lq8jYLq37N6XKaE41DIexlY1rF/z4/tIl3wo13Sqm28fRyfIsKZD+NZ8mM5RoKkpW/rBcuoSZSg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@emnapi/wasi-threads": "2.2.0",
|
"@emnapi/wasi-threads": "1.2.3",
|
||||||
"tslib": "^2.4.0"
|
"tslib": "^2.4.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@emnapi/runtime": {
|
"node_modules/@emnapi/runtime": {
|
||||||
"version": "2.0.0-beta.3",
|
"version": "1.11.3",
|
||||||
"resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-2.0.0-beta.3.tgz",
|
"resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.11.3.tgz",
|
||||||
"integrity": "sha512-ayb/PyyLzpwRyFVxeC0uoEHu59QlB1iWGcGsOpXQcaB/Dc+uGfBmNmpCHp3HmTT0t8lSsMmg3j7+tdJW/TlHjQ==",
|
"integrity": "sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"tslib": "^2.4.0"
|
"tslib": "^2.4.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@emnapi/wasi-threads": {
|
"node_modules/@emnapi/wasi-threads": {
|
||||||
"version": "2.2.0",
|
"version": "1.2.3",
|
||||||
"resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-2.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.3.tgz",
|
||||||
"integrity": "sha512-JP7OYH38Q7+pyTAe14raZHLQIK7BDKbdwji+Xi3pcd/6QkJYQH3SX4wu6EplGrGJWRepoNzedfm0G3B9Z4e9Rw==",
|
"integrity": "sha512-ELEBe8PsLvvJ6QMr0zLt8ffvOHW/dc1m3CEzNMg7aJUv3bMaoDtw2TXyDAwkYBuroxxuHEwhRTLJSe5sya547g==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"tslib": "^2.4.0"
|
"tslib": "^2.4.0"
|
||||||
}
|
}
|
||||||
@@ -128,13 +131,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@rsbuild/core": {
|
"node_modules/@rsbuild/core": {
|
||||||
"version": "2.3.6",
|
"version": "2.3.7",
|
||||||
"resolved": "https://registry.npmjs.org/@rsbuild/core/-/core-2.3.6.tgz",
|
"resolved": "https://registry.npmjs.org/@rsbuild/core/-/core-2.3.7.tgz",
|
||||||
"integrity": "sha512-IVuWh/0DO6XT8075eCAzxWIcVGA7c4xKggf/VEePq3yXqEiU302n6OVGD7uCxQwPaB4R9ViX4cAqalcQV/sxKQ==",
|
"integrity": "sha512-IvJZFEeVGcjeSiSHfMlRxJbyL5+xLGcvkNmD34wmIXo85n0va6b8cnqShmprdUKjvXyzE4dPPB9trRunaUY+mA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@rspack/core": "~2.3.4",
|
"@rspack/core": "~2.3.5",
|
||||||
"@swc/helpers": "^0.5.24"
|
"@swc/helpers": "^0.5.24"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
@@ -172,32 +175,32 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding": {
|
"node_modules/@rspack/binding": {
|
||||||
"version": "2.3.4",
|
"version": "2.3.5",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding/-/binding-2.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding/-/binding-2.3.5.tgz",
|
||||||
"integrity": "sha512-wSOT16LVITL/IKeIiLXgN5Q5jZIDqnQ7Gmk+wzKOSZ6OHYNfEBXAKhSJuYtCBq8ovJuGl8cJjdqatAlHE5XKIA==",
|
"integrity": "sha512-W3x7zw5d/mIH9WhWt4pO9RKYURoqgdUxeLSV5IhDCajnhXdRr7R59u5S2j5ZXzSk3eMGUC0PenfKIIdW7t0ufQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@rspack/binding-darwin-arm64": "2.3.4",
|
"@rspack/binding-darwin-arm64": "2.3.5",
|
||||||
"@rspack/binding-darwin-x64": "2.3.4",
|
"@rspack/binding-darwin-x64": "2.3.5",
|
||||||
"@rspack/binding-linux-arm64-gnu": "2.3.4",
|
"@rspack/binding-linux-arm64-gnu": "2.3.5",
|
||||||
"@rspack/binding-linux-arm64-musl": "2.3.4",
|
"@rspack/binding-linux-arm64-musl": "2.3.5",
|
||||||
"@rspack/binding-linux-ppc64-gnu": "2.3.4",
|
"@rspack/binding-linux-ppc64-gnu": "2.3.5",
|
||||||
"@rspack/binding-linux-riscv64-gnu": "2.3.4",
|
"@rspack/binding-linux-riscv64-gnu": "2.3.5",
|
||||||
"@rspack/binding-linux-riscv64-musl": "2.3.4",
|
"@rspack/binding-linux-riscv64-musl": "2.3.5",
|
||||||
"@rspack/binding-linux-s390x-gnu": "2.3.4",
|
"@rspack/binding-linux-s390x-gnu": "2.3.5",
|
||||||
"@rspack/binding-linux-x64-gnu": "2.3.4",
|
"@rspack/binding-linux-x64-gnu": "2.3.5",
|
||||||
"@rspack/binding-linux-x64-musl": "2.3.4",
|
"@rspack/binding-linux-x64-musl": "2.3.5",
|
||||||
"@rspack/binding-wasm32-wasi": "2.3.4",
|
"@rspack/binding-wasm32-wasi": "2.3.5",
|
||||||
"@rspack/binding-win32-arm64-msvc": "2.3.4",
|
"@rspack/binding-win32-arm64-msvc": "2.3.5",
|
||||||
"@rspack/binding-win32-ia32-msvc": "2.3.4",
|
"@rspack/binding-win32-ia32-msvc": "2.3.5",
|
||||||
"@rspack/binding-win32-x64-msvc": "2.3.4"
|
"@rspack/binding-win32-x64-msvc": "2.3.5"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding-darwin-arm64": {
|
"node_modules/@rspack/binding-darwin-arm64": {
|
||||||
"version": "2.3.4",
|
"version": "2.3.5",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-darwin-arm64/-/binding-darwin-arm64-2.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-darwin-arm64/-/binding-darwin-arm64-2.3.5.tgz",
|
||||||
"integrity": "sha512-eBD71fbmoJKnxcHD03bukbAIOP5r7nD0Ehs+mUrUQlZ6N53EhuJsTeJ1oYdg5L4GoSeQ+KecCqME81Nm0COLrA==",
|
"integrity": "sha512-A5XnBdSoJvcYV4t2Y+XJiCF0UZ42nOKE2D0ZlegfErGhzlQG1t3hDOzskSB2fPD3z+w5QeREoclqQ0zFOZyBpw==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@@ -209,9 +212,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding-darwin-x64": {
|
"node_modules/@rspack/binding-darwin-x64": {
|
||||||
"version": "2.3.4",
|
"version": "2.3.5",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-darwin-x64/-/binding-darwin-x64-2.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-darwin-x64/-/binding-darwin-x64-2.3.5.tgz",
|
||||||
"integrity": "sha512-CqdfzTLPVFQCniOy/GDVWbg+rqg31qfdzbFf8NYCzdDkCQg+p15hU2HsckD/1sLsaNB8Y55EjGz4ZyGDny0cHg==",
|
"integrity": "sha512-iZrweqTIj2cM4f0ADRj6FXn9a0FOpD1Mx/++zrsbrQzmnY0c8wmfpvZ5xA5Zfcq9O6nuUBS6GnhkmoFTgviHwQ==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@@ -223,9 +226,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding-linux-arm64-gnu": {
|
"node_modules/@rspack/binding-linux-arm64-gnu": {
|
||||||
"version": "2.3.4",
|
"version": "2.3.5",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-2.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-2.3.5.tgz",
|
||||||
"integrity": "sha512-T/Y1FYiSegcNc+oHuDOLRGIcc+eSdBnfbS70d51EWQj4+0TG/tlfuqFKeAIL3mnKUV5lDLaTz3vsoD0Sws5Fxw==",
|
"integrity": "sha512-aWE9V0ZhmclKsJNuO37cxUMLtXMjhLtFzrWDWC82mksUX6qM2rzOpPuye9i/c9NGqyrIH7EFQre8bskJvNHGuQ==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@@ -240,9 +243,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding-linux-arm64-musl": {
|
"node_modules/@rspack/binding-linux-arm64-musl": {
|
||||||
"version": "2.3.4",
|
"version": "2.3.5",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-arm64-musl/-/binding-linux-arm64-musl-2.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-arm64-musl/-/binding-linux-arm64-musl-2.3.5.tgz",
|
||||||
"integrity": "sha512-WZHCzZ532UfXFXNU8XyM8jb+I6wddegbs/7IXsyw7xiPwwZX1D/M6iKFVpBYdvKcupUM8bS8Uw2REirR/cERVw==",
|
"integrity": "sha512-I8ENTXdv7Th/OHEYhL7uu3B7DA9r1oTWSifkGHJtuT1XJ0KDsxoA6ORpYz1R2qIs87l+8+5QUnRH7iWyZrnroA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@@ -257,9 +260,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding-linux-ppc64-gnu": {
|
"node_modules/@rspack/binding-linux-ppc64-gnu": {
|
||||||
"version": "2.3.4",
|
"version": "2.3.5",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-2.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-2.3.5.tgz",
|
||||||
"integrity": "sha512-WeizqeI6HIh7Ax9w2tlmpTtipJWxXcdgt3QqI3N9LOixymlMD5yMBMZNPqwZ6cHXT9gOQ69SvPcVgMwxsdmceQ==",
|
"integrity": "sha512-ps5do0cKf4aTBWd+LHqvwm8Gdn7J/gvzmx9pWJhAIThvzii45wJREFjGOzJNxdQl+pzKq8JFuzbShNskCN9k2w==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"ppc64"
|
"ppc64"
|
||||||
],
|
],
|
||||||
@@ -274,9 +277,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding-linux-riscv64-gnu": {
|
"node_modules/@rspack/binding-linux-riscv64-gnu": {
|
||||||
"version": "2.3.4",
|
"version": "2.3.5",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-riscv64-gnu/-/binding-linux-riscv64-gnu-2.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-riscv64-gnu/-/binding-linux-riscv64-gnu-2.3.5.tgz",
|
||||||
"integrity": "sha512-h+001Vbq8LyGwPMNkeRWidPOVKwlAbwNPskY3CjNlSw3euHkVchfhM3uo6+1h0GyTtb3rzsWqsfm1kar7m/tiQ==",
|
"integrity": "sha512-3XXIEMS4SSr1/9wIAGgPT1oj1SzhnlejAG5xeVbGJR5y6iFp/oFKYzUPqyuuzZCkWph2/hJ+Q16sa+BJn1YIkg==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"riscv64"
|
"riscv64"
|
||||||
],
|
],
|
||||||
@@ -291,9 +294,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding-linux-riscv64-musl": {
|
"node_modules/@rspack/binding-linux-riscv64-musl": {
|
||||||
"version": "2.3.4",
|
"version": "2.3.5",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-riscv64-musl/-/binding-linux-riscv64-musl-2.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-riscv64-musl/-/binding-linux-riscv64-musl-2.3.5.tgz",
|
||||||
"integrity": "sha512-S1rlaCnNVG5s4WZ9odLsqN3ySh5TEdNTLXWapEK8x3iQl56aLtdvqXTfbJWHWnYLJuS7M1WqnQGdJNdjy2NDsA==",
|
"integrity": "sha512-z2DbQNcLbUEY9OvUa3gahsHey+dW4acLc9d3QlyJm7TJE//rL9C/XBk4kETvCgtdhqrwBSfWrZfislBPKODjvA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"riscv64"
|
"riscv64"
|
||||||
],
|
],
|
||||||
@@ -308,9 +311,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding-linux-s390x-gnu": {
|
"node_modules/@rspack/binding-linux-s390x-gnu": {
|
||||||
"version": "2.3.4",
|
"version": "2.3.5",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-2.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-2.3.5.tgz",
|
||||||
"integrity": "sha512-0SkgGrgulVMam3xel5dMNKQ+U7BEpCczhF1avGT1DzDVIbMfIOsbb32gApQNSz0E7RfAQ/Pa5eWiA9oyRq7ZMQ==",
|
"integrity": "sha512-n2UudDpzt9G2AOmycVS7uWRMcNMd2k4ubU4b4SX3FfU/uT6mfSNzuwhBhCi0RSZQAGBU0ombJ+sqw8vKXjGGbw==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"s390x"
|
"s390x"
|
||||||
],
|
],
|
||||||
@@ -325,9 +328,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding-linux-x64-gnu": {
|
"node_modules/@rspack/binding-linux-x64-gnu": {
|
||||||
"version": "2.3.4",
|
"version": "2.3.5",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-x64-gnu/-/binding-linux-x64-gnu-2.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-x64-gnu/-/binding-linux-x64-gnu-2.3.5.tgz",
|
||||||
"integrity": "sha512-q7E6x3rJJ/9fJyLuRe5+KyEPi23BF/xkAU4xCM5VwLkTf+rVyOkDZfu0qOkxmILjrxllQPV+b/ojBL/ZaIeQPw==",
|
"integrity": "sha512-1sxASGJXg9luaYsFSmAQxSFbUbnMnPA5Mr94yIlLsq4q94sHUIn5YjG1XGcT+cPhUYF9fHkCsKRmQlzrN9fR8A==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@@ -342,9 +345,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding-linux-x64-musl": {
|
"node_modules/@rspack/binding-linux-x64-musl": {
|
||||||
"version": "2.3.4",
|
"version": "2.3.5",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-x64-musl/-/binding-linux-x64-musl-2.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-linux-x64-musl/-/binding-linux-x64-musl-2.3.5.tgz",
|
||||||
"integrity": "sha512-rey4Tyasui/WeMn6KfhH5xyZGOMt+Ny+GDK7nGh9TSz/cb3/bisxqGzpbu6GJK8leDmTUDD5ZdpODexytA5rzQ==",
|
"integrity": "sha512-/S4pe1wAo8CBTs0X8DNKu1ZOJ2vQcnThLBKS2CxOPiuQXI7UfAsJCEABBoa8yCrZANWh63fJ90UwLb/s245Gsw==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@@ -359,9 +362,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding-wasm32-wasi": {
|
"node_modules/@rspack/binding-wasm32-wasi": {
|
||||||
"version": "2.3.4",
|
"version": "2.3.5",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-wasm32-wasi/-/binding-wasm32-wasi-2.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-wasm32-wasi/-/binding-wasm32-wasi-2.3.5.tgz",
|
||||||
"integrity": "sha512-sDt2MSXZrIaMBa6UaEqmXEqebwpTOPAXLdo9CYJ2Fa9FJWP4TCYbn30mbvV38ZC2n5YX411DRbjck+s97CceIg==",
|
"integrity": "sha512-GQnswrv6AyBdDCcTy8dTVhD0JqnvmgewzPz6qnOYWGKxpCY99Bv6FL4jvxI1yh64Uk3ykEfbwhrPnaA8Px4KJA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"wasm32"
|
"wasm32"
|
||||||
],
|
],
|
||||||
@@ -369,15 +372,49 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@emnapi/core": "2.0.0-beta.3",
|
"@emnapi/core": "2.0.0-beta.4",
|
||||||
"@emnapi/runtime": "2.0.0-beta.3",
|
"@emnapi/runtime": "2.0.0-beta.4",
|
||||||
"@napi-rs/wasm-runtime": "1.2.7"
|
"@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": {
|
"node_modules/@rspack/binding-win32-arm64-msvc": {
|
||||||
"version": "2.3.4",
|
"version": "2.3.5",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-2.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-2.3.5.tgz",
|
||||||
"integrity": "sha512-24YC1YSodLAJ8VsMQJmJSHCNvHTqK9JP5hj50T50WE8lCHNsNl/rIYXO9V0VlCYT/HshE6EHHzAeKdahiEOtcw==",
|
"integrity": "sha512-XVKu3Zs5KGr+P5Seh6NtSNU0UQ1GSgSDFANQRZlT1uFZ1NpBCX+9NB8FVZB0hBBoBKI1kU4b0Cr6Df1Xx0K4nQ==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@@ -389,9 +426,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding-win32-ia32-msvc": {
|
"node_modules/@rspack/binding-win32-ia32-msvc": {
|
||||||
"version": "2.3.4",
|
"version": "2.3.5",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-win32-ia32-msvc/-/binding-win32-ia32-msvc-2.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-win32-ia32-msvc/-/binding-win32-ia32-msvc-2.3.5.tgz",
|
||||||
"integrity": "sha512-xmUNu6kgV9lLEkRP1Zb+t6i1Z1ZMEWXmLlMalPx8tHqndz2RflNMBBx6kjB2nAPQBIZgWufwm7dVGS0HKomCmw==",
|
"integrity": "sha512-ejCqSuctPcOev2dyi0ayZyfIUY3fJdYHYvrTfSVrrGC19TspuRATXu+RLyu3xvB6TrQF3+JEF4KeG4/ZeWuXOg==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"ia32"
|
"ia32"
|
||||||
],
|
],
|
||||||
@@ -403,9 +440,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/binding-win32-x64-msvc": {
|
"node_modules/@rspack/binding-win32-x64-msvc": {
|
||||||
"version": "2.3.4",
|
"version": "2.3.5",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/binding-win32-x64-msvc/-/binding-win32-x64-msvc-2.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/binding-win32-x64-msvc/-/binding-win32-x64-msvc-2.3.5.tgz",
|
||||||
"integrity": "sha512-WY+AkJqpbLtLEZiG1fE7CVJZ54y0qHeCiVmLxGBsh4OOGIDCs6v2Ub5COcPrYVzGJFGyeHUS29dV7JAs93qIHw==",
|
"integrity": "sha512-IPvkjM3xAwL1z2N4Jp/GBcZUme703uDy5vrP1IMtXJEl/EOLLfwl7cRb4sSzdeOYGDDHs5dPYDcpgP5eRSRauA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@@ -417,13 +454,13 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rspack/core": {
|
"node_modules/@rspack/core": {
|
||||||
"version": "2.3.4",
|
"version": "2.3.5",
|
||||||
"resolved": "https://registry.npmjs.org/@rspack/core/-/core-2.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspack/core/-/core-2.3.5.tgz",
|
||||||
"integrity": "sha512-T8HGkIjPVDlGlIN8st/ICe8Gfixq8te75g/8crSdNSf8F+6884sBcKNky0CRdfPxao1C5SXV+Vjv1XJTjyu83w==",
|
"integrity": "sha512-4TG6zGTemEU/FU7bymDgeFOO7CRdd7ucn0CmXo+3cG6EhYmY5+hpAFYBRgxDbDuL4Bwo/s5GsgUvZuI7rLqVbQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@rspack/binding": "2.3.4"
|
"@rspack/binding": "2.3.5"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^20.19.0 || >=22.12.0"
|
"node": "^20.19.0 || >=22.12.0"
|
||||||
@@ -458,22 +495,22 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@rspress/core": {
|
"node_modules/@rspress/core": {
|
||||||
"version": "2.1.5",
|
"version": "2.1.6",
|
||||||
"resolved": "https://registry.npmjs.org/@rspress/core/-/core-2.1.5.tgz",
|
"resolved": "https://registry.npmjs.org/@rspress/core/-/core-2.1.6.tgz",
|
||||||
"integrity": "sha512-kzTqrfJ4UiW+RLLHLunoW/rET5Vjb6Qz4YjhEhiWEp4HYM+KxLVhfyYB5aL8af9+mdnwiTaqlu1s+BZGrMD2zw==",
|
"integrity": "sha512-a+CBJcslana9Zmr6j2o3RP6O19y+rcyfa8jeDToC1b29e/RGiD+xpAQJF2eBvnjNUHouXARTaFa7pE1myyV0Rg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@mdx-js/mdx": "^3.1.1",
|
"@mdx-js/mdx": "^3.1.1",
|
||||||
"@mdx-js/react": "^3.1.1",
|
"@mdx-js/react": "^3.1.1",
|
||||||
"@rsbuild/core": "^2.3.3",
|
"@rsbuild/core": "^2.3.7",
|
||||||
"@rsbuild/plugin-react": "~2.1.1",
|
"@rsbuild/plugin-react": "~2.1.1",
|
||||||
"@rspress/shared": "2.1.5",
|
"@rspress/shared": "2.1.6",
|
||||||
"@shikijs/rehype": "^4.2.0",
|
"@shikijs/rehype": "^4.2.0",
|
||||||
"@shikijs/transformers": "^4.2.0",
|
"@shikijs/transformers": "^4.2.0",
|
||||||
"@types/mdast": "^4.0.4",
|
"@types/mdast": "^4.0.4",
|
||||||
"@types/react": "^19.3.0",
|
"@types/react": "^19.3.3",
|
||||||
"@unhead/react": "^2.1.18",
|
"@unhead/react": "^2.1.19",
|
||||||
"body-scroll-lock": "4.0.0-beta.0",
|
"body-scroll-lock": "4.0.0-beta.0",
|
||||||
"clsx": "2.1.1",
|
"clsx": "2.1.1",
|
||||||
"copy-to-clipboard": "^3.3.3",
|
"copy-to-clipboard": "^3.3.3",
|
||||||
@@ -490,7 +527,7 @@
|
|||||||
"react-dom": "^19.3.1",
|
"react-dom": "^19.3.1",
|
||||||
"react-lazy-with-preload": "^2.2.1",
|
"react-lazy-with-preload": "^2.2.1",
|
||||||
"react-render-to-markdown": "19.2.0",
|
"react-render-to-markdown": "19.2.0",
|
||||||
"react-router-dom": "^7.18.6",
|
"react-router-dom": "^7.18.7",
|
||||||
"rehype-external-links": "^3.0.0",
|
"rehype-external-links": "^3.0.0",
|
||||||
"rehype-raw": "^7.0.0",
|
"rehype-raw": "^7.0.0",
|
||||||
"remark-cjk-friendly": "^2.3.4",
|
"remark-cjk-friendly": "^2.3.4",
|
||||||
@@ -514,9 +551,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@rspress/plugin-client-redirects": {
|
"node_modules/@rspress/plugin-client-redirects": {
|
||||||
"version": "2.1.5",
|
"version": "2.1.6",
|
||||||
"resolved": "https://registry.npmjs.org/@rspress/plugin-client-redirects/-/plugin-client-redirects-2.1.5.tgz",
|
"resolved": "https://registry.npmjs.org/@rspress/plugin-client-redirects/-/plugin-client-redirects-2.1.6.tgz",
|
||||||
"integrity": "sha512-vqAi7ynOgVsuwJi7cXwWEF5UgoNhXqGOyBfQubeZHZKWRtdNHRU42P9rG9DZLTss2dZUiDKlVrM2/vNY40t5hw==",
|
"integrity": "sha512-lnSIA3oD44PZa0o0r4gvTBBGWeImD3T7D28FRJlzCdrWQX3kOHpyhxd9fCcK9mE32DYItlu/ipsmpSozmDN9ZA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -527,15 +564,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@rspress/shared": {
|
"node_modules/@rspress/shared": {
|
||||||
"version": "2.1.5",
|
"version": "2.1.6",
|
||||||
"resolved": "https://registry.npmjs.org/@rspress/shared/-/shared-2.1.5.tgz",
|
"resolved": "https://registry.npmjs.org/@rspress/shared/-/shared-2.1.6.tgz",
|
||||||
"integrity": "sha512-XXxegxRZ7VPADS2veN9FTNmmLlA65ieydKH0tOhOZbMJC4OJpKbr/d/JS2jxxAO4u+ZmZxbDyEEir83NQHLKIw==",
|
"integrity": "sha512-ecHmNItlMsMU5FEf0CeBKZa4XNCE5fpwCED+1/lmcwIhozyBvd4j4Ook/8IyTT3UqgruJDZ2DwQqfyvCW7zmLg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@rsbuild/core": "^2.3.3",
|
"@rsbuild/core": "^2.3.7",
|
||||||
"@shikijs/rehype": "^4.2.0",
|
"@shikijs/rehype": "^4.2.0",
|
||||||
"@types/react": "^19.3.0",
|
"@types/react": "^19.3.3",
|
||||||
"mdast-util-mdx-jsx": "^3.2.2",
|
"mdast-util-mdx-jsx": "^3.2.2",
|
||||||
"unified": "^11.0.5"
|
"unified": "^11.0.5"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,9 +21,6 @@ brotli_compression = [
|
|||||||
"conduwuit-service/brotli_compression",
|
"conduwuit-service/brotli_compression",
|
||||||
"reqwest/brotli",
|
"reqwest/brotli",
|
||||||
]
|
]
|
||||||
element_hacks = [
|
|
||||||
"conduwuit-service/element_hacks",
|
|
||||||
]
|
|
||||||
gzip_compression = [
|
gzip_compression = [
|
||||||
"conduwuit-core/gzip_compression",
|
"conduwuit-core/gzip_compression",
|
||||||
"conduwuit-service/gzip_compression",
|
"conduwuit-service/gzip_compression",
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ pub(crate) async fn authorization_server_metadata(services: &Services) -> Value
|
|||||||
"authorization_endpoint": endpoint_base.join(AUTH_CODE_PATH).unwrap(),
|
"authorization_endpoint": endpoint_base.join(AUTH_CODE_PATH).unwrap(),
|
||||||
"code_challenge_methods_supported": ["S256"],
|
"code_challenge_methods_supported": ["S256"],
|
||||||
"device_authorization_endpoint": endpoint_base.join(DEVICE_AUTHORIZATION_PATH).unwrap(),
|
"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", "client_credentials"],
|
"grant_types_supported": ["authorization_code", "refresh_token", "urn:ietf:params:oauth:grant-type:device_code"],
|
||||||
"issuer": services.config.get_client_domain(),
|
"issuer": services.config.get_client_domain(),
|
||||||
"jwks_uri": endpoint_base.join(JWKS_URI_PATH).unwrap(),
|
"jwks_uri": endpoint_base.join(JWKS_URI_PATH).unwrap(),
|
||||||
"prompt_values_supported": prompt_values_supported,
|
"prompt_values_supported": prompt_values_supported,
|
||||||
|
|||||||
+1
-25
@@ -47,7 +47,6 @@ pub(crate) enum ClientIdentity {
|
|||||||
sender_device: Option<OwnedDeviceId>,
|
sender_device: Option<OwnedDeviceId>,
|
||||||
appservice_info: Box<RegistrationInfo>,
|
appservice_info: Box<RegistrationInfo>,
|
||||||
},
|
},
|
||||||
StaticClient,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ClientIdentity {
|
impl ClientIdentity {
|
||||||
@@ -55,7 +54,6 @@ impl ClientIdentity {
|
|||||||
match self {
|
match self {
|
||||||
| Self::User { sender_user, .. } | Self::Appservice { sender_user, .. } =>
|
| Self::User { sender_user, .. } | Self::Appservice { sender_user, .. } =>
|
||||||
Some(sender_user),
|
Some(sender_user),
|
||||||
| Self::StaticClient => None,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,8 +61,6 @@ impl ClientIdentity {
|
|||||||
match self {
|
match self {
|
||||||
| Self::User { sender_user, .. } | Self::Appservice { sender_user, .. } =>
|
| Self::User { sender_user, .. } | Self::Appservice { sender_user, .. } =>
|
||||||
Ok(sender_user),
|
Ok(sender_user),
|
||||||
| Self::StaticClient =>
|
|
||||||
Err!(Request(Forbidden("Static clients cannot use this endpoint."))),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +68,6 @@ impl ClientIdentity {
|
|||||||
match self {
|
match self {
|
||||||
| Self::User { sender_device, .. } => Some(sender_device),
|
| Self::User { sender_device, .. } => Some(sender_device),
|
||||||
| Self::Appservice { sender_device, .. } => sender_device.as_deref(),
|
| Self::Appservice { sender_device, .. } => sender_device.as_deref(),
|
||||||
| Self::StaticClient => None,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,14 +77,12 @@ impl ClientIdentity {
|
|||||||
| Self::Appservice { sender_device: Some(sender_device), .. } => Ok(sender_device),
|
| Self::Appservice { sender_device: Some(sender_device), .. } => Ok(sender_device),
|
||||||
| Self::Appservice { sender_device: None, .. } =>
|
| Self::Appservice { sender_device: None, .. } =>
|
||||||
Err!(Request(Forbidden("Appservices must masquerade to use this endpoint."))),
|
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> {
|
pub(crate) fn appservice_info(&self) -> Option<&RegistrationInfo> {
|
||||||
match self {
|
match self {
|
||||||
| Self::User { .. } | Self::StaticClient => None,
|
| Self::User { .. } => None,
|
||||||
| Self::Appservice { appservice_info, .. } => Some(appservice_info),
|
| Self::Appservice { appservice_info, .. } => Some(appservice_info),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -432,23 +425,6 @@ async fn check_access_token(
|
|||||||
sender_device,
|
sender_device,
|
||||||
appservice_info: Box::new(appservice_info),
|
appservice_info: Box::new(appservice_info),
|
||||||
})
|
})
|
||||||
} else if let Some(session) = services.oauth.get_client_credentials_session(token) {
|
|
||||||
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 if services.users.is_previous_token(token).await {
|
} else if services.users.is_previous_token(token).await {
|
||||||
// Return a soft-logout for previous tokens. This is necessary
|
// Return a soft-logout for previous tokens. This is necessary
|
||||||
// to make token refreshing idempotent.
|
// to make token refreshing idempotent.
|
||||||
|
|||||||
+1
-1
@@ -117,7 +117,7 @@ prometheus.workspace = true
|
|||||||
lock_api.workspace = true
|
lock_api.workspace = true
|
||||||
hyper-util.workspace = true
|
hyper-util.workspace = true
|
||||||
resolvematrix.workspace = true
|
resolvematrix.workspace = true
|
||||||
openidconnect.workspace = true
|
openid.workspace = true
|
||||||
libmimalloc-sys.optional = true
|
libmimalloc-sys.optional = true
|
||||||
libmimalloc-sys.workspace = true
|
libmimalloc-sys.workspace = true
|
||||||
mimalloc.optional = true
|
mimalloc.optional = true
|
||||||
|
|||||||
@@ -346,15 +346,6 @@ 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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-72
@@ -23,13 +23,11 @@ use figment::providers::{Env, Format, Toml};
|
|||||||
pub use figment::{Figment, value::Value as FigmentValue};
|
pub use figment::{Figment, value::Value as FigmentValue};
|
||||||
use governor::{DefaultKeyedRateLimiter, Quota, RateLimiter};
|
use governor::{DefaultKeyedRateLimiter, Quota, RateLimiter};
|
||||||
use lettre::message::Mailbox;
|
use lettre::message::Mailbox;
|
||||||
use openidconnect::{Audience, ClientId, ClientSecret, Scope};
|
|
||||||
use regex::RegexSet;
|
use regex::RegexSet;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
OwnedRoomId, OwnedRoomOrAliasId, OwnedServerName, OwnedServerSigningKeyId, OwnedUserId,
|
OwnedRoomId, OwnedRoomOrAliasId, OwnedServerName, OwnedServerSigningKeyId, OwnedUserId,
|
||||||
RoomVersionId, ServerName,
|
RoomVersionId, ServerName,
|
||||||
api::{
|
api::{
|
||||||
OAuthClientScope,
|
|
||||||
client::{discovery::discover_support::ContactRole, rtc::RtcTransport},
|
client::{discovery::discover_support::ContactRole, rtc::RtcTransport},
|
||||||
federation::discovery::OldVerifyKey,
|
federation::discovery::OldVerifyKey,
|
||||||
},
|
},
|
||||||
@@ -2751,12 +2749,7 @@ pub struct OauthConfig {
|
|||||||
compatibility_mode: OAuthMode,
|
compatibility_mode: OAuthMode,
|
||||||
|
|
||||||
/// display: hidden
|
/// display: hidden
|
||||||
#[serde(default)]
|
|
||||||
pub oidc: Option<OidcConfig>,
|
pub oidc: Option<OidcConfig>,
|
||||||
|
|
||||||
/// display: hidden
|
|
||||||
#[serde(default)]
|
|
||||||
pub clients: HashMap<String, OAuthClient>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl OauthConfig {
|
impl OauthConfig {
|
||||||
@@ -2808,15 +2801,15 @@ pub struct OidcConfig {
|
|||||||
/// automatically fetch the identity provider's metadata from this URL.
|
/// automatically fetch the identity provider's metadata from this URL.
|
||||||
/// Generally you should set this to the base domain your identity provider
|
/// Generally you should set this to the base domain your identity provider
|
||||||
/// runs on.
|
/// runs on.
|
||||||
pub discovery_url: String,
|
pub discovery_url: Url,
|
||||||
|
|
||||||
/// The OAuth client ID for Continuwuity to use when communicating with the
|
/// The OAuth client ID for Continuwuity to use when communicating with the
|
||||||
/// identity provider.
|
/// identity provider.
|
||||||
pub client_id: ClientId,
|
pub client_id: String,
|
||||||
|
|
||||||
/// The OAuth client secret for Continuwuity to use when communicating with
|
/// The OAuth client secret for Continuwuity to use when communicating with
|
||||||
/// the identity provider.
|
/// the identity provider.
|
||||||
pub client_secret: Option<ClientSecret>,
|
pub client_secret: Option<String>,
|
||||||
|
|
||||||
/// A path to a file which Continuwuity will read the client secret from.
|
/// A path to a file which Continuwuity will read the client secret from.
|
||||||
/// If this option is set, it will override `client_secret`.
|
/// If this option is set, it will override `client_secret`.
|
||||||
@@ -2832,19 +2825,7 @@ pub struct OidcConfig {
|
|||||||
///
|
///
|
||||||
/// default: ["profile"]
|
/// default: ["profile"]
|
||||||
#[serde(default = "default_additional_scopes")]
|
#[serde(default = "default_additional_scopes")]
|
||||||
pub additional_scopes: Vec<Scope>,
|
pub additional_scopes: Vec<String>,
|
||||||
|
|
||||||
/// 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
|
/// The name of the identity provider. If this is set, the login page's
|
||||||
/// button reads "Continue with <name>" instead of just "Continue".
|
/// button reads "Continue with <name>" instead of just "Continue".
|
||||||
@@ -2998,54 +2979,6 @@ impl<'de, K: Hash + Eq + Clone> Deserialize<'de> for PerMinuteRatelimiter<K> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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] = &[
|
const DEPRECATED_KEYS: &[&str] = &[
|
||||||
"allow_check_for_updates",
|
"allow_check_for_updates",
|
||||||
"allow_moderators_to_view_redacted_content",
|
"allow_moderators_to_view_redacted_content",
|
||||||
@@ -3498,7 +3431,7 @@ fn default_unauthenticated_request_ratelimit<K: Hash + Eq + Clone>() -> PerMinut
|
|||||||
PerMinuteRatelimiter::new(Quota::per_minute(30.try_into().unwrap()))
|
PerMinuteRatelimiter::new(Quota::per_minute(30.try_into().unwrap()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_additional_scopes() -> Vec<Scope> { vec![Scope::new("profile".to_owned())] }
|
fn default_additional_scopes() -> Vec<String> { vec!["profile".to_owned()] }
|
||||||
|
|
||||||
// NOTE: This must be declared *after* every config struct in this file. The
|
// NOTE: This must be declared *after* every config struct in this file. The
|
||||||
// example config generator writes sections in macro expansion order, and the
|
// example config generator writes sections in macro expansion order, and the
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ default = [
|
|||||||
standard = [
|
standard = [
|
||||||
"brotli_compression",
|
"brotli_compression",
|
||||||
"direct_tls",
|
"direct_tls",
|
||||||
"element_hacks",
|
|
||||||
"gzip_compression",
|
"gzip_compression",
|
||||||
"io_uring",
|
"io_uring",
|
||||||
"jemalloc_conf",
|
"jemalloc_conf",
|
||||||
@@ -86,10 +85,6 @@ console = [
|
|||||||
direct_tls = [
|
direct_tls = [
|
||||||
"conduwuit-router/direct_tls"
|
"conduwuit-router/direct_tls"
|
||||||
]
|
]
|
||||||
element_hacks = [
|
|
||||||
"conduwuit-service/element_hacks",
|
|
||||||
"conduwuit-router/element_hacks",
|
|
||||||
]
|
|
||||||
gzip_compression = [
|
gzip_compression = [
|
||||||
"conduwuit-core/gzip_compression",
|
"conduwuit-core/gzip_compression",
|
||||||
"conduwuit-router/gzip_compression",
|
"conduwuit-router/gzip_compression",
|
||||||
|
|||||||
@@ -27,9 +27,6 @@ direct_tls = [
|
|||||||
"axum-server/tls-rustls-no-provider",
|
"axum-server/tls-rustls-no-provider",
|
||||||
"dep:axum-server-dual-protocol",
|
"dep:axum-server-dual-protocol",
|
||||||
]
|
]
|
||||||
element_hacks = [
|
|
||||||
"conduwuit-api/element_hacks",
|
|
||||||
]
|
|
||||||
gzip_compression = [
|
gzip_compression = [
|
||||||
"conduwuit-admin/gzip_compression",
|
"conduwuit-admin/gzip_compression",
|
||||||
"conduwuit-api/gzip_compression",
|
"conduwuit-api/gzip_compression",
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ console = [
|
|||||||
"dep:rustyline-async",
|
"dep:rustyline-async",
|
||||||
"dep:termimad",
|
"dep:termimad",
|
||||||
]
|
]
|
||||||
element_hacks = []
|
|
||||||
gzip_compression = [
|
gzip_compression = [
|
||||||
"conduwuit-core/gzip_compression",
|
"conduwuit-core/gzip_compression",
|
||||||
"reqwest/gzip",
|
"reqwest/gzip",
|
||||||
@@ -131,10 +130,7 @@ yansi.workspace = true
|
|||||||
lettre.workspace = true
|
lettre.workspace = true
|
||||||
resolvematrix.workspace = true
|
resolvematrix.workspace = true
|
||||||
serde_urlencoded.workspace = true
|
serde_urlencoded.workspace = true
|
||||||
openidconnect.workspace = true
|
openid.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
|
rand.workspace = true
|
||||||
|
|
||||||
[target.'cfg(all(unix, target_os = "linux"))'.dependencies]
|
[target.'cfg(all(unix, target_os = "linux"))'.dependencies]
|
||||||
@@ -144,9 +140,6 @@ sd-notify.optional = true
|
|||||||
[lints]
|
[lints]
|
||||||
workspace = true
|
workspace = true
|
||||||
|
|
||||||
[package.metadata.cargo-shear]
|
|
||||||
ignored = ["reqwest_0_12"]
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
opentelemetry.workspace = true
|
opentelemetry.workspace = true
|
||||||
rustls = { workspace = true, features = ["ring"] }
|
rustls = { workspace = true, features = ["ring"] }
|
||||||
@@ -44,18 +44,3 @@ 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)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -125,12 +125,6 @@ impl ClientMetadata {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.grant_types.contains(&GrantType::ClientCredentials) {
|
|
||||||
return Err(
|
|
||||||
"Dynamically registered clients may not use the client credentials grant."
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -150,7 +144,6 @@ pub enum GrantType {
|
|||||||
#[serde(rename = "urn:ietf:params:oauth:grant-type:device_code")]
|
#[serde(rename = "urn:ietf:params:oauth:grant-type:device_code")]
|
||||||
DeviceCode,
|
DeviceCode,
|
||||||
RefreshToken,
|
RefreshToken,
|
||||||
ClientCredentials,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Deserialize, Serialize)]
|
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Deserialize, Serialize)]
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ impl Display for RequestedScopes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default, Deserialize, Serialize)]
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||||
pub struct RawScopes(String);
|
pub struct RawScopes(String);
|
||||||
|
|
||||||
impl RawScopes {
|
impl RawScopes {
|
||||||
@@ -257,11 +257,6 @@ pub enum TokenRequestType {
|
|||||||
RefreshToken {
|
RefreshToken {
|
||||||
refresh_token: String,
|
refresh_token: String,
|
||||||
},
|
},
|
||||||
ClientCredentials {
|
|
||||||
client_secret: String,
|
|
||||||
#[serde(default)]
|
|
||||||
scope: RawScopes,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TokenRequestType {
|
impl TokenRequestType {
|
||||||
@@ -271,7 +266,6 @@ impl TokenRequestType {
|
|||||||
| Self::AuthorizationCode { .. } => GrantType::AuthorizationCode,
|
| Self::AuthorizationCode { .. } => GrantType::AuthorizationCode,
|
||||||
| Self::DeviceCode { .. } => GrantType::DeviceCode,
|
| Self::DeviceCode { .. } => GrantType::DeviceCode,
|
||||||
| Self::RefreshToken { .. } => GrantType::RefreshToken,
|
| Self::RefreshToken { .. } => GrantType::RefreshToken,
|
||||||
| Self::ClientCredentials { .. } => GrantType::ClientCredentials,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -281,7 +275,7 @@ pub struct TokenResponse {
|
|||||||
pub access_token: String,
|
pub access_token: String,
|
||||||
pub token_type: TokenType,
|
pub token_type: TokenType,
|
||||||
pub expires_in: u64,
|
pub expires_in: u64,
|
||||||
pub refresh_token: Option<String>,
|
pub refresh_token: String,
|
||||||
pub scope: String,
|
pub scope: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
-119
@@ -7,10 +7,10 @@ use std::{
|
|||||||
|
|
||||||
use base64::Engine;
|
use base64::Engine;
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Result, SyncMappedMutexGuard, SyncMutex, SyncMutexGuard,
|
Result, SyncMutex,
|
||||||
config::experiments::ToggledExperiment,
|
config::experiments::ToggledExperiment,
|
||||||
error, info,
|
error, info,
|
||||||
utils::{self, MutexMap, hash::sha256, string::constant_time_eq},
|
utils::{self, MutexMap, hash::sha256},
|
||||||
warn,
|
warn,
|
||||||
};
|
};
|
||||||
use database::{Deserialized, Json, Map};
|
use database::{Deserialized, Json, Map};
|
||||||
@@ -27,9 +27,8 @@ use crate::{
|
|||||||
client_metadata::{ApplicationType, ClientMetadata, GrantType, ResponseType},
|
client_metadata::{ApplicationType, ClientMetadata, GrantType, ResponseType},
|
||||||
grant::{
|
grant::{
|
||||||
AuthorizationCodeQuery, AuthorizationCodeResponse, CodeChallengeMethod,
|
AuthorizationCodeQuery, AuthorizationCodeResponse, CodeChallengeMethod,
|
||||||
DeviceCodeRequest, DeviceCodeResponse, ErrorCode, OAuthError, RawScopes,
|
DeviceCodeRequest, DeviceCodeResponse, ErrorCode, OAuthError, RequestedScopes,
|
||||||
RequestedScopes, ResponseMode, TokenRequest, TokenRequestType, TokenResponse,
|
ResponseMode, TokenRequest, TokenRequestType, TokenResponse, TokenType,
|
||||||
TokenType,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
users::{self, DeviceToken, PreviousTokenAction},
|
users::{self, DeviceToken, PreviousTokenAction},
|
||||||
@@ -54,7 +53,6 @@ pub struct Service {
|
|||||||
tickets: SyncMutex<HashMap<String, HashMap<OAuthTicket, SystemTime>>>,
|
tickets: SyncMutex<HashMap<String, HashMap<OAuthTicket, SystemTime>>>,
|
||||||
pending_auth_code_grants: SyncMutex<LruCache<String, PendingAuthCodeGrant>>,
|
pending_auth_code_grants: SyncMutex<LruCache<String, PendingAuthCodeGrant>>,
|
||||||
pending_device_code_grants: SyncMutex<LruCache<String, PendingDeviceCodeGrant>>,
|
pending_device_code_grants: SyncMutex<LruCache<String, PendingDeviceCodeGrant>>,
|
||||||
client_credential_sessions: SyncMutex<HashMap<String, ClientCredentialsSession>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Data {
|
struct Data {
|
||||||
@@ -108,12 +106,6 @@ struct RefreshTokenInfo {
|
|||||||
device_id: OwnedDeviceId,
|
device_id: OwnedDeviceId,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ClientCredentialsSession {
|
|
||||||
pub client_id: String,
|
|
||||||
pub scopes: BTreeSet<OAuthClientScope>,
|
|
||||||
created_at: SystemTime,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct PendingAuthCodeGrant {
|
struct PendingAuthCodeGrant {
|
||||||
authorizing_user: OwnedUserId,
|
authorizing_user: OwnedUserId,
|
||||||
requested_scopes: RequestedScopes,
|
requested_scopes: RequestedScopes,
|
||||||
@@ -209,7 +201,6 @@ impl crate::Service for Service {
|
|||||||
tickets: SyncMutex::default(),
|
tickets: SyncMutex::default(),
|
||||||
pending_auth_code_grants: SyncMutex::new(LruCache::new(Self::MAX_PENDING_GRANTS)),
|
pending_auth_code_grants: SyncMutex::new(LruCache::new(Self::MAX_PENDING_GRANTS)),
|
||||||
pending_device_code_grants: SyncMutex::new(LruCache::new(Self::MAX_PENDING_GRANTS)),
|
pending_device_code_grants: SyncMutex::new(LruCache::new(Self::MAX_PENDING_GRANTS)),
|
||||||
client_credential_sessions: SyncMutex::default(),
|
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -506,25 +497,12 @@ impl Service {
|
|||||||
pub async fn issue_token(&self, request: TokenRequest) -> Result<TokenResponse, OAuthError> {
|
pub async fn issue_token(&self, request: TokenRequest) -> Result<TokenResponse, OAuthError> {
|
||||||
let TokenRequest { client_id, request } = request;
|
let TokenRequest { client_id, request } = request;
|
||||||
|
|
||||||
if !matches!(request, TokenRequestType::ClientCredentials { .. }) {
|
let Some(client_metadata) = self.get_client_metadata(&client_id).await else {
|
||||||
// The client credentials grant can only be used by statically
|
return Err(OAuthError::new_static(ErrorCode::InvalidClient, "Invalid client ID"));
|
||||||
// registered clients, and the other grant types can
|
};
|
||||||
// only be used by dynamically registered clients, so we
|
|
||||||
// don't look up the dynamic client metadata if the token request is
|
|
||||||
// for the client credentials grant.
|
|
||||||
|
|
||||||
let Some(client_metadata) = self.get_client_metadata(&client_id).await else {
|
if !client_metadata.grant_types.contains(&request.grant_type()) {
|
||||||
return Err(OAuthError::new_static(
|
return Err(OAuthError::unauthorized_client("Client cannot request this grant type"));
|
||||||
ErrorCode::InvalidClient,
|
|
||||||
"Invalid client ID",
|
|
||||||
));
|
|
||||||
};
|
|
||||||
|
|
||||||
if !client_metadata.grant_types.contains(&request.grant_type()) {
|
|
||||||
return Err(OAuthError::unauthorized_client(
|
|
||||||
"Client cannot request this grant type",
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match request {
|
match request {
|
||||||
@@ -596,8 +574,6 @@ impl Service {
|
|||||||
},
|
},
|
||||||
| TokenRequestType::RefreshToken { refresh_token } =>
|
| TokenRequestType::RefreshToken { refresh_token } =>
|
||||||
self.refresh_session(client_id, refresh_token).await,
|
self.refresh_session(client_id, refresh_token).await,
|
||||||
| TokenRequestType::ClientCredentials { client_secret, scope: scopes } =>
|
|
||||||
self.create_client_credentials_token(&client_id, &client_secret, &scopes),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -614,12 +590,8 @@ impl Service {
|
|||||||
self.services.users.find_from_token(&token).await
|
self.services.users.find_from_token(&token).await
|
||||||
{
|
{
|
||||||
(user_id, device_id)
|
(user_id, device_id)
|
||||||
} else if self.get_client_credentials_session(&token).is_some() {
|
|
||||||
return Err(OAuthError::invalid_grant(
|
|
||||||
"Access tokens for static clients cannot be revoked.",
|
|
||||||
));
|
|
||||||
} else {
|
} else {
|
||||||
return Err(OAuthError::invalid_grant("Invalid access or refresh token."));
|
return Err(OAuthError::invalid_grant("Invalid access or refersh token"));
|
||||||
};
|
};
|
||||||
|
|
||||||
// This will also call [`Self::remove_session`]
|
// This will also call [`Self::remove_session`]
|
||||||
@@ -756,7 +728,7 @@ impl Service {
|
|||||||
token_type: TokenType::Bearer,
|
token_type: TokenType::Bearer,
|
||||||
expires_in: Self::ACCESS_TOKEN_MAX_AGE.as_secs(),
|
expires_in: Self::ACCESS_TOKEN_MAX_AGE.as_secs(),
|
||||||
scope: response_scope,
|
scope: response_scope,
|
||||||
refresh_token: Some(refresh_token),
|
refresh_token,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -883,89 +855,10 @@ impl Service {
|
|||||||
token_type: TokenType::Bearer,
|
token_type: TokenType::Bearer,
|
||||||
expires_in: Self::ACCESS_TOKEN_MAX_AGE.as_secs(),
|
expires_in: Self::ACCESS_TOKEN_MAX_AGE.as_secs(),
|
||||||
scope,
|
scope,
|
||||||
refresh_token: Some(new_refresh_token),
|
refresh_token: new_refresh_token,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_client_credentials_token(
|
|
||||||
&self,
|
|
||||||
client_id: &str,
|
|
||||||
client_secret: &str,
|
|
||||||
scopes: &RawScopes,
|
|
||||||
) -> Result<TokenResponse, OAuthError> {
|
|
||||||
let now = SystemTime::now();
|
|
||||||
|
|
||||||
let Some(client) = self.services.config.oauth.clients.get(client_id) else {
|
|
||||||
return Err(OAuthError::new_static(ErrorCode::InvalidClient, "Unknown client ID"));
|
|
||||||
};
|
|
||||||
|
|
||||||
let RequestedScopes { device_id, scopes } = scopes
|
|
||||||
.to_scopes()
|
|
||||||
.map_err(|err| OAuthError::new(ErrorCode::InvalidGrant, err))?;
|
|
||||||
|
|
||||||
if device_id.is_some() {
|
|
||||||
return Err(OAuthError::new_static(
|
|
||||||
ErrorCode::InvalidGrant,
|
|
||||||
"Static clients may not request a device ID",
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
if !constant_time_eq(client_secret, &client.client_secret) {
|
|
||||||
return Err(OAuthError::new_static(
|
|
||||||
ErrorCode::InvalidClient,
|
|
||||||
"Client secret does not match",
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
if !scopes.is_subset(&client.scopes) {
|
|
||||||
return Err(OAuthError::new_static(
|
|
||||||
ErrorCode::InvalidScope,
|
|
||||||
"This client may not request those scopes",
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut sessions = self.client_credential_sessions.lock();
|
|
||||||
|
|
||||||
// Clear expired sessions while we're at it
|
|
||||||
sessions.retain(|_, session| {
|
|
||||||
now.duration_since(session.created_at)
|
|
||||||
.is_ok_and(|age| age <= Self::ACCESS_TOKEN_MAX_AGE)
|
|
||||||
});
|
|
||||||
|
|
||||||
let access_token = Self::generate_token();
|
|
||||||
let scope = scopes.iter().join(" ");
|
|
||||||
|
|
||||||
sessions.insert(access_token.clone(), ClientCredentialsSession {
|
|
||||||
client_id: client_id.to_owned(),
|
|
||||||
scopes,
|
|
||||||
created_at: now,
|
|
||||||
});
|
|
||||||
|
|
||||||
Ok(TokenResponse {
|
|
||||||
access_token,
|
|
||||||
token_type: TokenType::Bearer,
|
|
||||||
expires_in: Self::ACCESS_TOKEN_MAX_AGE.as_secs(),
|
|
||||||
refresh_token: None,
|
|
||||||
scope,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_client_credentials_session(
|
|
||||||
&self,
|
|
||||||
token: &str,
|
|
||||||
) -> Option<SyncMappedMutexGuard<'_, ClientCredentialsSession>> {
|
|
||||||
let sessions = self.client_credential_sessions.lock();
|
|
||||||
|
|
||||||
SyncMutexGuard::try_map(sessions, |sessions| {
|
|
||||||
sessions.get_mut(token).filter(|session| {
|
|
||||||
SystemTime::now()
|
|
||||||
.duration_since(session.created_at)
|
|
||||||
.is_ok_and(|age| age <= Self::ACCESS_TOKEN_MAX_AGE)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.ok()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn remove_session(&self, user_id: &UserId, device_id: &DeviceId) {
|
pub async fn remove_session(&self, user_id: &UserId, device_id: &DeviceId) {
|
||||||
let _lock = self.session_mutex.lock(&(user_id, device_id)).await;
|
let _lock = self.session_mutex.lock(&(user_id, device_id)).await;
|
||||||
let session_info = self.get_session_info_for_device(user_id, device_id).await;
|
let session_info = self.get_session_info_for_device(user_id, device_id).await;
|
||||||
|
|||||||
+158
-168
@@ -1,26 +1,19 @@
|
|||||||
use std::{collections::HashMap, net::IpAddr, str::FromStr, sync::Arc, time::Duration};
|
use std::{
|
||||||
|
collections::{HashMap, HashSet},
|
||||||
|
net::IpAddr,
|
||||||
|
str::FromStr,
|
||||||
|
sync::Arc,
|
||||||
|
};
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Result, SyncRwLock,
|
Result, SyncRwLock,
|
||||||
config::{OidcConfig, OidcProfileKeyImportMode},
|
config::{OidcConfig, OidcProfileKeyImportMode},
|
||||||
debug, err, error, info, warn,
|
debug, err, error, info, utils, warn,
|
||||||
};
|
};
|
||||||
use database::{Deserialized, Map};
|
use database::{Deserialized, Map};
|
||||||
use lettre::Address;
|
use lettre::Address;
|
||||||
use openidconnect::{
|
use openid::{Claims as _, Options, StandardClaims, Token};
|
||||||
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::{
|
use ruma::{
|
||||||
OwnedUserId, UserId,
|
OwnedUserId, UserId,
|
||||||
api::client::profile::PropagateTo,
|
api::client::profile::PropagateTo,
|
||||||
@@ -50,6 +43,7 @@ struct Data {
|
|||||||
openidsubjectprofilefield_url: Arc<Map>,
|
openidsubjectprofilefield_url: Arc<Map>,
|
||||||
}
|
}
|
||||||
struct Services {
|
struct Services {
|
||||||
|
client: Dep<client::Service>,
|
||||||
config: Dep<config::Service>,
|
config: Dep<config::Service>,
|
||||||
globals: Dep<globals::Service>,
|
globals: Dep<globals::Service>,
|
||||||
media: Dep<media::Service>,
|
media: Dep<media::Service>,
|
||||||
@@ -58,56 +52,61 @@ struct Services {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct OidcClient {
|
struct OidcClient {
|
||||||
|
client_secret: String,
|
||||||
config: OidcConfig,
|
config: OidcConfig,
|
||||||
client_secret: ClientSecret,
|
client: SetOnce<SyncRwLock<Arc<IdpClient>>>,
|
||||||
machine: SetOnce<SyncRwLock<Arc<OidcClientMachine>>>,
|
|
||||||
client: reqwest::Client,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type OidcClientMachine = openidconnect::Client<
|
type IdpClient = openid::Client<openid::Discovered, Claims>;
|
||||||
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)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
pub struct AllClaims {
|
pub struct Claims {
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub claims: HashMap<String, Value>,
|
standard_claims: StandardClaims,
|
||||||
|
|
||||||
|
#[serde(flatten)]
|
||||||
|
other_claims: HashMap<String, Value>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AdditionalClaims for AllClaims {}
|
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 {}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct PendingSession {
|
pub struct PendingSession {
|
||||||
pkce_verifier: PkceCodeVerifier,
|
pkce_verifier: String,
|
||||||
nonce: Nonce,
|
nonce: String,
|
||||||
csrf_token: CsrfToken,
|
csrf_token: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum SessionCompletionStatus {
|
pub enum SessionCompletionStatus {
|
||||||
@@ -135,54 +134,33 @@ impl crate::Service for Service {
|
|||||||
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
|
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
|
||||||
Ok(Arc::new(Self {
|
Ok(Arc::new(Self {
|
||||||
services: Services {
|
services: Services {
|
||||||
|
client: args.depend::<client::Service>("client"),
|
||||||
config: args.depend::<config::Service>("config"),
|
config: args.depend::<config::Service>("config"),
|
||||||
globals: args.depend::<globals::Service>("globals"),
|
globals: args.depend::<globals::Service>("globals"),
|
||||||
media: args.depend::<media::Service>("media"),
|
media: args.depend::<media::Service>("media"),
|
||||||
threepid: args.depend::<threepid::Service>("threepid"),
|
threepid: args.depend::<threepid::Service>("threepid"),
|
||||||
users: args.depend::<users::Service>("users"),
|
users: args.depend::<users::Service>("users"),
|
||||||
},
|
},
|
||||||
runtime: args.server.runtime().clone(),
|
runtime: args.server.runtime().clone(),
|
||||||
db: Data {
|
db: Data {
|
||||||
openidsubject_localpart: args.db["openidsubject_localpart"].clone(),
|
openidsubject_localpart: args.db["openidsubject_localpart"].clone(),
|
||||||
openidsubjectprofilefield_url: args.db["openidsubjectprofilefield_url"].clone(),
|
openidsubjectprofilefield_url: args.db["openidsubjectprofilefield_url"].clone(),
|
||||||
},
|
},
|
||||||
client: args.server.config.oauth.oidc.as_ref().map(|config| -> Result<OidcClient> {
|
client: args
|
||||||
Ok(OidcClient {
|
.server
|
||||||
config: config.clone(),
|
.config
|
||||||
client_secret: if let Some(client_secret_file) = &config.client_secret_file {
|
.oauth
|
||||||
std::fs::read_to_string(client_secret_file)
|
.oidc
|
||||||
.map(|client_secret| client_secret.trim().to_owned())
|
.clone()
|
||||||
.map(ClientSecret::new)
|
.map(Self::create_client)
|
||||||
.map_err(|err| err!("Failed to read OIDC client secret file: {err}"))?
|
.transpose()?,
|
||||||
} 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 {
|
async fn worker(self: Arc<Self>) -> Result {
|
||||||
if let Some(OidcClient { machine, .. }) = &self.client {
|
if let Some(OidcClient { client, .. }) = &self.client {
|
||||||
let discovered = self.discover().await?;
|
let discovered = self.discover().await?;
|
||||||
machine
|
client
|
||||||
.set(SyncRwLock::new(Arc::new(discovered)))
|
.set(SyncRwLock::new(Arc::new(discovered)))
|
||||||
.expect("machine should be empty");
|
.expect("machine should be empty");
|
||||||
}
|
}
|
||||||
@@ -198,13 +176,36 @@ impl Service {
|
|||||||
// into the media repository. Keep this synced with the list in the
|
// into the media repository. Keep this synced with the list in the
|
||||||
// doc comment for `profile_key_map` in the config.
|
// doc comment for `profile_key_map` in the config.
|
||||||
const IMAGE_PROFILE_KEYS: &[&str] = &["avatar_url", "chat.commet.profile_banner"];
|
const IMAGE_PROFILE_KEYS: &[&str] = &["avatar_url", "chat.commet.profile_banner"];
|
||||||
|
const NONCE_SIZE: usize = 32;
|
||||||
const SERVER_MISCONFIGURED: &str =
|
const SERVER_MISCONFIGURED: &str =
|
||||||
"Identity server is misconfigured. Contact your homeserver's administrator.";
|
"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() }
|
pub fn enabled(&self) -> bool { self.client.is_some() }
|
||||||
|
|
||||||
async fn discover(&self) -> Result<OidcClientMachine> {
|
async fn discover(&self) -> Result<IdpClient> {
|
||||||
let OidcClient { config, client_secret, client, .. } =
|
let OidcClient { config, client_secret, .. } =
|
||||||
self.client.as_ref().expect("oidc should be configured");
|
self.client.as_ref().expect("oidc should be configured");
|
||||||
|
|
||||||
let redirect_url = self
|
let redirect_url = self
|
||||||
@@ -214,20 +215,15 @@ impl Service {
|
|||||||
.join(&format!("{}/oidc/complete", conduwuit::ROUTE_PREFIX))
|
.join(&format!("{}/oidc/complete", conduwuit::ROUTE_PREFIX))
|
||||||
.expect("redirect url should be valid");
|
.expect("redirect url should be valid");
|
||||||
|
|
||||||
let provider_metadata = CoreProviderMetadata::discover_async(
|
IdpClient::discover_with_client(
|
||||||
IssuerUrl::new(config.discovery_url.clone())
|
self.services.client.external_resource.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}"))?;
|
|
||||||
|
|
||||||
Ok(OidcClientMachine::from_provider_metadata(
|
|
||||||
provider_metadata,
|
|
||||||
config.client_id.clone(),
|
config.client_id.clone(),
|
||||||
Some(client_secret.clone()),
|
Some(client_secret.clone()),
|
||||||
|
Some(redirect_url.to_string()),
|
||||||
|
config.discovery_url.clone(),
|
||||||
)
|
)
|
||||||
.set_redirect_uri(RedirectUrl::from_url(redirect_url)))
|
.await
|
||||||
|
.map_err(|err| err!("Failed to discover OIDC provider metadata: {err}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn provider_name(&self) -> Option<String> {
|
pub fn provider_name(&self) -> Option<String> {
|
||||||
@@ -256,29 +252,32 @@ impl Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn begin_session(&self, prompt: Option<CoreAuthPrompt>) -> (PendingSession, Url) {
|
pub async fn begin_session(&self, prompt: Option<openid::Prompt>) -> (PendingSession, Url) {
|
||||||
let OidcClient { machine, config, .. } =
|
let OidcClient { client, config, .. } =
|
||||||
self.client.as_ref().expect("oidc should be configured");
|
self.client.as_ref().expect("oidc should be configured");
|
||||||
let machine = machine.wait().await.read().clone();
|
let client = client.wait().await.read().clone();
|
||||||
|
|
||||||
let (pkce_challenge, pkce_verifier) = PkceCodeChallenge::new_random_sha256();
|
let csrf_token = Self::create_nonce();
|
||||||
|
let nonce = Self::create_nonce();
|
||||||
|
|
||||||
let mut auth_url = machine
|
let (auth_url, pkce) = client.auth_url_with_new_pkce(&Options {
|
||||||
.authorize_url(
|
// The client will add the `openid` scope for us.
|
||||||
CoreAuthenticationFlow::AuthorizationCode,
|
scope: Some(config.additional_scopes.join(" ")),
|
||||||
CsrfToken::new_random,
|
state: Some(csrf_token.clone()),
|
||||||
Nonce::new_random,
|
nonce: Some(nonce.clone()),
|
||||||
)
|
prompt: prompt.map(|prompt| HashSet::from_iter([prompt])),
|
||||||
.add_scopes(config.additional_scopes.iter().cloned())
|
|
||||||
.set_pkce_challenge(pkce_challenge);
|
|
||||||
|
|
||||||
if let Some(prompt) = prompt {
|
..Default::default()
|
||||||
auth_url = auth_url.add_prompt(prompt);
|
});
|
||||||
}
|
|
||||||
|
|
||||||
let (auth_url, csrf_token, nonce) = auth_url.url();
|
(
|
||||||
|
PendingSession {
|
||||||
(PendingSession { pkce_verifier, nonce, csrf_token }, auth_url)
|
pkce_verifier: pkce.code_verifier().to_owned(),
|
||||||
|
nonce,
|
||||||
|
csrf_token,
|
||||||
|
},
|
||||||
|
auth_url,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn exchange_code(
|
pub async fn exchange_code(
|
||||||
@@ -286,78 +285,77 @@ impl Service {
|
|||||||
session: PendingSession,
|
session: PendingSession,
|
||||||
response: AuthorizationCodeResponse,
|
response: AuthorizationCodeResponse,
|
||||||
) -> Result<Claims, &'static str> {
|
) -> Result<Claims, &'static str> {
|
||||||
let Some(OidcClient { machine, client, config, .. }) = self.client.as_ref() else {
|
let Some(OidcClient { client, .. }) = self.client.as_ref() else {
|
||||||
return Err("Delegated authentication is not enabled on this server.");
|
return Err("Delegated authentication is not enabled on this server.");
|
||||||
};
|
};
|
||||||
|
|
||||||
let current = machine.wait().await.read().clone();
|
let current = client.wait().await.read().clone();
|
||||||
|
|
||||||
if session.csrf_token.into_secret() != response.state {
|
if session.csrf_token != response.state {
|
||||||
return Err("State mismatch.");
|
return Err("State mismatch.");
|
||||||
}
|
}
|
||||||
|
|
||||||
let token_response = current
|
let token_response = current
|
||||||
.exchange_code(AuthorizationCode::new(response.code))
|
.request_token_pkce(&response.code, Some(&session.pkce_verifier))
|
||||||
.expect("machine should be configured correctly")
|
|
||||||
.set_pkce_verifier(session.pkce_verifier)
|
|
||||||
.request_async(client)
|
|
||||||
.await
|
.await
|
||||||
|
.map(Token::<Claims>::from)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
error!(error=?err, "Failed to exchange OIDC authorization code");
|
error!(error=?err, "Failed to exchange OIDC authorization code");
|
||||||
"Code exchange failed. The identity provider may be unreachable. Contact your \
|
"Code exchange failed. The identity provider may be unreachable. Contact your \
|
||||||
homeserver's administrator."
|
homeserver's administrator."
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let Some(id_token) = token_response.id_token() else {
|
let Some(mut id_token) = token_response.id_token else {
|
||||||
error!("Identity server did not return an id token");
|
error!("Identity server did not return an id token");
|
||||||
return Err(Self::SERVER_MISCONFIGURED);
|
return Err(Self::SERVER_MISCONFIGURED);
|
||||||
};
|
};
|
||||||
|
|
||||||
let verify = |machine: &OidcClientMachine| {
|
if let Err(err) = current.decode_token(&mut id_token) {
|
||||||
let verifier =
|
error!(error=?err, "Failed to decode ID token");
|
||||||
machine
|
return Err(Self::SERVER_MISCONFIGURED);
|
||||||
.id_token_verifier()
|
}
|
||||||
.set_other_audience_verifier_fn(|audience| {
|
|
||||||
config.additional_trusted_audiences.contains(audience)
|
|
||||||
});
|
|
||||||
|
|
||||||
id_token
|
let verify = |client: &IdpClient| {
|
||||||
.claims(&verifier, &session.nonce)
|
client.validate_token(&id_token, Some(session.nonce.as_str()), None)
|
||||||
.map(ToOwned::to_owned)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut result = verify(¤t);
|
let mut result = verify(¤t);
|
||||||
|
|
||||||
if matches!(
|
if matches!(
|
||||||
result,
|
result,
|
||||||
Err(ClaimsVerificationError::SignatureVerification(
|
Err(openid::error::Error::Jose(openid::error::Jose::ValidationError(
|
||||||
SignatureVerificationError::NoMatchingKey
|
openid::biscuit::errors::ValidationError::KeyNotFound
|
||||||
))
|
)))
|
||||||
) {
|
) {
|
||||||
match self.discover().await {
|
match self.discover().await {
|
||||||
| Ok(discovered) => {
|
| Ok(discovered) => {
|
||||||
info!("Refreshed OIDC provider metadata after an unknown signing key");
|
info!("Refreshed OIDC provider metadata after an unknown signing key");
|
||||||
result = verify(&discovered);
|
result = verify(&discovered);
|
||||||
*machine.wait().await.write() = Arc::new(discovered);
|
*client.wait().await.write() = Arc::new(discovered);
|
||||||
},
|
},
|
||||||
| Err(err) => warn!("Failed to refresh OIDC provider metadata: {err}"),
|
| Err(err) => warn!("Failed to refresh OIDC provider metadata: {err}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let claims = result.map_err(|err| {
|
match result {
|
||||||
error!("Failed to verify id token claims: {err}");
|
| Ok(()) => {
|
||||||
Self::SERVER_MISCONFIGURED
|
let (_, claims) = id_token.unwrap_decoded();
|
||||||
})?;
|
|
||||||
|
|
||||||
info!(subject = claims.subject().as_str(), "Authenticated subject");
|
info!(subject = claims.sub(), "Authenticated subject");
|
||||||
|
|
||||||
Ok(claims)
|
Ok(claims)
|
||||||
|
},
|
||||||
|
| Err(err) => {
|
||||||
|
error!("Failed to verify id token claims: {err}");
|
||||||
|
Err(Self::SERVER_MISCONFIGURED)
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip(self, claims), fields(subject = claims.subject().to_string()))]
|
#[tracing::instrument(skip(self, claims), fields(subject = claims.sub().to_owned()))]
|
||||||
pub async fn complete_session(
|
pub async fn complete_session(
|
||||||
&self,
|
&self,
|
||||||
claims: &Claims,
|
claims: Claims,
|
||||||
supplied_user_id: Option<OwnedUserId>,
|
supplied_user_id: Option<OwnedUserId>,
|
||||||
client_ip: &IpAddr,
|
client_ip: &IpAddr,
|
||||||
) -> Result<SessionCompletionStatus, &'static str> {
|
) -> Result<SessionCompletionStatus, &'static str> {
|
||||||
@@ -365,21 +363,14 @@ impl Service {
|
|||||||
return Err("Delegated authentication is not enabled on this server.");
|
return Err("Delegated authentication is not enabled on this server.");
|
||||||
};
|
};
|
||||||
|
|
||||||
// this is a truly awful hack but we really need all the claims in a map
|
debug!(claims = ?claims.other_claims, "Got claims from the identity provider");
|
||||||
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();
|
|
||||||
|
|
||||||
debug!(?all_claims, "Got claims from the identity provider");
|
let subject = claims.sub().to_owned();
|
||||||
|
|
||||||
let subject = claims.subject().as_str();
|
|
||||||
|
|
||||||
let user_id = if let Ok(localpart) = self
|
let user_id = if let Ok(localpart) = self
|
||||||
.db
|
.db
|
||||||
.openidsubject_localpart
|
.openidsubject_localpart
|
||||||
.get(subject)
|
.get(&subject)
|
||||||
.await
|
.await
|
||||||
.deserialized::<String>()
|
.deserialized::<String>()
|
||||||
{
|
{
|
||||||
@@ -391,7 +382,7 @@ impl Service {
|
|||||||
} else {
|
} else {
|
||||||
return Ok(SessionCompletionStatus::NeedsUserId);
|
return Ok(SessionCompletionStatus::NeedsUserId);
|
||||||
}
|
}
|
||||||
} else if let Some(preferred_username) = all_claims
|
} else if let Some(preferred_username) = claims
|
||||||
.get(&config.preferred_username_claim)
|
.get(&config.preferred_username_claim)
|
||||||
.and_then(|claim| claim.as_str())
|
.and_then(|claim| claim.as_str())
|
||||||
{
|
{
|
||||||
@@ -435,7 +426,7 @@ impl Service {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
self.link_user(&user_id, subject);
|
self.link_user(&user_id, &subject);
|
||||||
|
|
||||||
// Import profile fields
|
// Import profile fields
|
||||||
if matches!(config.profile_key_import_mode, OidcProfileKeyImportMode::OnLogin)
|
if matches!(config.profile_key_import_mode, OidcProfileKeyImportMode::OnLogin)
|
||||||
@@ -445,7 +436,7 @@ impl Service {
|
|||||||
) && new_account_registered)
|
) && new_account_registered)
|
||||||
{
|
{
|
||||||
if let Some(email_claim) = &config.email_claim {
|
if let Some(email_claim) = &config.email_claim {
|
||||||
if let Some(email) = claims.email().map(|email| email.as_str())
|
if let Some(email) = claims.get(email_claim).and_then(|email| email.as_str())
|
||||||
&& let Ok(address) = Address::from_str(email)
|
&& let Ok(address) = Address::from_str(email)
|
||||||
{
|
{
|
||||||
if let Err(err) = self
|
if let Err(err) = self
|
||||||
@@ -465,7 +456,6 @@ impl Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let user_id = user_id.clone();
|
let user_id = user_id.clone();
|
||||||
let subject = claims.subject().to_string();
|
|
||||||
let profile_key_map = config.profile_key_map.clone();
|
let profile_key_map = config.profile_key_map.clone();
|
||||||
let openidsubjectprofilefield_url = self.db.openidsubjectprofilefield_url.clone();
|
let openidsubjectprofilefield_url = self.db.openidsubjectprofilefield_url.clone();
|
||||||
let users = self.services.users.clone();
|
let users = self.services.users.clone();
|
||||||
@@ -475,7 +465,7 @@ impl Service {
|
|||||||
// TODO: once we get support for full profile replacement, use
|
// TODO: once we get support for full profile replacement, use
|
||||||
// that logic instead
|
// that logic instead
|
||||||
for (field, claim) in &profile_key_map {
|
for (field, claim) in &profile_key_map {
|
||||||
let Some(value) = all_claims.get(claim).cloned() else {
|
let Some(value) = claims.get(claim).cloned() else {
|
||||||
warn!(?field, ?claim, "IDP provided no value for this mapped claim");
|
warn!(?field, ?claim, "IDP provided no value for this mapped claim");
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -75,8 +75,7 @@ impl Service {
|
|||||||
"lazy loading should be enabled by your options"
|
"lazy loading should be enabled by your options"
|
||||||
);
|
);
|
||||||
|
|
||||||
let include_redundant = cfg!(feature = "element_hacks")
|
let include_redundant = ctx.options.is_some_and(Options::include_redundant_members);
|
||||||
|| ctx.options.is_some_and(Options::include_redundant_members);
|
|
||||||
|
|
||||||
let witness = self
|
let witness = self
|
||||||
.witness(ctx, senders.iter().map(AsRef::as_ref))
|
.witness(ctx, senders.iter().map(AsRef::as_ref))
|
||||||
|
|||||||
@@ -522,13 +522,6 @@ impl Service {
|
|||||||
let device_changes =
|
let device_changes =
|
||||||
self.select_edus_device_changes(server_name, batch, &max_edu_count, &events_len);
|
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
|
let presence: OptionFuture<_> = self
|
||||||
.server
|
.server
|
||||||
.config
|
.config
|
||||||
@@ -536,11 +529,20 @@ impl Service {
|
|||||||
.then(|| self.select_edus_presence(server_name, batch, &max_edu_count))
|
.then(|| self.select_edus_presence(server_name, batch, &max_edu_count))
|
||||||
.into();
|
.into();
|
||||||
|
|
||||||
let (device_changes, receipts, presence) = join!(device_changes, receipts, presence);
|
let (device_changes, presence) = join!(device_changes, presence);
|
||||||
|
|
||||||
let mut events = device_changes;
|
let mut events = device_changes;
|
||||||
events.extend(presence.into_iter().flatten());
|
events.extend(presence.into_iter().flatten());
|
||||||
events.extend(receipts.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,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO(nex): some EDUs like typing need flattening
|
// TODO(nex): some EDUs like typing need flattening
|
||||||
|
|
||||||
@@ -616,9 +618,11 @@ impl Service {
|
|||||||
server_name: &ServerName,
|
server_name: &ServerName,
|
||||||
since: (u64, u64),
|
since: (u64, u64),
|
||||||
max_edu_count: &AtomicU64,
|
max_edu_count: &AtomicU64,
|
||||||
) -> Option<EduBuf> {
|
edu_limit: usize,
|
||||||
|
) -> EduVec {
|
||||||
let num = AtomicUsize::new(0);
|
let num = AtomicUsize::new(0);
|
||||||
let receipts: BTreeMap<OwnedRoomId, ReceiptMap> = self
|
let deferred = AtomicU64::new(u64::MAX);
|
||||||
|
let rooms: Vec<_> = self
|
||||||
.services
|
.services
|
||||||
.state_cache
|
.state_cache
|
||||||
.server_rooms(server_name)
|
.server_rooms(server_name)
|
||||||
@@ -627,33 +631,54 @@ impl Service {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let receipt_map = self
|
let maps = self
|
||||||
.select_edus_receipts_room(&room_id, since, max_edu_count, &num)
|
.select_edus_receipts_room(
|
||||||
|
&room_id,
|
||||||
|
since,
|
||||||
|
max_edu_count,
|
||||||
|
&num,
|
||||||
|
edu_limit,
|
||||||
|
&deferred,
|
||||||
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
(!receipt_map.read.is_empty()).then_some((room_id, receipt_map))
|
(!maps.is_empty()).then_some((room_id, maps))
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
if receipts.is_empty() {
|
// the next transaction starts at the first receipt that did not fit
|
||||||
return None;
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let receipt_content = Edu::Receipt(ReceiptContent::new(receipts));
|
contents
|
||||||
|
.into_iter()
|
||||||
|
.map(|content| {
|
||||||
|
let edu = Edu::Receipt(ReceiptContent::new(content));
|
||||||
|
|
||||||
let mut buf = EduBuf::new();
|
let mut buf = EduBuf::new();
|
||||||
serde_json::to_writer(&mut buf, &receipt_content)
|
serde_json::to_writer(&mut buf, &edu)
|
||||||
.expect("Failed to serialize Receipt EDU to JSON vec");
|
.expect("Failed to serialize Receipt EDU to JSON vec");
|
||||||
|
buf
|
||||||
Some(buf)
|
})
|
||||||
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Look for read receipts in this room
|
/// Look for read receipts in this room
|
||||||
#[tracing::instrument(
|
#[tracing::instrument(
|
||||||
name = "receipts",
|
name = "receipts",
|
||||||
level = "trace",
|
level = "trace",
|
||||||
skip(self, since, max_edu_count, num)
|
skip(self, since, max_edu_count, num, deferred)
|
||||||
)]
|
)]
|
||||||
async fn select_edus_receipts_room(
|
async fn select_edus_receipts_room(
|
||||||
&self,
|
&self,
|
||||||
@@ -661,14 +686,16 @@ impl Service {
|
|||||||
since: (u64, u64),
|
since: (u64, u64),
|
||||||
max_edu_count: &AtomicU64,
|
max_edu_count: &AtomicU64,
|
||||||
num: &AtomicUsize,
|
num: &AtomicUsize,
|
||||||
) -> ReceiptMap {
|
edu_limit: usize,
|
||||||
|
deferred: &AtomicU64,
|
||||||
|
) -> Vec<BTreeMap<OwnedUserId, ReceiptData>> {
|
||||||
let receipts = self
|
let receipts = self
|
||||||
.services
|
.services
|
||||||
.read_receipt
|
.read_receipt
|
||||||
.readreceipts_since(room_id, Some(since.0));
|
.readreceipts_since(room_id, Some(since.0));
|
||||||
|
|
||||||
pin_mut!(receipts);
|
pin_mut!(receipts);
|
||||||
let mut read = BTreeMap::<OwnedUserId, ReceiptData>::new();
|
let mut maps = Vec::new();
|
||||||
while let Some((user_id, count, read_receipt)) = receipts.next().await {
|
while let Some((user_id, count, read_receipt)) = receipts.next().await {
|
||||||
if count > since.1 {
|
if count > since.1 {
|
||||||
break;
|
break;
|
||||||
@@ -704,14 +731,20 @@ impl Service {
|
|||||||
|
|
||||||
let receipt_data = ReceiptData::new(receipt, vec![event_id]);
|
let receipt_data = ReceiptData::new(receipt, vec![event_id]);
|
||||||
|
|
||||||
if read.insert(user_id, receipt_data).is_none() {
|
let Some(index) = add_receipt(&mut maps, user_id, receipt_data, edu_limit) else {
|
||||||
if num.fetch_add(1, Ordering::Relaxed).saturating_add(1) >= SELECT_RECEIPT_LIMIT {
|
deferred.fetch_min(count, Ordering::Relaxed);
|
||||||
break;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ReceiptMap::new(read)
|
maps
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Look for presence
|
/// Look for presence
|
||||||
@@ -1110,3 +1143,27 @@ 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,14 +1,19 @@
|
|||||||
use std::iter::once;
|
use std::{collections::BTreeMap, iter::once};
|
||||||
|
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Error,
|
Error,
|
||||||
matrix::{PartialPdu, pdu::sticky},
|
matrix::{PartialPdu, pdu::sticky},
|
||||||
};
|
};
|
||||||
use futures::{StreamExt, stream::FuturesUnordered};
|
use futures::{StreamExt, stream::FuturesUnordered};
|
||||||
use ruma::{RoomId, UserId, events::sticky::StickyDurationMs, server_name};
|
use ruma::{
|
||||||
|
RoomId, UserId,
|
||||||
|
api::federation::transactions::edu::ReceiptData,
|
||||||
|
events::{receipt::Receipt, sticky::StickyDurationMs},
|
||||||
|
server_name, user_id,
|
||||||
|
};
|
||||||
use serde_json::{json, value::to_raw_value};
|
use serde_json::{json, value::to_raw_value};
|
||||||
|
|
||||||
use super::{CurTransactionStatus, TransactionStatus};
|
use super::{CurTransactionStatus, TransactionStatus, add_receipt};
|
||||||
use crate::{
|
use crate::{
|
||||||
sending::{Destination, EduBuf, SendingEvent},
|
sending::{Destination, EduBuf, SendingEvent},
|
||||||
test_utils::{test_services, test_services_with},
|
test_utils::{test_services, test_services_with},
|
||||||
@@ -196,3 +201,17 @@ async fn restarted_worker_keeps_sticky_events_when_startup_netburst_is_disabled(
|
|||||||
assert_eq!(active_after_startup, 0);
|
assert_eq!(active_after_startup, 0);
|
||||||
assert_eq!(sending_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]);
|
||||||
|
}
|
||||||
+1
-1
@@ -31,7 +31,7 @@ form_urlencoded = "1.2.2"
|
|||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
lettre.workspace = true
|
lettre.workspace = true
|
||||||
memory-serve = "2.4.0"
|
memory-serve = "2.4.0"
|
||||||
openidconnect.workspace = true
|
openid.workspace = true
|
||||||
ruma.workspace = true
|
ruma.workspace = true
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use axum::{
|
|||||||
routing::{get, on},
|
routing::{get, on},
|
||||||
};
|
};
|
||||||
use conduwuit_api::client::handle_login;
|
use conduwuit_api::client::handle_login;
|
||||||
use openidconnect::core::CoreAuthPrompt;
|
use openid::Prompt;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
OwnedUserId,
|
OwnedUserId,
|
||||||
api::client::uiaa::{EmailUserIdentifier, MatrixUserIdentifier, UserIdentifier},
|
api::client::uiaa::{EmailUserIdentifier, MatrixUserIdentifier, UserIdentifier},
|
||||||
@@ -86,8 +86,8 @@ async fn route_login(
|
|||||||
let (session, redirect_url) = services
|
let (session, redirect_url) = services
|
||||||
.oidc
|
.oidc
|
||||||
.begin_session(match intent {
|
.begin_session(match intent {
|
||||||
| Some(LoginIntent::SwitchAccounts) => Some(CoreAuthPrompt::SelectAccount),
|
| Some(LoginIntent::SwitchAccounts) => Some(Prompt::SelectAccount),
|
||||||
| _ if reauthenticate => Some(CoreAuthPrompt::Consent),
|
| _ if reauthenticate => Some(Prompt::Consent),
|
||||||
| _ => None,
|
| _ => None,
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
|
|||||||
@@ -106,10 +106,7 @@ async fn route_complete(
|
|||||||
.await
|
.await
|
||||||
.expect("should be able to serialize oidc session");
|
.expect("should be able to serialize oidc session");
|
||||||
|
|
||||||
services
|
Box::pin(services.oidc.complete_session(claims, None, &client_ip)).await
|
||||||
.oidc
|
|
||||||
.complete_session(&claims, None, &client_ip)
|
|
||||||
.await
|
|
||||||
},
|
},
|
||||||
| OidcSessionState::Authorized { claims } => {
|
| OidcSessionState::Authorized { claims } => {
|
||||||
let supplied_user_id = if let Some(form) = form {
|
let supplied_user_id = if let Some(form) = form {
|
||||||
@@ -166,10 +163,12 @@ async fn route_complete(
|
|||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
services
|
Box::pin(
|
||||||
.oidc
|
services
|
||||||
.complete_session(&claims, supplied_user_id, &client_ip)
|
.oidc
|
||||||
.await
|
.complete_session(*claims, supplied_user_id, &client_ip),
|
||||||
|
)
|
||||||
|
.await
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
.map_err(|err| WebError::BadRequest(err.to_owned()))?;
|
.map_err(|err| WebError::BadRequest(err.to_owned()))?;
|
||||||
|
|||||||
Reference in new issue
Block a user