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

[1.4.0rc1] appkeys plugin: newly generated keys under Python 3 are binary and don't match provided strings #3350

Closed
foosel opened this issue Nov 26, 2019 · 1 comment

Comments

@foosel
Copy link
Owner

@foosel foosel commented Nov 26, 2019

Problem

Newly generated appkeys api key:

admin:
- api_key: !!binary |
    OTdlNDNhNmMwODY2OWM3MTMzYmY2MDNmMjBkZmI1ZjE=
  app_id: test

Under Python 3 this gets loaded as a bytes instance b'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 there str is bytes. 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.

foosel added a commit that referenced this issue Nov 26, 2019
Instead of binaries.

Closes #3350
@foosel

This comment has been minimized.

Copy link
Owner Author

@foosel foosel commented Dec 2, 2019

1.4.0rc2 is out.

@foosel foosel closed this Dec 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.