Skip to content

Commit c4e811a

Browse files
committed
Update mas-cli doctor to suggest the stable MAS integration
1 parent d11e0b2 commit c4e811a

File tree

1 file changed

+22
-50
lines changed

1 file changed

+22
-50
lines changed

crates/cli/src/commands/doctor.rs

Lines changed: 22 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use std::process::ExitCode;
1414
use anyhow::Context;
1515
use clap::Parser;
1616
use figment::Figment;
17+
use hyper::StatusCode;
1718
use mas_config::{ConfigurationSection, RootConfig};
1819
use mas_http::RequestBuilderExt;
1920
use tracing::{error, info, info_span, warn};
@@ -99,17 +100,14 @@ Make sure that the MAS config contains:
99100
100101
http:
101102
public_base: {issuer:?}
102-
# Or, if the issuer is different from the public base:
103-
issuer: {issuer:?}
104103
105104
And in the Synapse config:
106105
107-
experimental_features:
108-
msc3861:
109-
enabled: true
110-
# This must exactly match:
111-
issuer: {issuer:?}
112-
# ...
106+
matrix_authentication_service:
107+
enabled: true
108+
# This must point to where MAS is reachable by Synapse
109+
endpoint: {issuer:?}
110+
# ...
113111
114112
See {DOCS_BASE}/setup/homeserver.html
115113
"#
@@ -128,11 +126,10 @@ Check the well-known document at "{well_known_uri}"
128126
Check the well-known document at "{well_known_uri}"
129127
Make sure Synapse has delegated auth enabled:
130128
131-
experimental_features:
132-
msc3861:
133-
enabled: true
134-
issuer: {issuer:?}
135-
# ...
129+
matrix_authentication_service:
130+
enabled: true
131+
endpoint: {issuer:?}
132+
# ...
136133
137134
If it is not Synapse handling the well-known document, update it to include the following:
138135
@@ -278,62 +275,37 @@ Check that the homeserver is running."#
278275
Err(e) => error!(
279276
r#"❌ Can't reach the homeserver at "{whoami}".
280277
281-
Error details: {e}
282-
"#
283-
),
284-
}
285-
286-
// Try to reach the admin API on an unauthorized endpoint
287-
let server_version = hs_api.join("/_synapse/admin/v1/server_version")?;
288-
let result = http_client.get(server_version.as_str()).send_traced().await;
289-
match result {
290-
Ok(response) => {
291-
let status = response.status();
292-
if status.is_success() {
293-
info!(r#"✅ The Synapse admin API is reachable at "{server_version}"."#);
294-
} else {
295-
error!(
296-
r#"❌ A Synapse admin API endpoint at "{server_version}" replied with {status}.
297-
Make sure MAS can reach the admin API, and that the homeserver is running.
298-
"#
299-
);
300-
}
301-
}
302-
Err(e) => error!(
303-
r#"❌ Can't reach the Synapse admin API at "{server_version}".
304-
Make sure MAS can reach the admin API, and that the homeserver is running.
305-
306278
Error details: {e}
307279
"#
308280
),
309281
}
310282

311283
// Try to reach an authenticated admin API endpoint
312-
let background_updates = hs_api.join("/_synapse/admin/v1/background_updates/status")?;
284+
let mas_api = hs_api.join("/_synapse/mas/is_localpart_available")?;
313285
let result = http_client
314-
.get(background_updates.as_str())
286+
.get(mas_api.as_str())
315287
.bearer_auth(&admin_token)
316288
.send_traced()
317289
.await;
318290
match result {
319291
Ok(response) => {
320292
let status = response.status();
321-
if status.is_success() {
293+
// We're missing the localpart parameter, so expect a 400
294+
if status == StatusCode::BAD_REQUEST {
322295
info!(
323-
r#"✅ The Synapse admin API is reachable with authentication at "{background_updates}"."#
296+
r#"✅ The Synapse admin API is reachable with authentication at "{mas_api}"."#
324297
);
325298
} else {
326299
error!(
327-
r#"❌ A Synapse admin API endpoint at "{background_updates}" replied with {status}.
300+
r#"❌ A Synapse admin API endpoint at "{mas_api}" replied with {status}.
328301
Make sure the homeserver is running, and that the MAS config has the correct `matrix.secret`.
329302
It should match the `admin_token` set in the Synapse config.
330303
331-
experimental_features:
332-
msc3861:
333-
enabled: true
334-
issuer: {issuer}
335-
# This must exactly match the secret in the MAS config:
336-
admin_token: {admin_token:?}
304+
matrix_authentication_service:
305+
enabled: true
306+
endpoint: {issuer:?}
307+
# This must exactly match the secret in the MAS config:
308+
secret: {admin_token:?}
337309
338310
And in the MAS config:
339311
@@ -346,7 +318,7 @@ And in the MAS config:
346318
}
347319
}
348320
Err(e) => error!(
349-
r#"❌ Can't reach the Synapse admin API at "{background_updates}".
321+
r#"❌ Can't reach the Synapse admin API at "{mas_api}".
350322
Make sure the homeserver is running, and that the MAS config has the correct `matrix.secret`.
351323
352324
Error details: {e}

0 commit comments

Comments
 (0)