mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2025-09-03 16:28:10 +00:00
fix cargo check + rewrite config + add check url
This commit is contained in:
parent
f8906c5575
commit
6c9c97d17e
3 changed files with 34 additions and 18 deletions
|
@ -81,9 +81,6 @@
|
|||
# PUSH_INSTALLATION_ID=CHANGEME
|
||||
# PUSH_INSTALLATION_KEY=CHANGEME
|
||||
# PUSH_RELAY_REGION=us
|
||||
## Don't change this unless you know what you're doing.
|
||||
# PUSH_RELAY_URI=https://push.bitwarden.com
|
||||
# IDENTITY_URI=https://identity.bitwarden.com
|
||||
|
||||
## Controls whether users are allowed to create Bitwarden Sends.
|
||||
## This setting applies globally to all users.
|
||||
|
|
|
@ -50,8 +50,7 @@ async fn get_auth_push_token() -> ApiResult<String> {
|
|||
("client_secret", &client_secret),
|
||||
];
|
||||
|
||||
let res = match get_reqwest_client().post(CONFIG.identity_uri()).form(¶ms).send().await
|
||||
{
|
||||
let res = match get_reqwest_client().post(CONFIG.push_identity_uri()).form(¶ms).send().await {
|
||||
Ok(r) => r,
|
||||
Err(e) => err!(format!("Error getting push token from bitwarden server: {e}")),
|
||||
};
|
||||
|
|
|
@ -380,25 +380,25 @@ make_config! {
|
|||
push {
|
||||
/// Enable push notifications
|
||||
push_enabled: bool, false, def, false;
|
||||
/// Push relay region |> The data region from https://bitwarden.com/host
|
||||
/// Push relay region
|
||||
push_relay_region: String, false, def, "us".to_string();
|
||||
/// Push relay uri
|
||||
push_relay_uri: String, false, auto, |c| {
|
||||
let relay_region = match c.push_relay_region.as_str() {
|
||||
"us" => "com",
|
||||
"eu" => "eu",
|
||||
_ => "com", // Default to US if the region is not recognized
|
||||
let push_relay_uri = match c.push_relay_region.as_str() {
|
||||
"us" => "https://push.bitwarden.com".to_string(),
|
||||
"eu" => "https://push.bitwarden.eu".to_string(),
|
||||
_ => "https://push.bitwarden.com".to_string(), // Default to "us" region
|
||||
};
|
||||
format!("https://push.bitwarden.{}", relay_region)
|
||||
return push_relay_uri;
|
||||
};
|
||||
/// Identity uri
|
||||
identity_uri: String, false, auto, |c| {
|
||||
let relay_region = match c.push_relay_region.as_str() {
|
||||
"us" => "com",
|
||||
"eu" => "eu",
|
||||
_ => "com", // Default to US if the region is not recognized
|
||||
/// Push identity uri
|
||||
push_identity_uri: String, false, auto, |c| {
|
||||
let push_identity_uri = match c.push_relay_region.as_str() {
|
||||
"us" => "https://identity.bitwarden.com".to_string(),
|
||||
"eu" => "https://identity.bitwarden.eu".to_string(),
|
||||
_ => "https://identity.bitwarden.com".to_string(), // Default to "us" region
|
||||
};
|
||||
format!("https://identity.bitwarden.{}", relay_region)
|
||||
return push_identity_uri;
|
||||
};
|
||||
/// Installation id |> The installation id from https://bitwarden.com/host
|
||||
push_installation_id: Pass, false, def, String::new();
|
||||
|
@ -769,6 +769,26 @@ fn validate_config(cfg: &ConfigItems) -> Result<(), Error> {
|
|||
)
|
||||
}
|
||||
|
||||
if cfg.push_enabled {
|
||||
let push_relay_uri = cfg.push_relay_uri.to_lowercase();
|
||||
if !push_relay_uri.starts_with("https://") {
|
||||
err!("`PUSH_RELAY_URI` must start with 'https://'.")
|
||||
}
|
||||
|
||||
if let Err(_) = Url::parse(&push_relay_uri) {
|
||||
err!("Invalid URL format for `PUSH_RELAY_URI`.");
|
||||
}
|
||||
|
||||
let push_identity_uri = cfg.push_identity_uri.to_lowercase();
|
||||
if !push_identity_uri.starts_with("https://") {
|
||||
err!("`PUSH_IDENTITY_URI` must start with 'https://'.")
|
||||
}
|
||||
|
||||
if let Err(_) = Url::parse(&push_identity_uri) {
|
||||
err!("Invalid URL format for `PUSH_IDENTITY_URI`.");
|
||||
}
|
||||
}
|
||||
|
||||
if cfg._enable_duo
|
||||
&& (cfg.duo_host.is_some() || cfg.duo_ikey.is_some() || cfg.duo_skey.is_some())
|
||||
&& !(cfg.duo_host.is_some() && cfg.duo_ikey.is_some() && cfg.duo_skey.is_some())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue