Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Password checking error when using SQLAlchemy and Postgres #736

Open
npcole opened this issue Apr 2, 2024 · 0 comments
Open

Password checking error when using SQLAlchemy and Postgres #736

npcole opened this issue Apr 2, 2024 · 0 comments

Comments

@npcole
Copy link

npcole commented Apr 2, 2024

For some reason after updating to the latest versions of sqlalchemy and sqlalchemy utils, checking hashed passwords started to fail with a TypeError:


     if this_password.password == password:
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/home/quill/quill/venv3.11/lib/python3.11/site-packages/sqlalchemy_utils/types/password.py", line 60, in __eq__
]     valid, new = self.context.verify_and_update(value, self.hash)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/home/quill/quill/venv3.11/lib/python3.11/site-packages/passlib-1.7.4-py3.11.egg/passlib/context.py", line 2422, in verify_and_update
     record = self._get_or_identify_record(hash, scheme, category)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/home/quill/quill/venv3.11/lib/python3.11/site-packages/passlib-1.7.4-py3.11.egg/passlib/context.py", line 2031, in _get_or_identify_record
     return self._identify_record(hash, category)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/home/quill/quill/venv3.11/lib/python3.11/site-packages/passlib-1.7.4-py3.11.egg/passlib/context.py", line 1122, in identify_record
     raise ExpectedStringError(hash, "hash")

changing line 60 of types/password.py to read:

valid, new = self.context.verify_and_update(value, self.hash.decode())

appears to fix the error.

I'm not sure what is suddenly either causing the hash to be passed to the application as a bytearray or what is suddenly causing sqlalchemy-utils to complain.

As far as I can tell the column type has not changed in the database.

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

No branches or pull requests

1 participant