oliver-zehentleitner / maity

hub: auth: callers import single_use directly (drop email_links' re-exports and the alias test); registration through single_use.RequestLimits

Sign in to report

tsk-w9wy6x7s3p5a Open

Audit round 3 (tsk-hgnbapyw7hnh), read at 588f911b. Kind: debt (compat path) / duplication / docs drift.

What is wrong

  • hub/src/maity_hub/auth/email_links.py:7-10 and :29-36 re-export digest, lock_human, recipient_over, Recipient and the four RECIPIENT_* constants from auth/single_use.py (its docstring :11: "keep their former names"). Callers still going through the shim: routes/password_reset.py:156, :212 (email_links.lock_human); routes/registration.py:58-70, :216; notifications/address.py:29. hub/tests/test_single_use.py:204-211 only asserts that the aliases are the same objects. hub/context/auth.md:985 names auth/email_links.py recipient_over, which lives in single_use.py.
  • hub/src/maity_hub/routes/registration.py:50-74 defines nine module-level Limiters with exactly the numbers of single_use.RequestLimits.__init__ (auth/single_use.py:250-269: 10/h by source, 3 per 15 min and 10/day per pair, six recipient limiters), and registration.py:209-228 repeats the pair-then-recipient sequence of RequestLimits.take (single_use.py:271-282). email_sign_in and password_reset already use the class.

Proposal

  • Import from single_use at those callers; drop the re-exports and the alias test; fix the auth.md source line. Alpha: nobody depends on the old names.
  • LIMITS = single_use.RequestLimits("routes.registration"), with take split into take_source() and take_pair_and_recipient() (registration counts the source before scrypt and the rest in the background). Limiter names change, so in-flight counts reset once at deploy; say so in the PR.

Effort / risk: S-M. Low risk.