add option for explicit opt-in allow open registration and make it clear
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
5e641e2886
commit
d214371423
4 changed files with 43 additions and 3 deletions
|
@ -35,8 +35,19 @@ port = 6167
|
||||||
# Max size for uploads
|
# Max size for uploads
|
||||||
max_request_size = 20_000_000 # in bytes
|
max_request_size = 20_000_000 # in bytes
|
||||||
|
|
||||||
# Enables registration. If set to false, no users can register on this server.
|
# Enables open registration. If set to false, no users can register on this
|
||||||
allow_registration = true
|
# server (unless a token is configured).
|
||||||
|
# If set to true, users can register with no form of 2nd step only if you set
|
||||||
|
# `yes_i_am_very_very_sure_i_want_an_open_registration_server_prone_to_abuse` to
|
||||||
|
# in your config. If you would like
|
||||||
|
# registration only via token reg, please set this to *false* and configure the
|
||||||
|
# `registration_token` key.
|
||||||
|
allow_registration = false
|
||||||
|
|
||||||
|
# A static registration token that new users will have to provide when creating
|
||||||
|
# an account. If unset and `allow_registration` is true, registration is open
|
||||||
|
# without any condition. YOU NEED TO EDIT THIS.
|
||||||
|
registration_token = "change this token for something specific to your server"
|
||||||
|
|
||||||
allow_federation = true
|
allow_federation = true
|
||||||
allow_check_for_updates = true
|
allow_check_for_updates = true
|
||||||
|
|
|
@ -50,6 +50,8 @@ pub struct Config {
|
||||||
pub max_fetch_prev_events: u16,
|
pub max_fetch_prev_events: u16,
|
||||||
#[serde(default = "false_fn")]
|
#[serde(default = "false_fn")]
|
||||||
pub allow_registration: bool,
|
pub allow_registration: bool,
|
||||||
|
#[serde(default = "false_fn")]
|
||||||
|
pub yes_i_am_very_very_sure_i_want_an_open_registration_server_prone_to_abuse: bool,
|
||||||
pub registration_token: Option<String>,
|
pub registration_token: Option<String>,
|
||||||
#[serde(default = "true_fn")]
|
#[serde(default = "true_fn")]
|
||||||
pub allow_encryption: bool,
|
pub allow_encryption: bool,
|
||||||
|
@ -197,7 +199,10 @@ impl fmt::Display for Config {
|
||||||
"Maximum concurrent requests",
|
"Maximum concurrent requests",
|
||||||
&self.max_concurrent_requests.to_string(),
|
&self.max_concurrent_requests.to_string(),
|
||||||
),
|
),
|
||||||
("Allow registration", &self.allow_registration.to_string()),
|
(
|
||||||
|
"Allow registration (open registration)",
|
||||||
|
&self.allow_registration.to_string(),
|
||||||
|
),
|
||||||
(
|
(
|
||||||
"Allow guest registration",
|
"Allow guest registration",
|
||||||
&self.allow_guest_registration.to_string(),
|
&self.allow_guest_registration.to_string(),
|
||||||
|
|
17
src/main.rs
17
src/main.rs
|
@ -156,6 +156,23 @@ async fn main() {
|
||||||
};
|
};
|
||||||
let config = &services().globals.config;
|
let config = &services().globals.config;
|
||||||
|
|
||||||
|
if config.allow_registration
|
||||||
|
&& !config.yes_i_am_very_very_sure_i_want_an_open_registration_server_prone_to_abuse
|
||||||
|
{
|
||||||
|
error!("!! WARNING: You have `allow_registration` enabled in your config which means you are allowing ANYONE to register on your conduwuit instance without any 2nd-step (e.g. registration token).\n
|
||||||
|
If this is not the intended behaviour, please disable `allow_registration` and set a registration token.\n
|
||||||
|
For security and safety reasons, conduwuit will shut down. If you are extra sure this is the desired behaviour you want, please set the following config option to true:
|
||||||
|
`yes_i_am_very_very_sure_i_want_an_open_registration_server_prone_to_abuse`");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.allow_registration
|
||||||
|
&& config.yes_i_am_very_very_sure_i_want_an_open_registration_server_prone_to_abuse
|
||||||
|
{
|
||||||
|
error!("Open registration is enabled via setting `yes_i_am_very_very_sure_i_want_an_open_registration_server_prone_to_abuse` and `allow_registration` to true. You are expected to be aware of the risks now.\n
|
||||||
|
If this is not the desired behaviour, please disable `allow_registration` and set a registration token.");
|
||||||
|
}
|
||||||
|
|
||||||
info!("Starting server");
|
info!("Starting server");
|
||||||
run_server().await.unwrap();
|
run_server().await.unwrap();
|
||||||
|
|
||||||
|
|
|
@ -307,6 +307,13 @@ impl Service<'_> {
|
||||||
self.config.allow_guest_registration
|
self.config.allow_guest_registration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn yes_i_am_very_very_sure_i_want_an_open_registration_server_prone_to_abuse(
|
||||||
|
&self,
|
||||||
|
) -> bool {
|
||||||
|
self.config
|
||||||
|
.yes_i_am_very_very_sure_i_want_an_open_registration_server_prone_to_abuse
|
||||||
|
}
|
||||||
|
|
||||||
pub fn allow_encryption(&self) -> bool {
|
pub fn allow_encryption(&self) -> bool {
|
||||||
self.config.allow_encryption
|
self.config.allow_encryption
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue