Skip to content

FEATURE: Make TOTP verification window configurable#38

Open
gradinarufelix wants to merge 1 commit intosandstorm:mainfrom
gradinarufelix:feature/configurable-totp-window
Open

FEATURE: Make TOTP verification window configurable#38
gradinarufelix wants to merge 1 commit intosandstorm:mainfrom
gradinarufelix:feature/configurable-totp-window

Conversation

@gradinarufelix
Copy link

Add totpVerificationWindow setting to allow operators to configure the tolerance for TOTP code verification.

  • Add optional $window parameter to TOTPService::checkIfOtpIsValid()
  • Inject configuration in LoginController and BackendController
  • Default to 0 (strict, original behavior) for backward compatibility
  • Document the new setting in README.md

Setting totpVerificationWindow to 1 is recommended as it prevents authentication failures caused by:

  • Clock drift between user device and server
  • Period boundary race conditions (code generated at end of period)
  • Network latency during code submission

Add totpVerificationWindow setting to allow operators to configure
the tolerance for TOTP code verification.

- Add optional $window parameter to TOTPService::checkIfOtpIsValid()
- Inject configuration in LoginController and BackendController
- Default to 0 (strict, original behavior) for backward compatibility
- Document the new setting in README.md

Setting totpVerificationWindow to 1 is recommended as it prevents
authentication failures caused by:
- Clock drift between user device and server
- Period boundary race conditions (code generated at end of period)
- Network latency during code submission
Copy link
Contributor

@JamesAlias JamesAlias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we upgraded to OTPHP v11, please adjust your PR to use the newly introduced leeway parameter instead of the old window parameter.

https://github.com/Spomky-Labs/otphp/blob/11.0.x/src/TOTP.php#L87

The leeway parameter seems to specify an allowed time drift in seconds (+/-).
Thank you for the work! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants