2019-05-26 02:29:30 +02:00
|
|
|
// Matrix Construct
|
|
|
|
//
|
|
|
|
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
|
|
|
// Copyright (C) 2016-2019 Jason Volk <jason@zemos.net>
|
|
|
|
//
|
|
|
|
// Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
|
|
// copyright notice and this permission notice is present in all copies. The
|
|
|
|
// full license for this software is available in the LICENSE file.
|
|
|
|
|
|
|
|
ircd::mapi::header
|
|
|
|
IRCD_MODULE
|
|
|
|
{
|
|
|
|
"Matrix Room Server Access Control List"
|
|
|
|
};
|
|
|
|
|
|
|
|
//
|
2019-05-27 05:57:55 +02:00
|
|
|
// vm hookfn's
|
2019-05-26 02:29:30 +02:00
|
|
|
//
|
|
|
|
|
|
|
|
namespace ircd::m
|
|
|
|
{
|
|
|
|
static void on_changed_room_server_acl(const m::event &, m::vm::eval &);
|
2019-05-27 05:57:55 +02:00
|
|
|
static void on_check_room_server_acl(const m::event &, m::vm::eval &);
|
|
|
|
|
2019-05-26 02:29:30 +02:00
|
|
|
extern m::hookfn<m::vm::eval &> changed_room_server_acl;
|
2019-05-27 05:57:55 +02:00
|
|
|
extern m::hookfn<m::vm::eval &> check_room_server_acl;
|
|
|
|
}
|
|
|
|
|
|
|
|
decltype(ircd::m::check_room_server_acl)
|
|
|
|
ircd::m::check_room_server_acl
|
|
|
|
{
|
|
|
|
on_check_room_server_acl,
|
|
|
|
{
|
|
|
|
{ "_site", "vm.access" },
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
ircd::m::on_check_room_server_acl(const event &event,
|
|
|
|
vm::eval &)
|
|
|
|
{
|
|
|
|
if(!m::room::server_acl::enable_write)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if(!m::room::server_acl::check(at<"room_id"_>(event), at<"origin"_>(event)))
|
2023-02-19 02:10:01 +01:00
|
|
|
throw vm::error
|
2019-05-27 05:57:55 +02:00
|
|
|
{
|
2023-02-19 02:10:01 +01:00
|
|
|
vm::fault::DENIED,
|
2019-05-27 05:57:55 +02:00
|
|
|
"Server '%s' denied by room %s access control list.",
|
|
|
|
at<"origin"_>(event),
|
|
|
|
at<"room_id"_>(event),
|
|
|
|
};
|
2019-05-26 02:29:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
decltype(ircd::m::changed_room_server_acl)
|
|
|
|
ircd::m::changed_room_server_acl
|
|
|
|
{
|
|
|
|
on_changed_room_server_acl,
|
|
|
|
{
|
|
|
|
{ "_site", "vm.notify" },
|
|
|
|
{ "type", "m.room.server_acl" },
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
ircd::m::on_changed_room_server_acl(const event &event,
|
|
|
|
vm::eval &)
|
|
|
|
{
|
|
|
|
log::info
|
|
|
|
{
|
|
|
|
m::log, "%s changed server access control list in %s [%s]",
|
|
|
|
json::get<"sender"_>(event),
|
|
|
|
json::get<"room_id"_>(event),
|
2019-07-06 07:01:34 +02:00
|
|
|
string_view{event.event_id},
|
2019-05-26 02:29:30 +02:00
|
|
|
};
|
|
|
|
}
|