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

Encrypted cookies don't work in Python 3.2 #21

Closed
kiwidrew opened this issue Jun 20, 2012 · 7 comments
Closed

Encrypted cookies don't work in Python 3.2 #21

kiwidrew opened this issue Jun 20, 2012 · 7 comments

Comments

@kiwidrew
Copy link

It appears that none of the beaker.crypto code is ready for Python 3. In particular, pbkdf2.py does a bunch of isinstance() checks which enforce that the encryption keys are 'str' objects, and calls encode() on them if not. This is of course precisely backwards when working with str and bytes in Python 3.

I've tried making a few patches to the code, but this only serves to reveal additional issues, and I don't have the time to prepare a complete patch for now.

In the meantime, please update the docs to indicate that encrypted cookies (that is, cookie-only sessions) are not supported when running under Python 3.

@FedericoCeratto
Copy link
Contributor

https://github.com/bbangert/beaker/blob/master/beaker/crypto/pbkdf2.py#L160

In Python3, line 160 converts passphrase to "bytes" type: passphrase = passphrase.encode("UTF-8")

Then, line 161 checks if the variable has type "str" and proceeds to raise an exception: if not isinstance(passphrase, str)

@FedericoCeratto
Copy link
Contributor

Any update on this? Thanks!

@bbangert
Copy link
Owner

I'm open to pull requests that fix this while retaining backwards compatibility.

@FedericoCeratto
Copy link
Contributor

@amol- added patch to support Python3 #75
The code is a bit tricky, I'd recommend improving the unit testing around the module.

@amol-
Copy link
Collaborator

amol- commented Feb 25, 2015

backported pbkdf2 and added four pbkdf2 related tests to ensure behaviour is the same as before.
It seems that it is now correctly working on Python3.4 which is now included in travis:

https://travis-ci.org/bbangert/beaker

@amol-
Copy link
Collaborator

amol- commented Feb 25, 2015

Beaker is now natively python3 compatible and will be released as 1.7.0dev as a prerelease

See https://travis-ci.org/bbangert/beaker/builds/52155288

@amol- amol- closed this as completed Feb 25, 2015
@FedericoCeratto
Copy link
Contributor

🍰

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

4 participants