shaj13 / go-guardian

Go-Guardian is a golang library that provides a simple, clean, and idiomatic way to create powerful modern API and web authentication.
MIT License
543 stars 55 forks source link

otp package must verify totp also in the past timestamps #57

Closed shaj13 closed 3 years ago

shaj13 commented 4 years ago

Context: TOTP verify failed due network latency and transmission delay as defined in https://tools.ietf.org/html/rfc6238#section-5.2 , The validation system should compare OTPs not only with the receiving timestamp but also the past timestamps that are within the transmission delay

need to add a new field to struct e.g DelayWindow , and the verify method check if the type is totp so its generated 3 code for past, current, feature timestamp and validate the user code against three generated codes.

e.g

counters := []uint64{interval()}
if TOTP {
for i := 1; i <= DelayWindow; i++ {
counters = append(counters, counters[0]-i)
counters = append(counters, counters[0]+i)
}
and verify()
shaj13 commented 3 years ago

Fixed #64