Repository navigation
fix(auth): expose matched totp step so callers can reject replayed codes - #368
Merged
Merged
Conversation
There was a problem hiding this comment.
Correct. In totp-rs 6.0.0, check returns Option<u64>, the first matching counter in the skew window, so filtering on step > last gives the RFC 6238 §5.2 one-time-use rule. is_none_or needs Rust 1.82, and the MSRV is 1.85. Keeping the local unix_now() instead of check_current is right, because check_current panics on a pre-epoch clock.
Nit: verify_at and verify_now still accept replayed codes, and their docs don't say so. Add a line pointing callers to verify_step_* for login, or deprecate them, so new code doesn't pick the version without replay protection.
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.
Adds
TotpEnrollment::verify_step_atandverify_step_now, which return the matched step and reject any step at or beforelast_used_step. Callers persist the returned step atomically with the login to enforce RFC 6238 section 5.2.verify_atandverify_nowkeep their signatures (additive, not breaking).Closes #348