1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-08-09 04:22:45 +03:00

Interface to allow cross-signing reset using Synapse admin API

This commit is contained in:
Quentin Gliech
2023-11-22 18:22:57 +01:00
parent 83bf739538
commit 5957112ff6
3 changed files with 61 additions and 0 deletions

View File

@@ -130,6 +130,9 @@ struct SynapseDeactivateUserRequest {
erase: bool,
}
#[derive(Serialize)]
struct SynapseAllowCrossSigningResetRequest {}
#[async_trait::async_trait]
impl HomeserverConnection for SynapseConnection {
type Error = anyhow::Error;
@@ -366,4 +369,37 @@ impl HomeserverConnection for SynapseConnection {
async fn unset_displayname(&self, mxid: &str) -> Result<(), Self::Error> {
self.set_displayname(mxid, "").await
}
#[tracing::instrument(
name = "homeserver.allow_cross_signing_reset",
skip_all,
fields(
matrix.homeserver = self.homeserver,
matrix.mxid = mxid,
),
err(Display),
)]
async fn allow_cross_signing_reset(&self, mxid: &str) -> Result<(), Self::Error> {
let mut client = self
.http_client_factory
.client("homeserver.allow_cross_signing_reset")
.request_bytes_to_body()
.json_request();
let request = self
.post(&format!(
"_synapse/admin/v1/users/{mxid}/_allow_cross_signing_replacement_without_uia"
))
.body(SynapseAllowCrossSigningResetRequest {})?;
let response = client.ready().await?.call(request).await?;
if response.status() != StatusCode::OK {
return Err(anyhow::anyhow!(
"Failed to allow cross signing reset in Synapse"
));
}
Ok(())
}
}