diff --git a/proto b/proto index fee70601..96249ebd 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit fee706013b3bb5452c3c4dbf35bd973d0637ff25 +Subproject commit 96249ebde0556f4ae8c47eebc6015efb04ed0104 diff --git a/src/handlers/mod.rs b/src/handlers/mod.rs index cf391008..629cbc2d 100644 --- a/src/handlers/mod.rs +++ b/src/handlers/mod.rs @@ -18,6 +18,8 @@ pub(crate) mod register_mfa; // Timeout for awaiting response from Defguard Core. const CORE_RESPONSE_TIMEOUT: Duration = Duration::from_secs(5); +const CLIENT_VERSION_HEADER: &str = "defguard-client-version"; +const CLIENT_PLATFORM_HEADER: &str = "defguard-client-platform"; impl FromRequestParts for DeviceInfo where @@ -39,14 +41,27 @@ where // sanitize user-agent .filter(|agent| !ammonia::is_html(agent)); + let version = parts + .headers + .get(CLIENT_VERSION_HEADER) + .and_then(|v| v.to_str().ok()) + .map(str::to_string); + let platform = parts + .headers + .get(CLIENT_PLATFORM_HEADER) + .and_then(|v| v.to_str().ok()) + .map(str::to_string); + let ip_address = forwarded_for_ip .or(insecure_ip) .map(|v| v.to_string()) .map_err(|_| ApiError::Unexpected("Missing client IP".to_string()))?; - Ok(DeviceInfo { + Ok(Self { ip_address, user_agent, + version, + platform, }) } } @@ -84,9 +99,10 @@ pub(crate) async fn get_core_response(rx: Receiver) -> Result