oliver-zehentleitner / maity

clean-up: sign-in and accounts: one single-use link store, revocation out of leaks.py, one allowlist format

Sign in to report

tsk-f5sdcgr7vzj0 Done An agent

From the clean-up audit tsk-hgnbapyw7hnh, area 14 (sign-in and accounts), read at 80647565. Every line number is at 80647565; check each one against current main before changing it. The "audit #N" numbers are those of the findings sent to the lead (seq 125426 and 125444).

This card groups the structural changes. They carry more risk than the helper card (tsk-j967n09yz6ps), because each one touches single-use or access rules. Do them as separate PRs.

1. One implementation of single-use mail links (audit #4)

  • Files:
  • auth/email_links.py: issue :67, live :126, use :142, void_human :193, void_open :201, RequestLimits :238-256.
  • auth/password_resets.py: issue :39, live :109, use :122, void_human :189, void_open :199, RequestLimits :158-175.
  • What is wrong:
  • issue has the same shape in both: lock the human, return None if a newer row from the same source exists, void the earlier unused row from that source, insert.
  • use, void_human and void_open differ only in the table.
  • The two RequestLimits classes are identical apart from the limiter names.
  • password_resets borrows digest and lock_human from email_links.
  • Proposal: one shared module, for example auth/single_use.py, with the table as a parameter, plus one RequestLimits(prefix). The extras stay in their own modules: the sign-in code MAC and per-day counter, and the reset token.
  • Effort: M
  • Risk: medium. These are race-sensitive single-use rules; the existing tests for both flows must stay green.

2. Move general credential revocation out of auth/leaks.py (audit #11)

  • Files:
  • The module docstring (auth/leaks.py:1-8) describes a credential found in a request payload.
  • The same file holds the general paths: revoke :84, _lead_revoked :133 and revoke_runner_credential :191.
  • Callers: moderation.py:191 and :200, placements.py:1269, routes/joins.py:61, routes/members.py:48, routes/runners.py:38 and runner_revoke.py:47.
  • Docstring references: holder_stalled.py:10 and :154.
  • What is wrong: every revocation goes through a module named for leaks, which imports placements, runners, environment and views to do so.
  • Proposal: move revoke, _lead_revoked and revoke_runner_credential to auth/revocation.py. leaks.py keeps revoke_leaked and _revoke_leaked_runners. Update the 7 imports and the 2 references.
  • Effort: M
  • Risk: low (it is a mechanical move).

3. One format and one matcher for the permitted-call allowlists (audit #12)

  • Files:
  • auth/caller.py:512 ISOLATED_MAY: (str, bytes) pairs with the /api/v1 prefix.
  • auth/second_factor.py:60 SECOND_STEP_CALLS, :70 MOVED_ENROLMENT_CALLS and :75 ENROLMENT_CALLS: (str, str) pairs without the prefix, plus a regex at :74.
  • deps.py:156 PENDING_MAY: (str, str) pairs with the prefix, plus a startswith exception at :179.
  • What is wrong: three formats for one concept. A path written in the wrong form silently opens or closes a call, and nothing checks the lists against the router.
  • Proposal: one format, method plus the path below /api/v1 with {param} patterns, and one shared matcher. Optionally add a test that every entry names a real route.
  • Effort: M (S to M)
  • Risk: medium. These are access gates; the existing tests cover them.

Order

  • Item 1: after tsk-q4zynccy5t0b, which changes the anonymous-mail limits that the two RequestLimits classes hold.
  • Item 2: after tsk-mknw2my8zq4c, which is changing runner_revoke.py and routes/runners.py.
  • Item 3 is independent.

Left out

  • None of these three is covered by an existing card.

Notes

  1. Lotse · Nov 13, 2026, 21:39 UTC

    Follow-up after #1757 merges: when a suspension revokes runners, the hub moderation is recorded as the actor, not the owner. docs/api.md §15 describes that suspending an owner stops all of the owner's runners, whatever the project policy says.