mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-25 01:47:32 +00:00
refactor: Represent route auth information in the type system
This commit is contained in:
78 files changed
+496
-482
No files matched your search
@@ -30,7 +30,7 @@ use crate::Ruma;
|
||||
/// # `GET /_matrix/federation/v1/make_join/{roomId}/{userId}`
|
||||
///
|
||||
/// Creates a join template.
|
||||
#[tracing::instrument(skip_all, fields(room_id = %body.room_id, user_id = %body.user_id, origin = %body.origin()), level = "info")]
|
||||
#[tracing::instrument(skip_all, fields(room_id = %body.room_id, user_id = %body.user_id, origin = %body.identity), level = "info")]
|
||||
pub(crate) async fn create_join_event_template_route(
|
||||
State(services): State<crate::State>,
|
||||
body: Ruma<prepare_join_event::v1::Request>,
|
||||
@@ -45,14 +45,14 @@ pub(crate) async fn create_join_event_template_route(
|
||||
.await
|
||||
{
|
||||
info!(
|
||||
origin = body.origin().as_str(),
|
||||
origin = body.identity.as_str(),
|
||||
room_id = %body.room_id,
|
||||
"Refusing to serve make_join for room we aren't participating in"
|
||||
);
|
||||
return Err!(Request(NotFound("This server is not participating in that room.")));
|
||||
}
|
||||
|
||||
if body.user_id.server_name() != body.origin() {
|
||||
if body.user_id.server_name() != body.identity {
|
||||
return Err!(Request(BadJson("Not allowed to join on behalf of another server/user.")));
|
||||
}
|
||||
|
||||
@@ -60,19 +60,17 @@ pub(crate) async fn create_join_event_template_route(
|
||||
services
|
||||
.rooms
|
||||
.event_handler
|
||||
.acl_check(body.origin(), &body.room_id)
|
||||
.acl_check(&body.identity, &body.room_id)
|
||||
.await?;
|
||||
|
||||
if services
|
||||
.moderation
|
||||
.is_remote_server_forbidden(body.origin())
|
||||
.is_remote_server_forbidden(&body.identity)
|
||||
{
|
||||
warn!(
|
||||
"Server {} for remote user {} tried joining room ID {} which has a server name that \
|
||||
is globally forbidden. Rejecting.",
|
||||
body.origin(),
|
||||
&body.user_id,
|
||||
&body.room_id,
|
||||
body.identity, &body.user_id, &body.room_id,
|
||||
);
|
||||
return Err!(Request(Forbidden("Server is banned on this homeserver.")));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user