require client base_url, rename from authority

The previous code used `server_name` as a fallback but in reality there
is no real relationship between `server_name` and the location clients
are supposed to make requests to.

Additionally, the `insecure` option is gone, because we now allow users
to control the entire URL, so they're free to choose the scheme.
This commit is contained in:
Charles Hall 2024-09-12 17:12:49 -07:00
parent 48850605b0
commit b9ee898920
No known key found for this signature in database
GPG key ID: 7B8E0645816E07CF
3 changed files with 13 additions and 29 deletions

View file

@ -30,24 +30,10 @@ pub(crate) async fn server(
/// Handler for `/.well-known/matrix/client`
pub(crate) async fn client(_: Ar<client::Request>) -> Ra<client::Response> {
let authority = services()
.globals
.config
.server_discovery
.client
.authority
.clone()
.unwrap_or_else(|| services().globals.config.server_name.clone());
let scheme = if services().globals.config.server_discovery.client.insecure {
"http"
} else {
"https"
};
let base_url = format!("{scheme}://{authority}");
// I wish ruma used an actual URL type instead of `String`
let base_url =
services().globals.config.server_discovery.client.base_url.to_string();
Ra(client::Response {
homeserver: client::HomeserverInfo::new(base_url.clone()),
identity_server: None,