Skip to content

Gate an existing id: create(token=), set_password, set_expires - #2

Merged
thorwhalen merged 2 commits into
mainfrom
gate-existing-id
Oct 26, 2026
Merged

thorwhalen merged 2 commits into
mainfrom
gate-existing-id

Conversation

@thorwhalen

@thorwhalen thorwhalen commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Additive, for i2mint/heed#88: heed's review page ids must not change, so a link can now be made over an id the host already has.

  • create(..., token=): validated with check_token, refused if a link already has it.
  • set_password(token, pw | None) and set_expires(token, when) change a live link; a revoked one stays revoked (KeyError); a new password ends every open unlock (HMAC keyed by the hash).

Tests added (52 pass with doctests, ruff clean). Review: additive API only, no behaviour change to existing calls (self-review suffices; no new surface, no dependency).

Adversarial review (fresh Opus agent): verdict "fix first", all confirmed and fixed: (1) set_* could undo a concurrent revoke, so the record is now read right before the write via one _update (the residual window of a store with no compare-and-set is documented; multi-worker hosts serialise writes per token); (2) create(token=) overwrote a damaged record, so it now checks token in store; (3) caller owns the id's randomness, said in the docstring; tests added for the revoked-id, new-password, past-date, missing-token and damaged-record cases. Cut: duplicated hash/length code folded into _hash_password.

@thorwhalen
thorwhalen merged commit b0f350e into main Oct 26, 2026
12 checks passed
@thorwhalen
thorwhalen deleted the gate-existing-id branch October 26, 2026 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant