Module auth

Module auth 

Source
Expand description

HTTP Basic / Digest auth callback registry.

When CEF fires RequestHandler::get_auth_credentials for a browser pane, the host returns 1 (will-async-respond), parks the AuthCallback in this registry keyed by a generated request_id, and broadcasts a browser-pane-auth-required event to the renderer. The renderer prompts the user and replies via the browser_pane_auth_submit / browser_pane_auth_cancel IPC commands, which resolve the callback here and complete the CEF flow.

Phase α of SPEC_BROWSER_PANE_HTTP_BASIC_AUTH_2026_05_18.md.

Structs§

Entry 🔒
One parked auth challenge — the CEF callback plus the block_id owning it (so pane-close can clean up just its entries) and a monotonically-increasing arming epoch (so a delayed timeout task can detect “this request was already resolved + re-registered under the same id” and bail). The epoch is a defensive guard; uuid request_ids shouldn’t collide.

Constants§

PARKED_TTL 🔒
Maximum time a callback can sit parked before we cancel it automatically. Bounds the leak if the renderer never replies (background tab + suspended JS, hung modal). 5 minutes is well above any realistic credential-entry time and well below “user noticed and wondered what happened.”

Statics§

NEXT_EPOCH 🔒
TOKIO_HANDLE 🔒
Tokio runtime Handle captured from main.rs so register() can schedule the TTL timer from any thread — CEF invokes get_auth_credentials on its IO thread, which has no Handle::current(), so a bare tokio::spawn(...) would panic with “there is no reactor running”.

Functions§

cancel_for_block
Cancel every callback parked for block_id — called from browser_pane_close so closing a pane mid-prompt doesn’t leak CEF refcounts. Returns the number cancelled.
pending 🔒
HashMap::new is not const-fn so the static needs lazy init.
pending_count
Pending request count. Useful for diagnostics and leak checks in tests.
register
Park a CEF auth callback under request_id. The renderer will resolve it shortly via submit / cancel. A 5-minute timeout task is armed alongside so the entry can’t leak indefinitely if the renderer never replies. Replaces any prior entry for the same id (shouldn’t happen — ids are uuid4).
set_runtime_handle
Install the Tokio runtime Handle. Called once from main.rs after Runtime::new() and before CEF starts dispatching callbacks.
take
Pop the callback for request_id. Returns None if it was already resolved (e.g. submit + cancel race) or never existed.