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

Change password_hash to LargeBinary from Text #2623

Closed
12 tasks
stevepiercy opened this issue Jun 3, 2016 · 1 comment
Closed
12 tasks

Change password_hash to LargeBinary from Text #2623

stevepiercy opened this issue Jun 3, 2016 · 1 comment

Comments

@stevepiercy
Copy link
Member

  • Change the column password_hash to type LargeBinary from Text.
  • Remove .encode('utf8') so that it no longer encodes the value.
  • Update across the following files:
    • docs/tutorials/wiki2/src/models/tutorial/models/user.py
    • docs/tutorials/wiki2/src/views/tutorial/models/user.py
    • docs/tutorials/wiki2/src/authentication/tutorial/models/user.py
    • docs/tutorials/wiki2/src/authorization/tutorial/models/user.py
    • docs/tutorials/wiki2/src/tests/tutorial/models/user.py
  • Update tutorial docs to align with resulting changes.
    • docs/tutorials/wiki2/definingmodels
    • docs/tutorials/wiki2/definingviews
    • docs/tutorials/wiki2/authentication
    • docs/tutorials/wiki2/authorization
    • docs/tutorials/wiki2/tests

See #2576 for explanation.

Closes #2605.

@stevepiercy
Copy link
Member Author

@mmerickel is working on fix for set_password that will resolve this.

mmerickel added a commit to mmerickel/pyramid that referenced this issue Jul 16, 2016
Something really weird is happening but this fixes it. SQLAlchemy is
returning the "password_hash" from queries as the type that it was
inserted as. Not consistently unicode or bytes. If I insert bytes, then
I get bytes back out. If I insert unicode then I get unicode back out.
It's unclear why, as the type is Text, the data we're storing is
unambiguously US-ASCII and the connection is using a consistent
text_factory for unicode conversions of "str" on Python 3.

Here, we ensure that we always insert the value as unicode which appears
to fix downstream issues like those mentioned in Pylons#2605. I was able to
reproduce that bug and confirm this fixes it if the original database is
initialized using this fix.

Obsoletes Pylons#2623.
mmerickel added a commit to mmerickel/pyramid that referenced this issue Jul 16, 2016
Something really weird is happening but this fixes it. SQLAlchemy is
returning the "password_hash" from queries as the type that it was
inserted as. Not consistently unicode or bytes. If I insert bytes, then
I get bytes back out. If I insert unicode then I get unicode back out.
It's unclear why, as the type is Text, the data we're storing is
unambiguously US-ASCII and the connection is using a consistent
text_factory for unicode conversions of "str" on Python 3.

Here, we ensure that we always insert the value as unicode which appears
to fix downstream issues like those mentioned in Pylons#2605. I was able to
reproduce that bug and confirm this fixes it if the original database is
initialized using this fix.

Obsoletes Pylons#2623.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant