From bc8dc7a4f3a2d12a18c8b617bc7c7ef4285b4174 Mon Sep 17 00:00:00 2001 From: Kevin Yue Date: Thu, 18 Jan 2024 20:13:06 +0800 Subject: [PATCH] Fix the user agent of auth window --- apps/gpauth/src/auth_window.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/gpauth/src/auth_window.rs b/apps/gpauth/src/auth_window.rs index 11f3ae3..b335f4f 100644 --- a/apps/gpauth/src/auth_window.rs +++ b/apps/gpauth/src/auth_window.rs @@ -18,8 +18,8 @@ use tokio_util::sync::CancellationToken; use webkit2gtk::{ gio::Cancellable, glib::{GString, TimeSpan}, - LoadEvent, URIResponse, URIResponseExt, WebContextExt, WebResource, WebResourceExt, WebView, - WebViewExt, WebsiteDataManagerExtManual, WebsiteDataTypes, + LoadEvent, SettingsExt, URIResponse, URIResponseExt, WebContextExt, WebResource, WebResourceExt, + WebView, WebViewExt, WebsiteDataManagerExtManual, WebsiteDataTypes, }; enum AuthDataError { @@ -76,7 +76,7 @@ impl<'a> AuthWindow<'a> { let window = Window::builder(&self.app_handle, "auth_window", WindowUrl::default()) .title("GlobalProtect Login") - .user_agent(self.user_agent) + // .user_agent(self.user_agent) .focused(true) .visible(false) .center() @@ -128,6 +128,11 @@ impl<'a> AuthWindow<'a> { window.with_webview(move |wv| { let wv = wv.inner(); + if let Some(settings) = wv.settings() { + let ua = settings.user_agent().unwrap_or("".into()); + info!("Auth window user agent: {}", ua); + } + // Load the initial SAML request load_saml_request(&wv, &saml_request);