Add strict TOTP validation to block invalid authentication requests #578
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.
This MR adds strict client-side validation for TOTP values in the Python driver to prevent invalid authentication requests from being sent to the server.
Problem
The Python driver currently allows invalid TOTP values (e.g., ot1234, opentext, values shorter/longer than 6 digits) to pass through and reach the server.
This results in unnecessary authentication attempts and inconsistent behavior.
Solution
Added explicit validation to ensure TOTP:
Contains only numeric characters (isdigit() check)
Is exactly 6 digits long
Added corresponding error messages and logger entries.
Applied validation both:
When TOTP is passed via connection options
When TOTP is entered interactively during authentication
Expected Behavior
Driver should block invalid TOTP values before sending an authentication request.
Only valid 6-digit numeric TOTP codes should be accepted.