diff --git a/.env.template b/.env.template index 3b787be4c77..2047acbe67f 100644 --- a/.env.template +++ b/.env.template @@ -69,8 +69,8 @@ # WEB_VAULT_FOLDER=web-vault/ # WEB_VAULT_ENABLED=true -## Disable websocket notifications -# WEBSOCKET_DISABLED=false +## Enable websocket notifications +# ENABLE_WEBSOCKET=true ## Enables push notifications (requires key and id from https://bitwarden.com/host) # PUSH_ENABLED=true diff --git a/Cargo.lock b/Cargo.lock index fcfd4a6d7c2..0f8f854c69a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -154,7 +154,7 @@ dependencies = [ "log", "parking", "polling", - "rustix 0.37.26", + "rustix 0.37.27", "slab", "socket2 0.4.10", "waker-fn", @@ -182,7 +182,7 @@ dependencies = [ "cfg-if", "event-listener 3.0.0", "futures-lite", - "rustix 0.38.20", + "rustix 0.38.21", "windows-sys", ] @@ -198,7 +198,7 @@ dependencies = [ "cfg-if", "futures-core", "futures-io", - "rustix 0.38.20", + "rustix 0.38.21", "signal-hook-registry", "slab", "windows-sys", @@ -545,9 +545,9 @@ dependencies = [ [[package]] name = "cookie" -version = "0.17.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7efb37c3e1ccb1ff97164ad95ac1606e8ccd35b3fa0a7d99a304c7f4a428cc24" +checksum = "3cd91cf61412820176e137621345ee43b3f4423e589e7ae4e50d601d93e35ef8" dependencies = [ "percent-encoding", "time", @@ -606,9 +606,9 @@ checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" [[package]] name = "cpufeatures" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fbc60abd742b35f2492f808e1abbb83d45f72db402e14c55057edc9c7b1e9e4" +checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" dependencies = [ "libc", ] @@ -957,7 +957,7 @@ dependencies = [ "atomic 0.6.0", "pear", "serde", - "toml 0.8.4", + "toml 0.8.5", "uncased", "version_check", ] @@ -1004,9 +1004,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" dependencies = [ "futures-channel", "futures-core", @@ -1019,9 +1019,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" dependencies = [ "futures-core", "futures-sink", @@ -1029,15 +1029,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" +checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" [[package]] name = "futures-executor" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" +checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" dependencies = [ "futures-core", "futures-task", @@ -1046,9 +1046,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" +checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" [[package]] name = "futures-lite" @@ -1067,9 +1067,9 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" +checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" dependencies = [ "proc-macro2", "quote", @@ -1078,15 +1078,15 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" +checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" [[package]] name = "futures-task" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" +checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" [[package]] name = "futures-timer" @@ -1096,9 +1096,9 @@ checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" [[package]] name = "futures-util" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" dependencies = [ "futures-channel", "futures-core", @@ -1433,7 +1433,6 @@ checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", "hashbrown 0.12.3", - "serde", ] [[package]] @@ -1444,6 +1443,7 @@ checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" dependencies = [ "equivalent", "hashbrown 0.14.2", + "serde", ] [[package]] @@ -1497,7 +1497,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi", - "rustix 0.38.20", + "rustix 0.38.21", "windows-sys", ] @@ -2018,7 +2018,7 @@ checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.4.1", + "redox_syscall", "smallvec", "windows-targets", ] @@ -2057,7 +2057,7 @@ checksum = "61a386cd715229d399604b50d1361683fe687066f42d56f54be995bc6868f71c" dependencies = [ "inlinable_string", "pear_codegen", - "yansi 1.0.0-rc.1", + "yansi", ] [[package]] @@ -2262,7 +2262,7 @@ dependencies = [ "quote", "syn 2.0.38", "version_check", - "yansi 1.0.0-rc.1", + "yansi", ] [[package]] @@ -2377,15 +2377,6 @@ dependencies = [ "bitflags 1.3.2", ] -[[package]] -name = "redox_syscall" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "redox_syscall" version = "0.4.1" @@ -2563,7 +2554,7 @@ dependencies = [ [[package]] name = "rocket" version = "0.5.0-rc.3" -source = "git+https://github.com/SergioBenitez/Rocket?rev=ce441b5f46fdf5cd99cb32b8b8638835e4c2a5fa#ce441b5f46fdf5cd99cb32b8b8638835e4c2a5fa" +source = "git+https://github.com/SergioBenitez/Rocket?rev=923b61edf37424692a32727513b0062283ead741#923b61edf37424692a32727513b0062283ead741" dependencies = [ "async-stream", "async-trait", @@ -2573,8 +2564,7 @@ dependencies = [ "either", "figment", "futures", - "indexmap 1.9.3", - "is-terminal", + "indexmap 2.0.2", "log", "memchr", "multer", @@ -2595,35 +2585,36 @@ dependencies = [ "tokio-util", "ubyte", "version_check", - "yansi 0.5.1", + "yansi", ] [[package]] name = "rocket_codegen" version = "0.5.0-rc.3" -source = "git+https://github.com/SergioBenitez/Rocket?rev=ce441b5f46fdf5cd99cb32b8b8638835e4c2a5fa#ce441b5f46fdf5cd99cb32b8b8638835e4c2a5fa" +source = "git+https://github.com/SergioBenitez/Rocket?rev=923b61edf37424692a32727513b0062283ead741#923b61edf37424692a32727513b0062283ead741" dependencies = [ "devise", "glob", - "indexmap 1.9.3", + "indexmap 2.0.2", "proc-macro2", "quote", "rocket_http", "syn 2.0.38", "unicode-xid", + "version_check", ] [[package]] name = "rocket_http" version = "0.5.0-rc.3" -source = "git+https://github.com/SergioBenitez/Rocket?rev=ce441b5f46fdf5cd99cb32b8b8638835e4c2a5fa#ce441b5f46fdf5cd99cb32b8b8638835e4c2a5fa" +source = "git+https://github.com/SergioBenitez/Rocket?rev=923b61edf37424692a32727513b0062283ead741#923b61edf37424692a32727513b0062283ead741" dependencies = [ - "cookie 0.17.0", + "cookie 0.18.0", "either", "futures", "http", "hyper", - "indexmap 1.9.3", + "indexmap 2.0.2", "log", "memchr", "pear", @@ -2645,7 +2636,7 @@ dependencies = [ [[package]] name = "rocket_ws" version = "0.1.0-rc.3" -source = "git+https://github.com/SergioBenitez/Rocket?rev=ce441b5f46fdf5cd99cb32b8b8638835e4c2a5fa#ce441b5f46fdf5cd99cb32b8b8638835e4c2a5fa" +source = "git+https://github.com/SergioBenitez/Rocket?rev=923b61edf37424692a32727513b0062283ead741#923b61edf37424692a32727513b0062283ead741" dependencies = [ "rocket", "tokio-tungstenite", @@ -2680,9 +2671,9 @@ checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "rustix" -version = "0.37.26" +version = "0.37.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84f3f8f960ed3b5a59055428714943298bf3fa2d4a1d53135084e0544829d995" +checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2" dependencies = [ "bitflags 1.3.2", "errno", @@ -2694,9 +2685,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.20" +version = "0.38.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67ce50cb2e16c2903e30d1cbccfd8387a74b9d4c938b6a4c5ec6cc7556f7a8a0" +checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3" dependencies = [ "bitflags 2.4.1", "errno", @@ -2828,9 +2819,9 @@ checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" [[package]] name = "serde" -version = "1.0.189" +version = "1.0.190" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e422a44e74ad4001bdc8eede9a4570ab52f71190e9c076d14369f38b9200537" +checksum = "91d3c334ca1ee894a2c6f6ad698fe8c435b76d504b13d436f0685d648d6d96f7" dependencies = [ "serde_derive", ] @@ -2847,9 +2838,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.189" +version = "1.0.190" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e48d1f918009ce3145511378cf68d613e3b3d9137d67272562080d68a2b32d5" +checksum = "67c5609f394e5c2bd7fc51efda478004ea80ef42fee983d5c67a65e34f32c0e3" dependencies = [ "proc-macro2", "quote", @@ -3109,14 +3100,14 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.8.0" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" +checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" dependencies = [ "cfg-if", "fastrand 2.0.1", - "redox_syscall 0.3.5", - "rustix 0.38.20", + "redox_syscall", + "rustix 0.38.21", "windows-sys", ] @@ -3280,9 +3271,9 @@ dependencies = [ [[package]] name = "tokio-tungstenite" -version = "0.19.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec509ac96e9a0c43427c74f003127d953a265737636129424288d27cb5c4b12c" +checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" dependencies = [ "futures-util", "log", @@ -3318,14 +3309,14 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ef75d881185fd2df4a040793927c153d863651108a93c7e17a9e591baa95cc6" +checksum = "3efaf127c78d5339cc547cce4e4d973bd5e4f56e949a06d091c082ebeef2f800" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.20.4", + "toml_edit 0.20.5", ] [[package]] @@ -3352,9 +3343,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.20.4" +version = "0.20.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380f9e8120405471f7c9ad1860a713ef5ece6a670c7eae39225e477340f32fc4" +checksum = "782bf6c2ddf761c1e7855405e8975472acf76f7f36d0d4328bd3b7a2fae12a85" dependencies = [ "indexmap 2.0.2", "serde", @@ -3497,9 +3488,9 @@ checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" [[package]] name = "tungstenite" -version = "0.19.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15fba1a6d6bb030745759a9a2a588bfe8490fc8b4751a277db3a0be1c9ebbf67" +checksum = "9e3dac10fd62eaf6617d3a904ae222845979aec67c615d1c842b4002c7666fb9" dependencies = [ "byteorder", "bytes", @@ -3838,7 +3829,7 @@ dependencies = [ "either", "home", "once_cell", - "rustix 0.38.20", + "rustix 0.38.21", "windows-sys", ] @@ -3982,17 +3973,14 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "yansi" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" - [[package]] name = "yansi" version = "1.0.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1367295b8f788d371ce2dbc842c7b709c73ee1364d30351dd300ec2203b12377" +dependencies = [ + "is-terminal", +] [[package]] name = "yubico" diff --git a/Cargo.toml b/Cargo.toml index df88a6cc7a1..3c212600239 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -57,7 +57,7 @@ num-derive = "0.4.1" # Web framework rocket = { version = "0.5.0-rc.3", features = ["tls", "json"], default-features = false } # rocket_ws = { version ="0.1.0-rc.3" } -rocket_ws = { git = 'https://github.com/SergioBenitez/Rocket', rev = "ce441b5f46fdf5cd99cb32b8b8638835e4c2a5fa" } # v0.5 branch +rocket_ws = { git = 'https://github.com/SergioBenitez/Rocket', rev = "923b61edf37424692a32727513b0062283ead741" } # v0.5rc branch # WebSockets libraries rmpv = "1.0.1" # MessagePack library @@ -66,11 +66,11 @@ rmpv = "1.0.1" # MessagePack library dashmap = "5.5.3" # Async futures -futures = "0.3.28" +futures = "0.3.29" tokio = { version = "1.33.0", features = ["rt-multi-thread", "fs", "io-util", "parking_lot", "time", "signal"] } # A generic serialization/deserialization framework -serde = { version = "1.0.189", features = ["derive"] } +serde = { version = "1.0.190", features = ["derive"] } serde_json = "1.0.107" # A safe, extensible ORM and Query builder @@ -167,8 +167,8 @@ rpassword = "7.2.0" [patch.crates-io] -rocket = { git = 'https://github.com/SergioBenitez/Rocket', rev = 'ce441b5f46fdf5cd99cb32b8b8638835e4c2a5fa' } # v0.5 branch -# rocket_ws = { git = 'https://github.com/SergioBenitez/Rocket', rev = 'ce441b5f46fdf5cd99cb32b8b8638835e4c2a5fa' } # v0.5 branch +rocket = { git = 'https://github.com/SergioBenitez/Rocket', rev = '923b61edf37424692a32727513b0062283ead741' } # v0.5rc branch +# rocket_ws = { git = 'https://github.com/SergioBenitez/Rocket', rev = '923b61edf37424692a32727513b0062283ead741' } # v0.5rc branch # Strip debuginfo from the release builds diff --git a/src/api/admin.rs b/src/api/admin.rs index 56f3cd7759e..96f893dbdff 100644 --- a/src/api/admin.rs +++ b/src/api/admin.rs @@ -184,12 +184,11 @@ fn post_admin_login(data: Form, cookies: &CookieJar<'_>, ip: ClientIp let claims = generate_admin_claims(); let jwt = encode_jwt(&claims); - let cookie = Cookie::build(COOKIE_NAME, jwt) + let cookie = Cookie::build((COOKIE_NAME, jwt)) .path(admin_path()) .max_age(rocket::time::Duration::minutes(CONFIG.admin_session_lifetime())) .same_site(SameSite::Strict) - .http_only(true) - .finish(); + .http_only(true); cookies.add(cookie); if let Some(redirect) = redirect { @@ -313,7 +312,7 @@ async fn test_smtp(data: Json, _token: AdminToken) -> EmptyResult { #[get("/logout")] fn logout(cookies: &CookieJar<'_>) -> Redirect { - cookies.remove(Cookie::build(COOKIE_NAME, "").path(admin_path()).finish()); + cookies.remove(Cookie::build((COOKIE_NAME, "")).path(admin_path())); Redirect::to(admin_path()) } @@ -793,7 +792,7 @@ impl<'r> FromRequest<'r> for AdminToken { if decode_admin(access_token).is_err() { // Remove admin cookie - cookies.remove(Cookie::build(COOKIE_NAME, "").path(admin_path()).finish()); + cookies.remove(Cookie::build((COOKIE_NAME, "")).path(admin_path())); error!("Invalid or expired admin JWT. IP: {}.", &ip.ip); return Outcome::Failure((Status::Unauthorized, "Session expired")); } diff --git a/src/api/notifications.rs b/src/api/notifications.rs index 46a07218e31..4d19fc45cb7 100644 --- a/src/api/notifications.rs +++ b/src/api/notifications.rs @@ -35,12 +35,14 @@ use super::{ push_send_update, push_user_update, }; +static NOTIFICATIONS_DISABLED: Lazy = Lazy::new(|| !CONFIG.enable_websocket() && !CONFIG.push_enabled()); + pub fn routes() -> Vec { - if CONFIG.websocket_disabled() { + if CONFIG.enable_websocket() { + routes![websockets_hub, anonymous_websockets_hub] + } else { info!("WebSocket are disabled, realtime sync functionality will not work!"); routes![] - } else { - routes![websockets_hub, anonymous_websockets_hub] } } @@ -329,7 +331,7 @@ impl WebSocketUsers { // NOTE: The last modified date needs to be updated before calling these methods pub async fn send_user_update(&self, ut: UpdateType, user: &User) { // Skip any processing if both WebSockets and Push are not active - if CONFIG.websocket_disabled() && !CONFIG.push_enabled() { + if *NOTIFICATIONS_DISABLED { return; } let data = create_update( @@ -338,7 +340,7 @@ impl WebSocketUsers { None, ); - if !CONFIG.websocket_disabled() { + if CONFIG.enable_websocket() { self.send_update(&user.uuid, &data).await; } @@ -349,7 +351,7 @@ impl WebSocketUsers { pub async fn send_logout(&self, user: &User, acting_device_uuid: Option) { // Skip any processing if both WebSockets and Push are not active - if CONFIG.websocket_disabled() && !CONFIG.push_enabled() { + if *NOTIFICATIONS_DISABLED { return; } let data = create_update( @@ -358,7 +360,7 @@ impl WebSocketUsers { acting_device_uuid.clone(), ); - if !CONFIG.websocket_disabled() { + if CONFIG.enable_websocket() { self.send_update(&user.uuid, &data).await; } @@ -375,7 +377,7 @@ impl WebSocketUsers { conn: &mut DbConn, ) { // Skip any processing if both WebSockets and Push are not active - if CONFIG.websocket_disabled() && !CONFIG.push_enabled() { + if *NOTIFICATIONS_DISABLED { return; } let data = create_update( @@ -388,7 +390,7 @@ impl WebSocketUsers { Some(acting_device_uuid.into()), ); - if !CONFIG.websocket_disabled() { + if CONFIG.enable_websocket() { self.send_update(&folder.user_uuid, &data).await; } @@ -407,7 +409,7 @@ impl WebSocketUsers { conn: &mut DbConn, ) { // Skip any processing if both WebSockets and Push are not active - if CONFIG.websocket_disabled() && !CONFIG.push_enabled() { + if *NOTIFICATIONS_DISABLED { return; } let org_uuid = convert_option(cipher.organization_uuid.clone()); @@ -435,7 +437,7 @@ impl WebSocketUsers { Some(acting_device_uuid.into()), ); - if !CONFIG.websocket_disabled() { + if CONFIG.enable_websocket() { for uuid in user_uuids { self.send_update(uuid, &data).await; } @@ -455,7 +457,7 @@ impl WebSocketUsers { conn: &mut DbConn, ) { // Skip any processing if both WebSockets and Push are not active - if CONFIG.websocket_disabled() && !CONFIG.push_enabled() { + if *NOTIFICATIONS_DISABLED { return; } let user_uuid = convert_option(send.user_uuid.clone()); @@ -470,7 +472,7 @@ impl WebSocketUsers { None, ); - if !CONFIG.websocket_disabled() { + if CONFIG.enable_websocket() { for uuid in user_uuids { self.send_update(uuid, &data).await; } @@ -488,7 +490,7 @@ impl WebSocketUsers { conn: &mut DbConn, ) { // Skip any processing if both WebSockets and Push are not active - if CONFIG.websocket_disabled() && !CONFIG.push_enabled() { + if *NOTIFICATIONS_DISABLED { return; } let data = create_update( @@ -496,7 +498,7 @@ impl WebSocketUsers { UpdateType::AuthRequest, Some(acting_device_uuid.to_string()), ); - if !CONFIG.websocket_disabled() { + if CONFIG.enable_websocket() { self.send_update(user_uuid, &data).await; } @@ -513,7 +515,7 @@ impl WebSocketUsers { conn: &mut DbConn, ) { // Skip any processing if both WebSockets and Push are not active - if CONFIG.websocket_disabled() && !CONFIG.push_enabled() { + if *NOTIFICATIONS_DISABLED { return; } let data = create_update( @@ -521,7 +523,7 @@ impl WebSocketUsers { UpdateType::AuthRequestResponse, approving_device_uuid.clone().into(), ); - if !CONFIG.websocket_disabled() { + if CONFIG.enable_websocket() { self.send_update(auth_response_uuid, &data).await; } @@ -547,14 +549,15 @@ impl AnonymousWebSocketSubscriptions { } pub async fn send_auth_response(&self, user_uuid: &String, auth_response_uuid: &str) { + if !CONFIG.enable_websocket() { + return; + } let data = create_anonymous_update( vec![("Id".into(), auth_response_uuid.to_owned().into()), ("UserId".into(), user_uuid.clone().into())], UpdateType::AuthRequestResponse, user_uuid.to_string(), ); - if !CONFIG.websocket_disabled() { - self.send_update(auth_response_uuid, &data).await; - } + self.send_update(auth_response_uuid, &data).await; } } diff --git a/src/config.rs b/src/config.rs index b2203babdf2..bc334e5914b 100644 --- a/src/config.rs +++ b/src/config.rs @@ -369,8 +369,8 @@ make_config! { web_vault_folder: String, false, def, "web-vault/".to_string(); }, ws { - /// Disable websocket notifications - websocket_disabled: bool, false, def, false; + /// Enable websocket notifications + enable_websocket: bool, false, def, true; }, push { /// Enable push notifications diff --git a/src/util.rs b/src/util.rs index 2aef77b3580..2afd3ed8642 100644 --- a/src/util.rs +++ b/src/util.rs @@ -46,6 +46,7 @@ impl Fairing for AppHeaders { // Remove headers which could cause websocket connection issues res.remove_header("X-Frame-Options"); res.remove_header("X-Content-Type-Options"); + res.remove_header("Permissions-Policy"); return; } (_, _) => (),