We attempt to be clever about string types in the token formatters.
We do this because in some cases, not all items in a token payload
are serialized to byte strings. To add flexibility for this, we use
tuples with a boolean value that denotes if the accompanying value is
a byte string or not. This helps us safely re-inflate the value from
a byte string back to it's .hex representations, typically with UUID
strings.
With python3, we actually hit an interesting case where what we pass
into the token payload doesn't actually maintain that state due to the
usage of msgpack. The msgpack library returns byte strings even though
the initial value may not have been a byte string. This breaks the
logic we have for the associated boolean value because the string type
changes and the boolean does not.
This commit adds a couple of if/statements to detect if we running on
python3 and if the boolean mismatches the actual value type. Then, it
attempts to do the right thing by decoding the string.
We should think about how we want to do this, or if there is a better
way.
Reviewed: https:/ /review. openstack. org/633288 /git.openstack. org/cgit/ openstack/ keystone/ commit/ ?id=af3aef940c0 162f12752a65282 368d16c2d17c4f
Committed: https:/
Submitter: Zuul
Branch: master
commit af3aef940c0162f 12752a65282368d 16c2d17c4f
Author: Lance Bragstad <email address hidden>
Date: Fri Jan 25 20:55:15 2019 +0000
Handle special cases with msgpack and python3
We attempt to be clever about string types in the token formatters.
We do this because in some cases, not all items in a token payload
are serialized to byte strings. To add flexibility for this, we use
tuples with a boolean value that denotes if the accompanying value is
a byte string or not. This helps us safely re-inflate the value from
a byte string back to it's .hex representations, typically with UUID
strings.
With python3, we actually hit an interesting case where what we pass
into the token payload doesn't actually maintain that state due to the
usage of msgpack. The msgpack library returns byte strings even though
the initial value may not have been a byte string. This breaks the
logic we have for the associated boolean value because the string type
changes and the boolean does not.
This commit adds a couple of if/statements to detect if we running on
python3 and if the boolean mismatches the actual value type. Then, it
attempts to do the right thing by decoding the string.
We should think about how we want to do this, or if there is a better
way.
Change-Id: Iaecd45ef985cbf 5ff4a6a724df96c 1304a927247
Closes-Bug: 1813085