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

v1.0.0 cannot load strings signed by v0.24 #109

Closed
leohemsted opened this issue Oct 22, 2018 · 4 comments
Closed

v1.0.0 cannot load strings signed by v0.24 #109

leohemsted opened this issue Oct 22, 2018 · 4 comments

Comments

@leohemsted
Copy link

Testing with python 3.5.2.

I've got some strings that were serialised with v0.24. After upgrading, those strings are no longer able to be deserialised. (I've also tried this with Serializer, same outcome).

$ pip freeze | grep -i itsdangerous
itsdangerous==0.24
$ python -c "import itsdangerous; print(itsdangerous.URLSafeSerializer('secret-key').dumps('hello', salt='salt'))"
ImhlbGxvIg.IsTgRVmz0Tp1EYVQx7VJSY7R--M
$ pip install itsdangerous==1.0.0
python -c "import itsdangerous; print(itsdangerous.URLSafeSerializer('secret-key').loads('ImhlbGxvIg.IsTgRVmz0Tp1EYVQx7VJSY7R--M', salt='salt'))"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/me/.virtualenvs/test/lib/python3.5/site-packages/itsdangerous/serializer.py", line 131, in loads
    return self.load_payload(self.make_signer(salt).unsign(s))
  File "/Users/me/.virtualenvs/test/lib/python3.5/site-packages/itsdangerous/signer.py", line 175, in unsign
    raise BadSignature("Signature %r does not match" % sig, payload=value)
itsdangerous.exc.BadSignature: Signature b'IsTgRVmz0Tp1EYVQx7VJSY7R--M' does not match
@leohemsted
Copy link
Author

leohemsted commented Oct 22, 2018

Ah, this is due to the change of default digest method from sha1 to sha512. Can pass in signer_kwargs={'digest_method': hashlib.sha1} to the __init__ while we migrate.

@davidism
Copy link
Member

Yeah, you'll need to support that migration in your code. You can upgrade tokens by trying the new signer, then trying the old signer if it fails.

@davidism
Copy link
Member

#111, #112

@davidism
Copy link
Member

itsdangerous 1.1.0 has been released. It reverts to SHA-1, and adds a fallback mechanism to safely upgrade signing parameters in the future. It also reverts the package name to all lowercase "itsdangerous".

You can read a longer explanation here: https://palletsprojects.com/blog/itsdangerous-1-1-0-released/

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants