mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2025-07-10 12:46:42 +02:00
feat(recaptcha): Add documentation for new fields
This commit is contained in:
parent
651d07a609
commit
df1cb10a8e
2 changed files with 29 additions and 15 deletions
|
@ -298,26 +298,27 @@ pub(crate) async fn register_route(
|
||||||
session: None,
|
session: None,
|
||||||
auth_error: None,
|
auth_error: None,
|
||||||
};
|
};
|
||||||
let mut skip_auth = false;
|
let mut skip_auth = body.appservice_info.is_some();
|
||||||
if services.globals.registration_token.is_some() {
|
if services.globals.registration_token.is_some() {
|
||||||
// Registration token required
|
// Registration token required
|
||||||
uiaainfo.flows.push(AuthFlow {
|
uiaainfo.flows.push(AuthFlow {
|
||||||
stages: vec![AuthType::RegistrationToken],
|
stages: vec![AuthType::RegistrationToken],
|
||||||
});
|
});
|
||||||
skip_auth = body.appservice_info.is_some();
|
|
||||||
}
|
}
|
||||||
if let Some(pubkey) = &services.config.recaptcha_site_key {
|
if !services.config.recaptcha_private_site_key.is_none() {
|
||||||
// ReCaptcha required
|
if let Some(pubkey) = &services.config.recaptcha_site_key {
|
||||||
uiaainfo
|
// ReCaptcha required
|
||||||
.flows
|
uiaainfo
|
||||||
.push(AuthFlow { stages: vec![AuthType::ReCaptcha] });
|
.flows
|
||||||
uiaainfo.params = serde_json::value::to_raw_value(&serde_json::json!({
|
.push(AuthFlow { stages: vec![AuthType::ReCaptcha] });
|
||||||
"m.login.recaptcha": {
|
uiaainfo.params = serde_json::value::to_raw_value(&serde_json::json!({
|
||||||
"public_key": pubkey,
|
"m.login.recaptcha": {
|
||||||
},
|
"public_key": pubkey,
|
||||||
}))
|
},
|
||||||
.expect("Failed to serialize recaptcha params");
|
}))
|
||||||
skip_auth = body.appservice_info.is_some() || skip_auth;
|
.expect("Failed to serialize recaptcha params");
|
||||||
|
skip_auth = skip_auth || is_guest;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// No registration token necessary, but clients must still go through the flow
|
// No registration token necessary, but clients must still go through the flow
|
||||||
uiaainfo = UiaaInfo {
|
uiaainfo = UiaaInfo {
|
||||||
|
@ -327,7 +328,7 @@ pub(crate) async fn register_route(
|
||||||
session: None,
|
session: None,
|
||||||
auth_error: None,
|
auth_error: None,
|
||||||
};
|
};
|
||||||
skip_auth = skip_auth || body.appservice_info.is_some() || is_guest;
|
skip_auth = skip_auth || is_guest;
|
||||||
};
|
};
|
||||||
|
|
||||||
if !skip_auth {
|
if !skip_auth {
|
||||||
|
|
|
@ -556,8 +556,21 @@ pub struct Config {
|
||||||
/// example: "/etc/continuwuity/.reg_token"
|
/// example: "/etc/continuwuity/.reg_token"
|
||||||
pub registration_token_file: Option<PathBuf>,
|
pub registration_token_file: Option<PathBuf>,
|
||||||
|
|
||||||
|
/// The public site key for reCaptcha. If this is provided, reCaptcha
|
||||||
|
/// becomes required during registration, **even if token registration is
|
||||||
|
/// enabled**.
|
||||||
|
///
|
||||||
|
/// IMPORTANT: "Verify the origin of reCAPTCHA solutions" **MUST** BE
|
||||||
|
/// DISABLED IF YOU WANT THE CAPTCHA TO WORK IN 3RD PARTY CLIENTS, OR
|
||||||
|
/// CLIENTS HOSTED ON DOMAINS OTHER THAN YOUR OWN!
|
||||||
|
///
|
||||||
|
/// Registration must be enabled (`allow_registration` must be true) for
|
||||||
|
/// this to have any effect.
|
||||||
pub recaptcha_site_key: Option<String>,
|
pub recaptcha_site_key: Option<String>,
|
||||||
|
|
||||||
|
/// The private site key for reCaptcha.
|
||||||
|
/// If this is omitted, captcha registration will not work,
|
||||||
|
/// even if `recaptcha_site_key` is set.
|
||||||
pub recaptcha_private_site_key: Option<String>,
|
pub recaptcha_private_site_key: Option<String>,
|
||||||
|
|
||||||
/// Controls whether encrypted rooms and events are allowed.
|
/// Controls whether encrypted rooms and events are allowed.
|
||||||
|
|
Loading…
Add table
Reference in a new issue