Skip to content

Conversation

@sharmagot
Copy link
Collaborator

@sharmagot sharmagot commented Dec 8, 2025

This MR improves TOTP validation in the Vertica Python driver by enforcing strict 6-digit numeric checks.
Invalid TOTPs (alphanumeric, incorrect length, or with extra spaces) are now blocked locally and return a consistent error message:
“Invalid TOTP: Please enter a valid 6-digit numeric code.”
This prevents invalid authentication requests from being sent to the server and improves user experience.

@sharmagot sharmagot self-assigned this Dec 8, 2025
@sharmagot sharmagot requested a review from ssharieff21 December 8, 2025 05:20
try:
print("Enter TOTP: ", end="", flush=True)
ready, _, _ = select.select([sys.stdin], [], [], timeout_seconds)
if ready:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we wait 5mins for the user to enter TOTP?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hi Siva, if the user does not provide the TOTP within 5 minutes, the session should expire—meaning the connection between the driver and the server should be terminated.

result = validate_totp_code(totp_input, totp_is_valid=None)
if not result.ok:
msg = result.message or INVALID_TOTP_MSG
print(msg)
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this print(msg) for debugging purpose, please remove it

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hi Siva, I have removed the debug message .

@sivaalamp
Copy link
Collaborator

MR description did not cover all the issues that addressed. Please update the MR description accordingly.

INVALID_TOTP_MSG = 'Invalid TOTP: Please enter a valid 6-digit numeric code.'

if validate_totp_code is not None:
result = validate_totp_code(self.totp, totp_is_valid=None)
Copy link
Collaborator

Choose a reason for hiding this comment

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

validate_totp_code function definition is missing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hi Siva , Added the definition for validate_totp_code.

Copy link
Collaborator

@sivaalamp sivaalamp left a comment

Choose a reason for hiding this comment

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

Comments are added

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.

3 participants