Adjust several integer types to be a lower or unsigned type.
Most types were too large, only because the function which used this
value needed that specific type. But, this allowed too large values
which either caused panics or might cause a DoS.
This does however might possible cause configurations which have larger
values, which are probably way too large anyway to be not loaded or use
their defaults. During the config loading, either via env or json, it
will show error logs regarding these items.
Also fixed an issue with protected actions via OTP, it increased the
attempt before it validated if the attempt limit was reached. This could
cause an issue when set to `1`, that way it was never allowed, and `3`
times would actually be `2`.
Also added several config validation checks which otherwise would have
prevent Vaultwarden to start, or login, so these will probably not cause
issues, else users would already have issues.
Signed-off-by: BlackDex <black.dex@gmail.com>
/// Events days retain |> Number of days to retain events stored in the database. If unset, events are kept indefinitely.
/// Events days retain |> Number of days to retain events stored in the database. If unset or 0, events are kept indefinitely.
events_days_retain: i64,false,option;
events_days_retain: u16,false,option;
},
},
client{
client{
@ -694,13 +700,13 @@ make_config! {
/// Temporary redirects are useful while testing different icon services, but once a service
/// Temporary redirects are useful while testing different icon services, but once a service
/// has been decided on, consider using permanent redirects for cacheability. The legacy codes
/// has been decided on, consider using permanent redirects for cacheability. The legacy codes
/// are currently better supported by the Bitwarden clients.
/// are currently better supported by the Bitwarden clients.
icon_redirect_code: u32,true,def,302;
icon_redirect_code: u16,true,def,302;
/// Positive icon cache expiry |> Number of seconds to consider that an already cached icon is fresh. After this period, the icon will be refreshed
/// Positive icon cache expiry |> Number of seconds to consider that an already cached icon is fresh. After this period, the icon will be refreshed
icon_cache_ttl: u64,true,def,2_592_000;
icon_cache_ttl: u32,true,def,2_592_000;
/// Negative icon cache expiry |> Number of seconds before trying to download an icon that failed again.
/// Negative icon cache expiry |> Number of seconds before trying to download an icon that failed again.
icon_cache_negttl: u64,true,def,259_200;
icon_cache_negttl: u32,true,def,259_200;
/// Icon download timeout |> Number of seconds when to stop attempting to download an icon.
/// Icon download timeout |> Number of seconds when to stop attempting to download an icon.
icon_download_timeout: u64,true,def,10;
icon_download_timeout: u16,true,def,10;
/// [Deprecated] Icon blacklist Regex |> Use `http_request_block_regex` instead
/// [Deprecated] Icon blacklist Regex |> Use `http_request_block_regex` instead
icon_blacklist_regex: String,false,option;
icon_blacklist_regex: String,false,option;
@ -751,11 +757,11 @@ make_config! {
/// Max database connection retries |> Number of times to retry the database connection during startup, with 1 second between each retry, set to 0 to retry indefinitely
/// Max database connection retries |> Number of times to retry the database connection during startup, with 1 second between each retry, set to 0 to retry indefinitely
db_connection_retries: u32,false,def,15;
db_connection_retries: u32,false,def,15;
/// Timeout when acquiring database connection
/// Timeout in seconds when acquiring database connection
database_timeout: u64,false,def,30;
database_timeout: u32,false,def,30;
/// Timeout in seconds before idle connections to the database are closed
/// Timeout in seconds before idle connections to the database are closed
/// Seconds between login requests |> Number of seconds, on average, between login and 2FA requests from the same IP address before rate limiting kicks in
/// Seconds between login requests |> Number of seconds, on average, between login and 2FA requests from the same IP address before rate limiting kicks in
login_ratelimit_seconds: u64,false,def,60;
login_ratelimit_seconds: u16,false,def,60;
/// Max burst size for login requests |> Allow a burst of requests of up to this size, while maintaining the average indicated by `login_ratelimit_seconds`. Note that this applies to both the login and the 2FA, so it's recommended to allow a burst size of at least 2
/// Max burst size for login requests |> Allow a burst of requests of up to this size, while maintaining the average indicated by `login_ratelimit_seconds`. Note that this applies to both the login and the 2FA, so it's recommended to allow a burst size of at least 2
login_ratelimit_max_burst: u32,false,def,10;
login_ratelimit_max_burst: u16,false,def,10;
/// Seconds between unauthenticated requests |> Number of seconds, on average, between requests from the same IP address to any of the rate limited unauthenticated endpoints
/// Seconds between unauthenticated requests |> Number of seconds, on average, between requests from the same IP address to any of the rate limited unauthenticated endpoints
/// Max burst size for unauthenticated requests |> Allow a burst of requests of up to this size, while maintaining the average indicated by `unauthenticated_ratelimit_seconds`. This is shared between several endpoints, so it needs to be more lenient than the login one
/// Max burst size for unauthenticated requests |> Allow a burst of requests of up to this size, while maintaining the average indicated by `unauthenticated_ratelimit_seconds`. This is shared between several endpoints, so it needs to be more lenient than the login one
/// Seconds between admin login requests |> Number of seconds, on average, between admin requests from the same IP address before rate limiting kicks in
/// Seconds between admin login requests |> Number of seconds, on average, between admin requests from the same IP address before rate limiting kicks in
admin_ratelimit_seconds: u64,false,def,300;
admin_ratelimit_seconds: u16,false,def,300;
/// Max burst size for admin login requests |> Allow a burst of requests of up to this size, while maintaining the average indicated by `admin_ratelimit_seconds`
/// Max burst size for admin login requests |> Allow a burst of requests of up to this size, while maintaining the average indicated by `admin_ratelimit_seconds`
admin_ratelimit_max_burst: u32,false,def,3;
admin_ratelimit_max_burst: u16,false,def,3;
/// Admin session lifetime |> Set the lifetime of admin sessions to this value (in minutes).
/// Admin session lifetime |> Set the lifetime of admin sessions to this value (in minutes).
admin_session_lifetime: i64,true,def,20;
admin_session_lifetime: u32,true,def,20;
/// Enable groups (BETA!) (Know the risks!) |> Enables groups support for organizations (Currently contains known issues!).
/// Enable groups (BETA!) (Know the risks!) |> Enables groups support for organizations (Currently contains known issues!).
org_groups_enabled: bool,false,def,false;
org_groups_enabled: bool,false,def,false;
@ -844,8 +850,8 @@ make_config! {
sso_master_password_policy: String,true,option;
sso_master_password_policy: String,true,option;
/// Use SSO only for auth not the session lifecycle |> Use default Vaultwarden session lifecycle (Idle refresh token valid for 30days)
/// Use SSO only for auth not the session lifecycle |> Use default Vaultwarden session lifecycle (Idle refresh token valid for 30days)
sso_auth_only_not_session: bool,true,def,false;
sso_auth_only_not_session: bool,true,def,false;
/// Client cache for discovery endpoint. |> Duration in seconds (0 or less to disable). More details: https://github.com/dani-garcia/vaultwarden/wiki/Enabling-SSO-support-using-OpenId-Connect#client-cache
/// Client cache for discovery endpoint. |> Duration in seconds (0 to disable). More details: https://github.com/dani-garcia/vaultwarden/wiki/Enabling-SSO-support-using-OpenId-Connect#client-cache
sso_client_cache_expiration: u64,true,def,0;
sso_client_cache_expiration: u32,true,def,0;
/// Log all tokens |> `LOG_LEVEL=debug` or `LOG_LEVEL=info,vaultwarden::sso=debug` is required
/// Log all tokens |> `LOG_LEVEL=debug` or `LOG_LEVEL=info,vaultwarden::sso=debug` is required
sso_debug_tokens: bool,true,def,false;
sso_debug_tokens: bool,true,def,false;
},
},
@ -903,7 +909,7 @@ make_config! {
/// SMTP Auth mechanism |> Defaults for SSL is "Plain" and "Login" and nothing for Non-SSL connections. Possible values: ["Plain", "Login", "Xoauth2"]. Multiple options need to be separated by a comma ','.
/// SMTP Auth mechanism |> Defaults for SSL is "Plain" and "Login" and nothing for Non-SSL connections. Possible values: ["Plain", "Login", "Xoauth2"]. Multiple options need to be separated by a comma ','.
smtp_auth_mechanism: String,true,option;
smtp_auth_mechanism: String,true,option;
/// SMTP connection timeout |> Number of seconds when to stop trying to connect to the SMTP server
/// SMTP connection timeout |> Number of seconds when to stop trying to connect to the SMTP server
smtp_timeout: u64,true,def,15;
smtp_timeout: u16,true,def,15;
/// Server name sent during HELO |> By default this value should be the machine's hostname, but might need to be changed in case it trips some anti-spam filters
/// Server name sent during HELO |> By default this value should be the machine's hostname, but might need to be changed in case it trips some anti-spam filters
helo_name: String,true,option;
helo_name: String,true,option;
/// Embed images as email attachments.
/// Embed images as email attachments.
@ -925,9 +931,9 @@ make_config! {
/// Email token size |> Number of digits in an email 2FA token (min: 6, max: 255). Note that the Bitwarden clients are hardcoded to mention 6 digit codes regardless of this setting.
/// Email token size |> Number of digits in an email 2FA token (min: 6, max: 255). Note that the Bitwarden clients are hardcoded to mention 6 digit codes regardless of this setting.
email_token_size: u8,true,def,6;
email_token_size: u8,true,def,6;
/// Token expiration time |> Maximum time in seconds a token is valid. The time the user has to open email client and copy token.
/// Token expiration time |> Maximum time in seconds a token is valid. The time the user has to open email client and copy token.
email_expiration_time: u64,true,def,600;
email_expiration_time: u32,true,def,600;
/// Maximum attempts |> Maximum attempts before an email token is reset and a new email will need to be sent
/// Maximum attempts |> Maximum attempts before an email token is reset and a new email will need to be sent
email_attempts_limit: u64,true,def,3;
email_attempts_limit: u8,true,def,3;
/// Setup email 2FA at signup |> Setup email 2FA provider on registration regardless of any organization policy
/// Setup email 2FA at signup |> Setup email 2FA provider on registration regardless of any organization policy