oliver-zehentleitner / maity

hub: auth: the second_factor leftovers tsk-j967n09yz6ps kept for after #1756 (admins rule x3, _handle reach-in, address_of, recovery-code alphabet, dead DUMMY_HASH half, EMPTY_BODY_SHA256)

Sign in to report

tsk-5ey8p2s2dq5w Open

Audit round 3b (tsk-hgnbapyw7hnh), read at 80fef076. Kind: duplication / dead code / leftover compatibility.

tsk-j967n09yz6ps is done, but its commit d2131073 (#1788) left several items "after #1756"; #1756 merged (840ad942) and no open card holds them. tsk-ee3z4rakddq9 points second_factor._handle at j967 item 8, a closed card.

What is still there

  • The "required_admins and (instance admin or owns a project)" rule three times: hub/src/maity_hub/auth/second_factor.py:143-145, :919-921, :970-971.
  • Private second_factor._handle (:990-991) called from auth/second_factor_reset.py:111, 172, 191; an inline copy at second_factor.py:834.
  • mail_factor.address_of (auth/mail_factor.py:60-63), a wrapper of verified_row "kept for second_factor ... after #1756"; callers second_factor.py:138, 650, tests/test_mail_factor.py:690.
  • Recovery codes keep their own Crockford alphabet and reading rule (second_factor.py:61-62, 356-361, 366) beside codes.ALPHABET, codes.random_code, codes.normalise (codes.py:22-51).
  • has_password (second_factor.py:794): the != passwords.DUMMY_HASH half is always true; DUMMY_HASH is made per process (passwords.py:59) and never stored.
  • credentials.EMPTY_BODY_SHA256 (auth/credentials.py:27) has no reader in hub/, cli/ or web/.
  • mail_factor.py:167 is a no-op: method="password" if row.method == "password" else row.method.

Proposal

  • One _admins_must_have_it(conn, hub, human_id); the public handle helper of tsk-ee3z4rakddq9 (and fix that card's pointer); inline verified_row, drop address_of; recovery codes through codes.random_code/codes.normalise(code, 10) plus .lower() so stored hashes stay valid; delete the DUMMY_HASH half, EMPTY_BODY_SHA256 and the no-op.

Effort / risk: S. Low; the recovery-code reading must keep today's lower-case form or every stored code stops working.