Page MenuHomePhabricator

D10804.id36430.diff
No OneTemporary

D10804.id36430.diff

diff --git a/services/identity/Cargo.lock b/services/identity/Cargo.lock
--- a/services/identity/Cargo.lock
+++ b/services/identity/Cargo.lock
@@ -2078,6 +2078,7 @@
"http 0.2.11",
"hyper 0.14.28",
"hyper-tungstenite",
+ "identity_search_messages",
"moka",
"once_cell",
"prost",
@@ -2098,6 +2099,15 @@
"uuid 1.6.1",
]
+[[package]]
+name = "identity_search_messages"
+version = "0.1.0"
+dependencies = [
+ "serde",
+ "serde_json",
+ "websocket_messages",
+]
+
[[package]]
name = "idna"
version = "0.1.5"
diff --git a/services/identity/Cargo.toml b/services/identity/Cargo.toml
--- a/services/identity/Cargo.toml
+++ b/services/identity/Cargo.toml
@@ -29,6 +29,7 @@
serde = { version = "1.0.159", features = ["derive"] }
serde_json = "1.0.95"
tunnelbroker_messages = { path = "../../shared/tunnelbroker_messages" }
+identity_search_messages = { path = "../../shared/identity_search_messages" }
moka = { version = "0.10", features = ["future"] }
uuid = { version = "1.3", features = ["v4"] }
base64 = "0.21.2"
diff --git a/services/identity/src/websockets/auth.rs b/services/identity/src/websockets/auth.rs
--- a/services/identity/src/websockets/auth.rs
+++ b/services/identity/src/websockets/auth.rs
@@ -3,22 +3,12 @@
use grpc_clients::tonic::Request;
use identity::get_unauthenticated_client;
use identity::protos::unauthenticated as client_proto;
-use serde::{Deserialize, Serialize};
+use identity_search_messages::AuthMessage;
use tracing::{debug, error};
use crate::constants::DEFAULT_IDENTITY_ENDPOINT;
use crate::websockets::errors::WebsocketError;
-#[derive(Serialize, Deserialize, Debug)]
-#[serde(tag = "type", rename_all = "camelCase")]
-pub struct AuthMessage {
- #[serde(rename = "userID")]
- pub user_id: String,
- #[serde(rename = "deviceID")]
- pub device_id: String,
- pub access_token: String,
-}
-
const PLACEHOLDER_CODE_VERSION: u64 = 0;
const DEVICE_TYPE: &str = "service";
diff --git a/shared/identity_search_messages/.gitignore b/shared/identity_search_messages/.gitignore
new file mode 100644
--- /dev/null
+++ b/shared/identity_search_messages/.gitignore
@@ -0,0 +1 @@
+target/
diff --git a/shared/identity_search_messages/Cargo.lock b/shared/identity_search_messages/Cargo.lock
new file mode 100644
--- /dev/null
+++ b/shared/identity_search_messages/Cargo.lock
@@ -0,0 +1,98 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "identity_search_messages"
+version = "0.1.0"
+dependencies = [
+ "serde",
+ "serde_json",
+ "websocket_messages",
+]
+
+[[package]]
+name = "itoa"
+version = "1.0.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c"
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.78"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.35"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
+dependencies = [
+ "proc-macro2",
+]
+
+[[package]]
+name = "ryu"
+version = "1.0.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c"
+
+[[package]]
+name = "serde"
+version = "1.0.195"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02"
+dependencies = [
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_derive"
+version = "1.0.195"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "serde_json"
+version = "1.0.111"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4"
+dependencies = [
+ "itoa",
+ "ryu",
+ "serde",
+]
+
+[[package]]
+name = "syn"
+version = "2.0.48"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "unicode-ident"
+version = "1.0.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
+
+[[package]]
+name = "websocket_messages"
+version = "0.1.0"
+dependencies = [
+ "serde",
+ "serde_json",
+]
diff --git a/shared/identity_search_messages/Cargo.toml b/shared/identity_search_messages/Cargo.toml
new file mode 100644
--- /dev/null
+++ b/shared/identity_search_messages/Cargo.toml
@@ -0,0 +1,11 @@
+[package]
+name = "identity_search_messages"
+version = "0.1.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
+serde = { version = "1.0.159", features = ["derive"] }
+serde_json = "1.0.95"
+websocket_messages = { path = "../websocket_messages" }
diff --git a/shared/identity_search_messages/src/lib.rs b/shared/identity_search_messages/src/lib.rs
new file mode 100644
--- /dev/null
+++ b/shared/identity_search_messages/src/lib.rs
@@ -0,0 +1,3 @@
+pub mod messages;
+
+pub use messages::*;
diff --git a/shared/identity_search_messages/src/messages/auth_messages.rs b/shared/identity_search_messages/src/messages/auth_messages.rs
new file mode 100644
--- /dev/null
+++ b/shared/identity_search_messages/src/messages/auth_messages.rs
@@ -0,0 +1,13 @@
+//! Message sent by client to authenticate with Identity Search Server
+
+use serde::{Deserialize, Serialize};
+
+#[derive(Serialize, Deserialize, Debug)]
+#[serde(tag = "type", rename_all = "camelCase")]
+pub struct AuthMessage {
+ #[serde(rename = "userID")]
+ pub user_id: String,
+ #[serde(rename = "deviceID")]
+ pub device_id: String,
+ pub access_token: String,
+}
diff --git a/shared/identity_search_messages/src/messages/mod.rs b/shared/identity_search_messages/src/messages/mod.rs
new file mode 100644
--- /dev/null
+++ b/shared/identity_search_messages/src/messages/mod.rs
@@ -0,0 +1,18 @@
+//! Messages sent from client to Identity Search Server
+
+pub mod auth_messages;
+
+pub use auth_messages::*;
+
+use serde::{Deserialize, Serialize};
+pub use websocket_messages::{
+ ConnectionInitializationResponse, ConnectionInitializationStatus, Heartbeat,
+};
+
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(untagged)]
+pub enum Messages {
+ AuthMessage(AuthMessage),
+ Heartbeat(Heartbeat),
+ ConnectionInitializationResponse(ConnectionInitializationResponse),
+}

File Metadata

Mime Type
text/plain
Expires
Tue, Dec 3, 12:09 PM (21 h, 11 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2611628
Default Alt Text
D10804.id36430.diff (6 KB)

Event Timeline