[pdm-devel] [PATCH yew-comp v5 20/21] http helpers: ask server to remove `__Host-` prefixed cookie on logout
Shannon Sterz
s.sterz at proxmox.com
Tue Mar 4 15:42:46 CET 2025
when clearing the authentication data, we can no longer remove the
cookie that stores the ticket once it is properly protected. so ask
the server to do this for us.
Signed-off-by: Shannon Sterz <s.sterz at proxmox.com>
---
src/http_helpers.rs | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/http_helpers.rs b/src/http_helpers.rs
index e2489cc..b1425d5 100644
--- a/src/http_helpers.rs
+++ b/src/http_helpers.rs
@@ -148,11 +148,19 @@ pub fn http_get_auth() -> Option<Authentication> {
CLIENT.with(move |c| c.borrow().get_auth())
}
+thread_local! {
+ static LOGOUT_GUARD: RefCell<Option<AsyncAbortGuard>> = const { RefCell::new(None) };
+}
+
pub fn http_clear_auth() {
- CLIENT.with(move |c| {
- c.borrow_mut().clear_auth();
- crate::clear_auth_cookie(c.borrow().product().auth_cookie_name());
+ let abort_guard = AsyncAbortGuard::spawn(async move {
+ let client = CLIENT.with(|c| Rc::clone(&*c.borrow()));
+ let _ = client.logout().await;
+ client.clear_auth();
+ crate::clear_auth_cookie(client.product().auth_cookie_name());
});
+
+ LOGOUT_GUARD.with_borrow_mut(|v| *v = Some(abort_guard));
}
pub async fn http_login(
--
2.39.5
More information about the pdm-devel
mailing list