Skip to content

Commit d184c8f

Browse files
authored
Fix keyword collision in Rust 2024 and add new api/config value (#4975)
* Avoid keyword collision with gen in Rust 2024 * Include new api/config setting to disable user registration, not yet used by clients * Actually qualify CONFIG
1 parent 7d6dec6 commit d184c8f

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

src/api/core/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ fn config() -> Json<Value> {
204204
"name": "Vaultwarden",
205205
"url": "https://github.com/dani-garcia/vaultwarden"
206206
},
207+
"settings": {
208+
"disableUserRegistration": !crate::CONFIG.signups_allowed() && crate::CONFIG.signups_domains_whitelist().is_empty(),
209+
},
207210
"environment": {
208211
"vault": domain,
209212
"api": format!("{domain}/api"),

src/config.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ macro_rules! make_config {
331331
}
332332
}
333333
}};
334-
( @build $value:expr, $config:expr, gen, $default_fn:expr ) => {{
334+
( @build $value:expr, $config:expr, generated, $default_fn:expr ) => {{
335335
let f: &dyn Fn(&ConfigItems) -> _ = &$default_fn;
336336
f($config)
337337
}};
@@ -349,10 +349,10 @@ macro_rules! make_config {
349349
// }
350350
//
351351
// Where action applied when the value wasn't provided and can be:
352-
// def: Use a default value
353-
// auto: Value is auto generated based on other values
354-
// option: Value is optional
355-
// gen: Value is always autogenerated and it's original value ignored
352+
// def: Use a default value
353+
// auto: Value is auto generated based on other values
354+
// option: Value is optional
355+
// generated: Value is always autogenerated and it's original value ignored
356356
make_config! {
357357
folders {
358358
/// Data folder |> Main data folder
@@ -515,7 +515,7 @@ make_config! {
515515
/// Set to the string "none" (without quotes), to disable any headers and just use the remote IP
516516
ip_header: String, true, def, "X-Real-IP".to_string();
517517
/// Internal IP header property, used to avoid recomputing each time
518-
_ip_header_enabled: bool, false, gen, |c| &c.ip_header.trim().to_lowercase() != "none";
518+
_ip_header_enabled: bool, false, generated, |c| &c.ip_header.trim().to_lowercase() != "none";
519519
/// Icon service |> The predefined icon services are: internal, bitwarden, duckduckgo, google.
520520
/// To specify a custom icon service, set a URL template with exactly one instance of `{}`,
521521
/// which is replaced with the domain. For example: `https://icon.example.com/domain/{}`.
@@ -524,9 +524,9 @@ make_config! {
524524
/// corresponding icon at the external service.
525525
icon_service: String, false, def, "internal".to_string();
526526
/// _icon_service_url
527-
_icon_service_url: String, false, gen, |c| generate_icon_service_url(&c.icon_service);
527+
_icon_service_url: String, false, generated, |c| generate_icon_service_url(&c.icon_service);
528528
/// _icon_service_csp
529-
_icon_service_csp: String, false, gen, |c| generate_icon_service_csp(&c.icon_service, &c._icon_service_url);
529+
_icon_service_csp: String, false, generated, |c| generate_icon_service_csp(&c.icon_service, &c._icon_service_url);
530530
/// Icon redirect code |> The HTTP status code to use for redirects to an external icon service.
531531
/// The supported codes are 301 (legacy permanent), 302 (legacy temporary), 307 (temporary), and 308 (permanent).
532532
/// Temporary redirects are useful while testing different icon services, but once a service
@@ -624,7 +624,7 @@ make_config! {
624624
/// WARNING: This could cause issues with clients. Also exports will not work on Bitwarden servers!
625625
increase_note_size_limit: bool, true, def, false;
626626
/// Generated max_note_size value to prevent if..else matching during every check
627-
_max_note_size: usize, false, gen, |c| if c.increase_note_size_limit {100_000} else {10_000};
627+
_max_note_size: usize, false, generated, |c| if c.increase_note_size_limit {100_000} else {10_000};
628628

629629
/// Enforce Single Org with Reset Password Policy |> Enforce that the Single Org policy is enabled before setting the Reset Password policy
630630
/// Bitwarden enforces this by default. In Vaultwarden we encouraged to use multiple organizations because groups were not available.
@@ -695,7 +695,7 @@ make_config! {
695695
/// Embed images as email attachments.
696696
smtp_embed_images: bool, true, def, true;
697697
/// _smtp_img_src
698-
_smtp_img_src: String, false, gen, |c| generate_smtp_img_src(c.smtp_embed_images, &c.domain);
698+
_smtp_img_src: String, false, generated, |c| generate_smtp_img_src(c.smtp_embed_images, &c.domain);
699699
/// Enable SMTP debugging (Know the risks!) |> DANGEROUS: Enabling this will output very detailed SMTP messages. This could contain sensitive information like passwords and usernames! Only enable this during troubleshooting!
700700
smtp_debug: bool, false, def, false;
701701
/// Accept Invalid Certs (Know the risks!) |> DANGEROUS: Allow invalid certificates. This option introduces significant vulnerabilities to man-in-the-middle attacks!

0 commit comments

Comments
 (0)