Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix timeout UI OTP #168

Merged
merged 2 commits into from
Nov 21, 2023
Merged

fix timeout UI OTP #168

merged 2 commits into from
Nov 21, 2023

Conversation

jj-so
Copy link
Contributor

@jj-so jj-so commented Nov 15, 2023

correction of the otp_timeout

	modified:   nitrokeyapp/secrets_tab/__init__.py
@jj-so jj-so added the ui Issues related to UI label Nov 15, 2023
@jj-so jj-so linked an issue Nov 15, 2023 that may be closed by this pull request
2 tasks
@robin-nitrokey
Copy link
Member

Can you add some context for this change? The calculation does not make sense to me.

@jj-so
Copy link
Contributor Author

jj-so commented Nov 17, 2023

Previously, the validity period of the OTP was always different because the variable end changes in 30sec increments. By calculating end - start the validity is calculated and this is then added to the current time in order to obtain an exact end time = opt_timeout.

@robin-nitrokey
Copy link
Member

OTPs are typically calculated using 30 s time windows starting with the Unix epoch, so this is what we use for the validty:

period = 30
now = int(datetime.now().timestamp())
challenge = now // period
valid_from = datetime.fromtimestamp(challenge * period)
valid_until = datetime.fromtimestamp((challenge + 1) * period)
validity = (valid_from, valid_until)

I still don’t see why this would be wrong. What am I missing here?

@daringer daringer merged commit d73eaa6 into main Nov 21, 2023
8 checks passed
@daringer daringer deleted the improveOTPdisplay branch November 21, 2023 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ui Issues related to UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

secrets: Improve OTP display
3 participants