Skip to content
Closed

1.1.2 #572

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions vertica_python/vertica/messages/frontend_messages/password.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,41 @@
from ..backend_messages.authentication import Authentication
from ....compat import as_bytes

from . import crypt_windows as crypt

try:
if os.name == 'nt':
# Windows-specific crypt module workaround
# Try using passlib or cryptography in place of 'crypt' on Windows
try:
from passlib.hash import sha256_crypt as crypt # Passlib as fallback
except ImportError:
try:
from cryptography.hazmat.primitives import hashes # Cryptography fallback
crypt = hashes # Note: hashes doesn't replace 'crypt', review usage
except ImportError:
raise ValueError(
"Neither 'passlib' nor 'cryptography' is available on Windows, "
"and the 'crypt' module is missing. "
"Please install one of these libraries or adapt the code to use a different hashing mechanism."
)
else:
# Try importing cryptography as an alternative for non-Windows platforms
try:
from cryptography.hazmat.primitives import hashes
crypt = hashes # Note: hashes doesn't replace 'crypt', review usage
except ImportError:
# If cryptography isn't available, fallback to passlib
try:
from passlib.hash import sha256_crypt as crypt
except ImportError:
raise ValueError(
"Neither 'cryptography' nor 'passlib' is available, "
"and the 'crypt' module is missing. "
"Please install one of these libraries or adapt the code to use a different hashing mechanism."
)
except ValueError as e:
raise ValueError(f"Error importing crypt module: {e}") from e


class Password(BulkFrontendMessage):
message_id = b'p'

Expand Down
Loading