mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2025-09-12 12:42:42 +00:00
Rename feature_flags to experimental_client_feature_flags
Additionally, use a caret (^) instead of an exclamation mark (!) to disable features
This commit is contained in:
parent
942462983d
commit
2d45af26b6
3 changed files with 17 additions and 19 deletions
|
@ -54,7 +54,7 @@ use crate::{
|
|||
auth::Headers,
|
||||
db::DbConn,
|
||||
error::Error,
|
||||
util::{get_reqwest_client, parse_feature_flags},
|
||||
util::{get_reqwest_client, parse_experimental_client_feature_flags},
|
||||
};
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
|
@ -192,8 +192,8 @@ fn version() -> Json<&'static str> {
|
|||
#[get("/config")]
|
||||
fn config() -> Json<Value> {
|
||||
let domain = crate::CONFIG.domain();
|
||||
let feature_states = parse_feature_flags(&crate::CONFIG.feature_flags());
|
||||
let mut config = json!({
|
||||
let feature_states = parse_experimental_client_feature_flags(&crate::CONFIG.experimental_client_feature_flags());
|
||||
Json(json!({
|
||||
// Note: The clients use this version to handle backwards compatibility concerns
|
||||
// This means they expect a version that closely matches the Bitwarden server version
|
||||
// We should make sure that we keep this updated when we support the new server features
|
||||
|
@ -213,10 +213,9 @@ fn config() -> Json<Value> {
|
|||
"notifications": format!("{domain}/notifications"),
|
||||
"sso": "",
|
||||
},
|
||||
"feature_states": feature_states,
|
||||
"object": "config",
|
||||
});
|
||||
config["featureStates"] = serde_json::to_value(feature_states).unwrap();
|
||||
Json(config)
|
||||
}))
|
||||
}
|
||||
|
||||
pub fn catchers() -> Vec<Catcher> {
|
||||
|
|
|
@ -9,7 +9,7 @@ use reqwest::Url;
|
|||
use crate::{
|
||||
db::DbConnType,
|
||||
error::Error,
|
||||
util::{get_env, get_env_bool, parse_feature_flags},
|
||||
util::{get_env, get_env_bool, parse_experimental_client_feature_flags},
|
||||
};
|
||||
|
||||
static CONFIG_FILE: Lazy<String> = Lazy::new(|| {
|
||||
|
@ -548,9 +548,9 @@ make_config! {
|
|||
authenticator_disable_time_drift: bool, true, def, false;
|
||||
|
||||
/// Customize the enabled feature flags on the clients |> This is a comma separated list of feature flags to en-/disable.
|
||||
/// Features are enabled by default which can be overridden by prefixing the feature with a `!`.
|
||||
/// Features are enabled by default which can be overridden by prefixing the feature with a `^`.
|
||||
/// Autofill v2 is disabled by default because it is causing issues https://github.com/dani-garcia/vaultwarden/discussions/4052
|
||||
feature_flags: String, false, def, "!autofill-v2,fido2-vault-credentials".to_string();
|
||||
experimental_client_feature_flags: String, false, def, "^autofill-v2,fido2-vault-credentials".to_string();
|
||||
|
||||
/// Require new device emails |> When a user logs in an email is required to be sent.
|
||||
/// If sending the email fails the login attempt will fail.
|
||||
|
@ -756,16 +756,15 @@ fn validate_config(cfg: &ConfigItems) -> Result<(), Error> {
|
|||
)
|
||||
}
|
||||
|
||||
const SUPPORTED_FLAGS: &[&str] = &[
|
||||
const KNOWN_FLAGS: &[&str] = &[
|
||||
"autofill-overlay",
|
||||
"autofill-v2",
|
||||
"browser-fileless-import",
|
||||
"display-kdf-iteration-warning",
|
||||
"fido2-vault-credentials",
|
||||
];
|
||||
for flag in parse_feature_flags(&cfg.feature_flags).keys() {
|
||||
if !SUPPORTED_FLAGS.contains(&flag.as_str()) {
|
||||
err!(format!("Feature flag {flag:?} is not supported."));
|
||||
for flag in parse_experimental_client_feature_flags(&cfg.experimental_client_feature_flags).keys() {
|
||||
if !KNOWN_FLAGS.contains(&flag.as_str()) {
|
||||
err!(format!("The experimental client feature flag {flag:?} is unrecognized. Please ensure the feature flag is spelled correctly, a caret (^) is used for disabling and that it is supported in this version."));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
10
src/util.rs
10
src/util.rs
|
@ -749,14 +749,14 @@ pub fn convert_json_key_lcase_first(src_json: Value) -> Value {
|
|||
}
|
||||
}
|
||||
|
||||
/// Parses the feature flags string into a HashMap.
|
||||
pub fn parse_feature_flags(feature_flags: &str) -> HashMap<String, bool> {
|
||||
let feature_flags_lowercase = feature_flags.to_lowercase();
|
||||
let features = feature_flags_lowercase.split(',').map(|f| f.trim()).collect::<Vec<_>>();
|
||||
/// Parses the experimental client feature flags string into a HashMap.
|
||||
pub fn parse_experimental_client_feature_flags(experimental_client_feature_flags: &str) -> HashMap<String, bool> {
|
||||
let experimental_client_feature_flags_lowercase = experimental_client_feature_flags.to_lowercase();
|
||||
let features = experimental_client_feature_flags_lowercase.split(',').map(|f| f.trim()).collect::<Vec<_>>();
|
||||
let mut feature_states: HashMap<String, bool> = HashMap::new();
|
||||
|
||||
for feature in features {
|
||||
let is_enabled = !feature.starts_with('!');
|
||||
let is_enabled = !feature.starts_with('^');
|
||||
let flag = if is_enabled {
|
||||
feature
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue