Skip to main content

duo-pass

Duo second-factor handling for Playwright logins — push approval with Verified Push number matching, or a typed passcode — behind one Approver interface. Spun out of canvasser, where it was proved against a live Duo tenant. GPL-3.0-or-later.

This module never asks how the Duo page was reached and never leaves the Duo host except by Duo handing control back. The login flow that got here is the host application's business.

from playwright.sync_api import sync_playwright
from duo_pass import complete_duo, PushApprover, configure

configure(
    snapshot=lambda page, label: save_somewhere(page, label),
    announce=lambda number: show_somehow(number),
)

with sync_playwright() as p:
    ...  # reach the Duo challenge on `page`
    complete_duo(page, PushApprover())  # or PasscodeApprover()

Hooks

A library must not invent paths or terminal chrome, so two hooks connect this module to its host. Both have working defaults; both should be overridden by any host with its own state directory or display layer.

hook signature default
snapshot (page, label) -> Path PNG under ./snapshots/, mode 700/600
announce (number: str | None) -> None framed box on stderr

snapshot fires as duo-exit-error (Duo refused the session) and duo-timeout (still on Duo when the wait expired). announce fires with Duo's Verified Push number, or None when the tenant has Verified Push off — absence is normal, not an error, and the frame is drawn either way.

Notes

  • The wait watches for leaving the Duo host, never for Duo markup — markup changes, leaving does not.
  • The trust prompt ("remember this device") is clicked during the wait, not after it: waiting to leave Duo before handling the prompt deadlocks, because the missing click is what would let us leave.
  • The Verified Push number is re-read every few seconds while waiting. A push can expire and be re-sent with a different number, and a stale number on screen is worse than none.
  • A Duo error= exit is reported as Duo refusing the browser, not as the user failing to approve. A timeout says what it knows: approval may have worked while Duo never handed control back.
  • Nothing here retries a credential. Repeatedly submitting a bad passcode can lock the account; a wrong code raises ApprovalError instead.

Release files for duo-pass 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for duo-pass 0.0.1
File Size Uploaded
duo_pass-0.0.1.tar.gz 20.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for duo-pass 0.0.1
File Interpreter ABI Platform
duo_pass-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 42.1 kB

Release files / duo_pass-0.0.1.tar.gz

Download URL duo_pass-0.0.1.tar.gz
Size 20.7 kB
Tags Source
SHA-256 checksum
How to use checksums
3f12f944216433f32bc5ca059c985868d14d5686a7abc4a909072969f969a3d5
BLAKE2b-256 checksum
How to use checksums
b7e206691ac47f81afe19e46928292388785dbf088696785f2a8491d5fe76a82
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / duo_pass-0.0.1-py3-none-any.whl

Download URL duo_pass-0.0.1-py3-none-any.whl
Size 21.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fb7dd315aad77e25e3ed04f9143b9081e59e612cfdfe482a8dc93b3141fb0948
BLAKE2b-256 checksum
How to use checksums
6b8a0851aed30a9b0512ed29f77c93c623826c43c84621897c90e25d3c351c61
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release history Release notifications | RSS feed

0.0.2

2 release files

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page