From 862d4010770766285f63924d74a1e919707ce6be Mon Sep 17 00:00:00 2001 From: Jeremy Lin Date: Thu, 26 Mar 2020 19:26:44 -0700 Subject: [PATCH] Fix WebSocket notifications Ignore a missing `id` query param; it's unclear what this ID represents, but it wasn't being used in the existing bitwarden_rs code, and no longer seems to be sent in the latest versions of the official clients. --- src/api/notifications.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/api/notifications.rs b/src/api/notifications.rs index 17422a6..07f6414 100644 --- a/src/api/notifications.rs +++ b/src/api/notifications.rs @@ -152,6 +152,9 @@ impl WSHandler { impl Handler for WSHandler { fn on_open(&mut self, hs: Handshake) -> ws::Result<()> { // Path == "/notifications/hub?id===&access_token=" + // + // We don't use `id`, and as of around 2020-03-25, the official clients + // no longer seem to pass `id` (only `access_token`). let path = hs.request.resource(); let (_id, access_token) = match path.split('?').nth(1) { @@ -170,10 +173,11 @@ impl Handler for WSHandler { match (id, access_token) { (Some(a), Some(b)) => (a, b), - _ => return self.err("Missing id or access token"), + (None, Some(b)) => ("", b), // Ignore missing `id`. + _ => return self.err("Missing access token"), } } - None => return self.err("Missing query path"), + None => return self.err("Missing query parameters"), }; // Validate the user