fix(auth): fail closed on reusable invite flags - #3059
Open
tang-vu wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why this matters
Guest magic links are single-use unless their stored record explicitly enables reuse. Python truthiness made the persisted string false reusable, allowing repeated redemption of a token that the record appeared to mark single-use.
The invariant is: only JSON boolean true makes a guest token reusable. Owner tokens keep their intentional always-reusable contract. A schema-invalid guest value fails closed and is consumed after the first successful redemption.
Overlap check
Searched open and closed PRs for magic link reusable string false and _normalize_record, plus every open PR touching magic_link.py. #2996/#2321 address revoke-prefix ambiguity, #2995 unreadable stores, #2522 expiry validation, #2521 store-root shape, #2413 legacy timestamps, and #2236/#2020 file permissions. None covers the reusable scalar or redemption cardinality. This scope is independent.
Validation
The regression writes a schema-incompatible receipt to the real token store, redeems through /auth/magic-link/{token}, and proves the second redemption returns the same opaque 404 as other invalid links.
Tradeoffs, review, and rollback
This intentionally revokes repeat-use behavior from malformed legacy guest records. Valid reusable booleans and owner-card tokens are unchanged. No store migration is required because normalization applies on read. Because this is an authentication lifecycle change, it should receive independent human review before merge. Rollback is one normalization expression.