feat: Support advertising a policy server public key in well-known

# Conflicts:
#	src/api/client/well_known.rs
#	src/core/config/mod.rs
This commit is contained in:
timedout
2026-04-28 15:59:44 +01:00
parent 47051af392
commit 5f9cc83b18
4 changed files with 27 additions and 0 deletions
+5
View File
@@ -1857,6 +1857,11 @@
# #
#support_page = #support_page =
# The ed25519 public key for the policy server available at this server's
# name. Must be unpadded base64.
#
#policy_server_public_key =
# Role string for server support contacts, to be served as part of the # Role string for server support contacts, to be served as part of the
# MSC1929 server support endpoint at /.well-known/matrix/support. # MSC1929 server support endpoint at /.well-known/matrix/support.
# #
+16
View File
@@ -3,6 +3,7 @@ use conduwuit::{Err, Result};
use ruma::{ use ruma::{
api::client::discovery::{ api::client::discovery::{
discover_homeserver::{self, HomeserverInfo}, discover_homeserver::{self, HomeserverInfo},
discover_policy_server,
discover_support::{self, Contact, ContactRole}, discover_support::{self, Contact, ContactRole},
}, },
assign, assign,
@@ -114,3 +115,18 @@ pub(crate) async fn well_known_support(
Ok(assign!(discover_support::Response::with_contacts(contacts), { support_page })) Ok(assign!(discover_support::Response::with_contacts(contacts), { support_page }))
} }
/// # `GET /.well-known/matrix/policy_server`
///
/// Advertises the policy server's public key, allowing clients to discover the
/// values to be set in m.room.policy. Introduced in spec v1.18.
pub(crate) async fn well_known_policy_server(
State(services): State<crate::State>,
_body: Ruma<discover_policy_server::Request>,
) -> Result<discover_policy_server::Response> {
if let Some(key) = services.config.well_known.policy_server_public_key.clone() {
Ok(discover_policy_server::Response::new(key))
} else {
Err!(Request(NotFound("No policy server available.")))
}
}
+1
View File
@@ -183,6 +183,7 @@ pub fn build(router: Router<State>, server: &Server) -> Router<State> {
.ruma_route(&client::put_suspended_status) .ruma_route(&client::put_suspended_status)
.ruma_route(&client::well_known_support) .ruma_route(&client::well_known_support)
.ruma_route(&client::well_known_client) .ruma_route(&client::well_known_client)
.ruma_route(&client::well_known_policy_server)
.ruma_route(&client::get_rtc_transports) .ruma_route(&client::get_rtc_transports)
.ruma_route(&client::room_initial_sync_route) .ruma_route(&client::room_initial_sync_route)
.route("/_conduwuit/server_version", get(client::conduwuit_server_version)) .route("/_conduwuit/server_version", get(client::conduwuit_server_version))
+5
View File
@@ -21,6 +21,7 @@ use regex::RegexSet;
use ruma::{ use ruma::{
OwnedRoomId, OwnedRoomOrAliasId, OwnedServerName, OwnedUserId, RoomVersionId, OwnedRoomId, OwnedRoomOrAliasId, OwnedServerName, OwnedUserId, RoomVersionId,
api::client::{discovery::discover_support::ContactRole, rtc::RtcTransport}, api::client::{discovery::discover_support::ContactRole, rtc::RtcTransport},
serde::Base64,
}; };
use serde::{Deserialize, Serialize, de::IgnoredAny}; use serde::{Deserialize, Serialize, de::IgnoredAny};
use url::Url; use url::Url;
@@ -2175,6 +2176,10 @@ pub struct WellKnownConfig {
/// Will be included alongside any contact information /// Will be included alongside any contact information
pub support_page: Option<Url>, pub support_page: Option<Url>,
/// The ed25519 public key for the policy server available at this server's
/// name. Must be unpadded base64.
pub policy_server_public_key: Option<Base64<ruma::serde::base64::Standard>>,
/// Role string for server support contacts, to be served as part of the /// Role string for server support contacts, to be served as part of the
/// MSC1929 server support endpoint at /.well-known/matrix/support. /// MSC1929 server support endpoint at /.well-known/matrix/support.
/// ///