Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign up[1.4.0rc1] appkeys plugin: newly generated keys under Python 3 are binary and don't match provided strings #3350
Labels
Comments
This comment has been minimized.
This comment has been minimized.
1.4.0rc2 is out. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem
Newly generated appkeys api key:
Under Python 3 this gets loaded as a
bytes
instanceb'97e43a6c08669c7133bf603f20dfb5f1'
instead of the string instance'97e43a6c08669c7133bf603f20dfb5f1'
that it should be. The reasons seems to be that we actually do generate a binary blob instead of a string, and the only reason that hasn't yet caused issues under Python 2 is that therestr
isbytes
. Under Python 3 a comparison to'97e43a6c08669c7133bf603f20dfb5f1'
as coming in via the API will fail/not match and thus the key will be invalid.Solution
Generate strings, eg. by switching from
hexlify(os.urandom(16))
to''.join('%02X' % z for z in bytes(uuid.uuid4().bytes))
for key generation.