Skip to main content

Module mfa

Module mfa 

Source

Constants§

BACKUP_CODE_COUNT
Number of one-time backup codes generated at enable time.

Functions§

check_code
True when code is the valid current TOTP for this secret/account.
consume_backup_code
If code matches one of the stored (JSON array) hashes, consume it and return the remaining hashes as JSON. Returns None when nothing matched.
generate_backup_codes
Generate BACKUP_CODE_COUNT human-friendly one-time codes (shown once, in plain text). Format: 1234-5678.
generate_secret
Generate a fresh base32 TOTP secret to persist on the user row.
hash_backup_codes
Hash backup codes for storage. Returns a JSON array of bcrypt hashes.
provisioning_url
otpauth:// URL to encode into the setup QR code.
qr_svg
Render arbitrary data (an otpauth URL) as an inline SVG QR code. SVG keeps the dependency light — no raster/image encoders.