Make totp_timestamp column an integer #140
Open
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.
The ROTP gem expects the prior timestamp in
verify_with_drift_and_prior
to be an integer. Moreover, whenverify_with_drift_and_prior
returns it returns an integer.We noticed a bug where the
totp_timestamp
column was always nil. The reason for this was that the database had a timestamp column and when this gem was attempting to assigntotp_timestamp
to an integer, it was actually set to nil.This commit changes the column to an integer instead of a timestamp to avoid the problem described above.
Another potential solution is to change the result of
verify_with_drift_and_prior
to a datetime before saving, and then change the value oftotp_timestamp
to an integer before callingverify_with_drift_and_prior
.I went with the solution I did instead b/c it looked like the path of least resistance, but am happy to modify my PR to leave the column as a timestamp and handle moving between integers and dates in the
authenticate_totp
method.