Skip to content

Add MFA session keeper module (weblogin.mfa)#23

Open
alba-kth wants to merge 5 commits into
dbosk:mainfrom
alba-kth:mfa-session-keeper
Open

Add MFA session keeper module (weblogin.mfa)#23
alba-kth wants to merge 5 commits into
dbosk:mainfrom
alba-kth:mfa-session-keeper

Conversation

@alba-kth

@alba-kth alba-kth commented Mar 5, 2026

Copy link
Copy Markdown

Description:

Background

Universities using Microsoft MFA with number matching (including KTH)
can no longer use weblogin — the login page is JavaScript-driven and
requires a real browser.

Solution

This adds weblogin.mfa, a module that uses headless Chrome (Selenium)
to handle the interactive MFA flow and saves the resulting cookies to a
file for use by other scripts.

Usage

Install:
pip install weblogin[mfa]

Run:
python -m weblogin.mfa <trigger_url> <cookie_file>

Or import the functions directly to integrate into your own scripts.

Notes

  • Selenium is an optional dependency (weblogin[mfa]) — base package unchanged
  • Tested on KTH with Microsoft Authenticator number matching
  • Follows noweb literate programming conventions

alba-kth added 5 commits March 5, 2026 01:13
Adds support for KTH logins with Microsoft MFA number matching.
Uses headless Chrome (Selenium) to handle the interactive MFA flow,
then saves cookies for use by other scripts.

Install with: pip install weblogin[mfa]
Run with: python -m weblogin.mfa <trigger_url> <cookie_file>
Check _on_login_page before scanning for MFA number, so we don't
pick up random two-digit numbers from the destination page.
@dbosk dbosk mentioned this pull request Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant