Browse Source

add selection of data region for push

pull/3752/head
toto-xoxo 2 years ago
committed by Mathijs van Veluw
parent
commit
f8906c5575
  1. 2
      .env.template
  2. 2
      src/api/push.rs
  3. 22
      src/config.rs

2
.env.template

@ -80,8 +80,10 @@
# PUSH_ENABLED=true # PUSH_ENABLED=true
# PUSH_INSTALLATION_ID=CHANGEME # PUSH_INSTALLATION_ID=CHANGEME
# PUSH_INSTALLATION_KEY=CHANGEME # PUSH_INSTALLATION_KEY=CHANGEME
# PUSH_RELAY_REGION=us
## Don't change this unless you know what you're doing. ## Don't change this unless you know what you're doing.
# PUSH_RELAY_URI=https://push.bitwarden.com # PUSH_RELAY_URI=https://push.bitwarden.com
# IDENTITY_URI=https://identity.bitwarden.com
## Controls whether users are allowed to create Bitwarden Sends. ## Controls whether users are allowed to create Bitwarden Sends.
## This setting applies globally to all users. ## This setting applies globally to all users.

2
src/api/push.rs

@ -50,7 +50,7 @@ async fn get_auth_push_token() -> ApiResult<String> {
("client_secret", &client_secret), ("client_secret", &client_secret),
]; ];
let res = match get_reqwest_client().post("https://identity.bitwarden.com/connect/token").form(&params).send().await let res = match get_reqwest_client().post(CONFIG.identity_uri()).form(&params).send().await
{ {
Ok(r) => r, Ok(r) => r,
Err(e) => err!(format!("Error getting push token from bitwarden server: {e}")), Err(e) => err!(format!("Error getting push token from bitwarden server: {e}")),

22
src/config.rs

@ -380,8 +380,26 @@ make_config! {
push { push {
/// Enable push notifications /// Enable push notifications
push_enabled: bool, false, def, false; push_enabled: bool, false, def, false;
/// Push relay base uri /// Push relay region |> The data region from https://bitwarden.com/host
push_relay_uri: String, false, def, "https://push.bitwarden.com".to_string(); 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
};
format!("https://push.bitwarden.{}", relay_region)
};
/// 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
};
format!("https://identity.bitwarden.{}", relay_region)
};
/// Installation id |> The installation id from https://bitwarden.com/host /// Installation id |> The installation id from https://bitwarden.com/host
push_installation_id: Pass, false, def, String::new(); push_installation_id: Pass, false, def, String::new();
/// Installation key |> The installation key from https://bitwarden.com/host /// Installation key |> The installation key from https://bitwarden.com/host

Loading…
Cancel
Save