mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-19 06:26:14 -05:00
fix(windows): refine authentication UI and rotate desktop logs
Brand browser callbacks as GP Connect Login and refine the native recovery controls. Share bounded rotating logs between the GUI and authentication helper. Make OpenSSL interoperability tests opt-in, retain them in full CI, and correct platform-specific test guards and dependencies.
This commit is contained in:
24 files changed
+345
-61
No files matched your search
@@ -99,6 +99,8 @@ pub fn ensure_auth_callback_handler() -> anyhow::Result<()> {
|
||||
let (scheme, _) = root.create_subkey(r"Software\Classes\globalprotectcallback")?;
|
||||
scheme.set_value("", &"URL:GlobalProtect authentication callback")?;
|
||||
scheme.set_value("URL Protocol", &"")?;
|
||||
let (application, _) = scheme.create_subkey("Application")?;
|
||||
application.set_value("ApplicationName", &"GP Connect Login")?;
|
||||
let (command, _) = scheme.create_subkey(r"shell\open\command")?;
|
||||
// URL association activation requires a shell path, not Rust's verbatim
|
||||
// canonical path (\\?\C:\...), even though CreateProcess accepts both.
|
||||
|
||||
@@ -22,7 +22,7 @@ impl RecoveryStatus {
|
||||
Self::Hidden => "",
|
||||
Self::Restarting => "Restarting sign-in…",
|
||||
Self::Loading => "Loading sign-in…",
|
||||
Self::Failed => "Couldn’t restart sign-in.",
|
||||
Self::Failed => "Couldn’t load sign-in.",
|
||||
Self::Rejected => "Sign-in wasn’t completed.",
|
||||
Self::Tls {
|
||||
reason: TlsFailureReason::Handshake,
|
||||
@@ -55,6 +55,7 @@ impl RecoveryStatus {
|
||||
matches!(self, Self::Hidden | Self::Loading | Self::CertificateBypassed)
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
pub fn is_busy(self) -> bool {
|
||||
matches!(self, Self::Restarting | Self::Loading)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub(super) enum TlsFailureReason {
|
||||
Expired,
|
||||
#[cfg(not(windows))]
|
||||
NotYetValid,
|
||||
#[cfg(not(windows))]
|
||||
Untrusted,
|
||||
HostnameMismatch,
|
||||
InvalidCertificate,
|
||||
@@ -17,7 +19,9 @@ impl TlsFailureReason {
|
||||
pub fn message(self) -> &'static str {
|
||||
match self {
|
||||
Self::Expired => "The certificate has expired.",
|
||||
#[cfg(not(windows))]
|
||||
Self::NotYetValid => "The certificate is not valid yet.",
|
||||
#[cfg(not(windows))]
|
||||
Self::Untrusted => "The certificate was issued by an untrusted authority.",
|
||||
Self::HostnameMismatch => "The certificate does not match this server’s hostname.",
|
||||
Self::InvalidCertificate => "The server’s certificate could not be verified.",
|
||||
|
||||
@@ -18,6 +18,7 @@ const SUBCLASS: usize = 0x47504155;
|
||||
const ADDRESS_SUBCLASS: usize = 0x47504156;
|
||||
const ADDRESS_HEIGHT: i32 = 24;
|
||||
const TOOLBAR_HEIGHT: i32 = 34;
|
||||
const RECOVERY_PADDING: i32 = 4;
|
||||
const RETRY: usize = 101;
|
||||
const PROCEED: usize = 102;
|
||||
const CANCEL: usize = 103;
|
||||
@@ -31,6 +32,7 @@ pub(super) struct Controls {
|
||||
proceed: HWND,
|
||||
cancel: HWND,
|
||||
status: Cell<RecoveryStatus>,
|
||||
recovery_bounds: Cell<RECT>,
|
||||
font: Cell<Option<(u32, HFONT)>>,
|
||||
}
|
||||
|
||||
@@ -75,6 +77,7 @@ impl Controls {
|
||||
proceed: child(w!("BUTTON"), "Continue Anyway…", WS_TABSTOP, PROCEED)?,
|
||||
cancel: child(w!("BUTTON"), "Cancel", WS_TABSTOP, CANCEL)?,
|
||||
status: Cell::new(RecoveryStatus::Hidden),
|
||||
recovery_bounds: Cell::new(RECT::default()),
|
||||
font: Cell::new(None),
|
||||
};
|
||||
unsafe {
|
||||
@@ -186,33 +189,63 @@ impl Controls {
|
||||
Some(LPARAM(&text as *const _ as isize)),
|
||||
);
|
||||
let status = self.status.get();
|
||||
let header = if status == RecoveryStatus::Hidden {
|
||||
TOOLBAR_HEIGHT
|
||||
} else {
|
||||
TOOLBAR_HEIGHT + 68
|
||||
};
|
||||
MoveWindow(
|
||||
self.message,
|
||||
px(8),
|
||||
px(TOOLBAR_HEIGHT + 2),
|
||||
(width - px(16)).max(0),
|
||||
px(38),
|
||||
true,
|
||||
)?;
|
||||
let mut right = width - px(8);
|
||||
for (hwnd, visible, size) in [
|
||||
let buttons = [
|
||||
(self.cancel, status.blocks_page(), 70),
|
||||
(self.proceed, status.can_continue(), 136),
|
||||
(self.retry, status.can_retry(), 84),
|
||||
] {
|
||||
];
|
||||
let button_width: i32 = buttons
|
||||
.iter()
|
||||
.filter(|(_, visible, _)| *visible)
|
||||
.map(|(_, _, size)| size + 6)
|
||||
.sum();
|
||||
let stacked = width < px(700) && button_width > 0;
|
||||
let message_height = if status.detail().is_empty() { 20 } else { 40 };
|
||||
let row_height = message_height.max(28);
|
||||
let recovery_content_height = if stacked { message_height + 8 + 28 } else { row_height };
|
||||
// Equal padding surrounds the controls; the divider occupies one physical pixel.
|
||||
let recovery_height = px(recovery_content_height + 2 * RECOVERY_PADDING) + 1;
|
||||
let header_height = if status == RecoveryStatus::Hidden {
|
||||
px(TOOLBAR_HEIGHT)
|
||||
} else {
|
||||
px(TOOLBAR_HEIGHT) + recovery_height
|
||||
};
|
||||
self.recovery_bounds.set(RECT {
|
||||
left: 0,
|
||||
top: px(TOOLBAR_HEIGHT),
|
||||
right: width,
|
||||
bottom: header_height,
|
||||
});
|
||||
let message_width = if stacked {
|
||||
width - px(24)
|
||||
} else {
|
||||
width - px(24 + button_width)
|
||||
};
|
||||
MoveWindow(
|
||||
self.message,
|
||||
px(12),
|
||||
px(TOOLBAR_HEIGHT + RECOVERY_PADDING + if stacked { 0 } else { (row_height - message_height) / 2 }),
|
||||
message_width.max(0),
|
||||
px(message_height),
|
||||
true,
|
||||
)?;
|
||||
let button_top = TOOLBAR_HEIGHT
|
||||
+ RECOVERY_PADDING
|
||||
+ if stacked {
|
||||
message_height + 8
|
||||
} else {
|
||||
(row_height - 28) / 2
|
||||
};
|
||||
let mut right = width - px(8);
|
||||
for (hwnd, visible, size) in buttons {
|
||||
if visible {
|
||||
right -= px(size);
|
||||
MoveWindow(hwnd, right, px(TOOLBAR_HEIGHT + 38), px(size), px(28), true)?;
|
||||
MoveWindow(hwnd, right, px(button_top), px(size), px(28), true)?;
|
||||
right -= px(6);
|
||||
}
|
||||
}
|
||||
let content_height = (bounds.bottom - px(header)).max(0);
|
||||
MoveWindow(self.webview_host, 0, px(header), width, content_height, true)?;
|
||||
let content_height = (bounds.bottom - header_height).max(0);
|
||||
MoveWindow(self.webview_host, 0, header_height, width, content_height, true)?;
|
||||
state.controller.SetBounds(RECT {
|
||||
left: 0,
|
||||
top: 0,
|
||||
@@ -291,12 +324,36 @@ unsafe extern "system" fn window_proc(
|
||||
key: usize,
|
||||
) -> LRESULT {
|
||||
let state = STATES.with_borrow(|states| states.get(&key).cloned());
|
||||
if msg == WM_CTLCOLORSTATIC {
|
||||
unsafe {
|
||||
let dc = HDC(wparam.0 as *mut _);
|
||||
let is_message = state
|
||||
.as_ref()
|
||||
.is_some_and(|state| state.controls.message.0 as isize == lparam.0);
|
||||
let background = if is_message { COLOR_3DFACE } else { COLOR_WINDOW };
|
||||
SetTextColor(dc, COLORREF(GetSysColor(COLOR_WINDOWTEXT)));
|
||||
SetBkColor(dc, COLORREF(GetSysColor(background)));
|
||||
return LRESULT(GetSysColorBrush(background).0 as isize);
|
||||
}
|
||||
}
|
||||
// Paint the native toolbar and recovery surface outside the child webview.
|
||||
if msg == WM_ERASEBKGND {
|
||||
unsafe {
|
||||
let mut bounds = RECT::default();
|
||||
if GetClientRect(hwnd, &mut bounds).is_ok() {
|
||||
FillRect(HDC(wparam.0 as *mut _), &bounds, GetSysColorBrush(COLOR_WINDOW));
|
||||
let dc = HDC(wparam.0 as *mut _);
|
||||
FillRect(dc, &bounds, GetSysColorBrush(COLOR_WINDOW));
|
||||
if let Some(state) = &state {
|
||||
let row = state.controls.recovery_bounds.get();
|
||||
if row.bottom > row.top {
|
||||
FillRect(dc, &row, GetSysColorBrush(COLOR_3DFACE));
|
||||
let divider = RECT {
|
||||
top: row.bottom - 1,
|
||||
..row
|
||||
};
|
||||
FillRect(dc, ÷r, GetSysColorBrush(COLOR_3DLIGHT));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return LRESULT(1);
|
||||
|
||||
Reference in new issue
Block a user