s365b.auth.totp¶
Time-based one-time passwords (RFC 6238) for break-glass accounts.
Attributes¶
Functions¶
|
Create a new random TOTP secret. |
|
Return the |
|
Verify a TOTP code, rejecting replays. |
Module Contents¶
- s365b.auth.totp.provisioning_uri(secret: str, username: str, issuer: str) str[source]¶
Return the
otpauth://URI shown as a QR code during enrolment.- Parameters:
secret – Base32 secret.
username – Account name shown in the authenticator app.
issuer – Product name shown in the authenticator app (from branding).
- Returns:
The URI.
- s365b.auth.totp.verify(secret: str, code: str, last_step: int | None, *, now: float | None = None) int | None[source]¶
Verify a TOTP code, rejecting replays.
Accepts the current code and the one before or after (clock drift), but never a code from a time step at or before
last_step.- Parameters:
secret – Base32 secret.
code – Six-digit code from the user.
last_step – Time step of the last accepted code for this account.
now – Current Unix time (tests).
- Returns:
The matched time step (store it as the new
last_step), orNoneif the code is wrong or was already used.