cadrumo.adapters.outbound.aeat.auth._session_probe module¶
Shared authenticated-landing navigation probe for AEAT auth providers.
The Cl@ve Móvil and Cl@ve Permanente providers both re-probe a persisted
browser session by navigating an owned BrowserContextPort to a
target URL and deciding whether the final landing page is an authenticated
AEAT surface. The navigation state machine — open a page, goto the probe
URL, read the status and landing URL, optionally run a provider-specific
on-landing dispatch, classify the landing, and always close the page — was
cloned near-byte-identically across both providers.
run_authenticated_landing_probe() owns that one state machine. Each
provider supplies:
is_authenticated_landing— the provider’s landing predicate.on_landing— an optional hook (Cl@ve Móvil uses it for the selector-page Cl@ve-button dispatch; Cl@ve Permanente passesNone).log_label— the operator-facing label used in the navigation-failure and page-close-suppression log lines.
The provider keeps its own guards, target/probe-URL resolution, and typed
AeatLoginAssertion assembly; only the navigation probe is shared.
- AuthenticatedLandingPredicate¶
(landing_url, target_path) -> boolprovider landing classifier.
- OnLandingHook¶
(page, landing_url, target_path) -> actedpost-landing dispatch hook.Returning
Truesignals the probe that the hook navigated the page, so the probe re-reads the page’s landing URL afterwards;Falseleaves the observed landing URL unchanged.alias of
Callable[[BrowserPagePort,str,str],Awaitable[bool]]
- class SessionProbeOutcome(**data)[source]¶
Bases:
BaseModelResult of a single authenticated-landing navigation probe.
- Parameters:
data (Any)
- status_code: int¶
- landing_url: str | None¶
- session_cookie_present: bool¶
- error_message: str | None¶
- elapsed_ms: int¶
- async run_authenticated_landing_probe(context, *, probe_url, target_path, navigation_timeout_ms, is_authenticated_landing, on_landing, log_label)[source]¶
Navigate
contexttoprobe_urland classify the landing page.Opens a new page on the owned
context, navigates toprobe_url, and reads the response status and landing URL. Whenon_landingis supplied and a landing URL is observed, the hook runs and — if it reports acting — the landing URL is re-read. The landing counts as an authenticated session only when the status is in[200, 400), a landing URL is present, andis_authenticated_landingaccepts it. Navigation failures are captured intoerror_message; the page is always closed.- Return type:
- Parameters:
context (BrowserContextPort)
probe_url (str)
target_path (str)
navigation_timeout_ms (int)
is_authenticated_landing (AuthenticatedLandingPredicate)
on_landing (OnLandingHook | None)
log_label (str)