PY3 unicode text values change in ldap not taking care of py2 special charater unicode strings
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack Identity (keystone) |
New
|
Undecided
|
Abhishek Sharma M |
Bug Description
wrt to the recent community change https:/
But while configuring ldap with user (say flügel), we are getting the below error.
[Mon Apr 22 08:04:36.723781 2019] [:error] [pid 46754] [remote ] ref = driver.
[Mon Apr 22 08:04:36.723802 2019] [:error] [pid 46754] [remote ] File "/usr/lib/
[Mon Apr 22 08:04:36.724054 2019] [:error] [pid 46754] [remote ] user_ref = self._get_
[Mon Apr 22 08:04:36.724082 2019] [:error] [pid 46754] [remote ] File "/usr/lib/
[Mon Apr 22 08:04:36.724122 2019] [:error] [pid 46754] [remote ] return self.user.
[Mon Apr 22 08:04:36.724145 2019] [:error] [pid 46754] [remote ] File "/usr/lib/
[Mon Apr 22 08:04:36.724184 2019] [:error] [pid 46754] [remote ] obj = super(UserApi, self).get(user_id, ldap_filter=
[Mon Apr 22 08:04:36.724208 2019] [:error] [pid 46754] [remote ] File "/usr/lib/
[Mon Apr 22 08:04:36.724958 2019] [:error] [pid 46754] [remote ] ref = super(EnabledEm
[Mon Apr 22 08:04:36.724989 2019] [:error] [pid 46754] [remote ] File "/usr/lib/
[Mon Apr 22 08:04:36.725031 2019] [:error] [pid 46754] [remote ] res = self._ldap_
[Mon Apr 22 08:04:36.725055 2019] [:error] [pid 46754] [remote ] File "/usr/lib/
[Mon Apr 22 08:04:36.725108 2019] [:error] [pid 46754] [remote ] six.text_
[Mon Apr 22 08:04:36.725163 2019] [:error] [pid 46754] [remote ] UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 2: ordinal not in range(128)
It fails at six.text_type which is basically trying to convert the string to unicode. But what if we are getting a string value with special characters there, in those cases the execution fails. (six.text_type cannot convert special characters to unicode, it can just convert plain ascii to unicode type.)
IMO we should rather be using utf8_decode() from /usr/lib/
Once the above is fixed we get the below similar error,
[Mon Apr 22 05:00:30.699425 2019] [:error] [pid 121709] [remote ] File "/usr/lib/
[Mon Apr 22 05:00:30.699444 2019] [:error] [pid 121709] [remote ] for group in self.get_all(query, hints)]
[Mon Apr 22 05:00:30.699455 2019] [:error] [pid 121709] [remote ] File "/usr/lib/
[Mon Apr 22 05:00:30.711297 2019] [:error] [pid 121709] [remote ] for x in self._ldap_
[Mon Apr 22 05:00:30.711359 2019] [:error] [pid 121709] [remote ] File "/usr/lib/
[Mon Apr 22 05:00:30.720098 2019] [:error] [pid 121709] [remote ] return f(self, hints, *args, **kwargs)
[Mon Apr 22 05:00:30.720134 2019] [:error] [pid 121709] [remote ] File "/usr/lib/
[Mon Apr 22 05:00:30.720188 2019] [:error] [pid 121709] [remote ] self.id_attr)
[Mon Apr 22 05:00:30.720259 2019] [:error] [pid 121709] [remote ] UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 13: ordinal not in range(128)
Here,
query = u'(&%s(
After resolving the above, we get the below error while trying to get the role assignments for the group after we configuring a ldap group with special character (flügel).
[Mon Apr 22 10:49:26.263074 2019] [:error] [pid 99824] [remote ] File "/usr/lib/
[Mon Apr 22 10:49:26.263097 2019] [:error] [pid 99824] [remote ] for user_id in self._transform
[Mon Apr 22 10:49:26.263108 2019] [:error] [pid 99824] [remote ] File "/usr/lib/
[Mon Apr 22 10:49:26.263125 2019] [:error] [pid 99824] [remote ] user_id = self.user.
[Mon Apr 22 10:49:26.263136 2019] [:error] [pid 99824] [remote ] File "/usr/lib/
[Mon Apr 22 10:49:26.263153 2019] [:error] [pid 99824] [remote ] return ldap.dn.
[Mon Apr 22 10:49:26.263163 2019] [:error] [pid 99824] [remote ] File "/usr/lib64/
[Mon Apr 22 10:49:26.263205 2019] [:error] [pid 99824] [remote ] return ldap.functions.
[Mon Apr 22 10:49:26.263236 2019] [:error] [pid 99824] [remote ] File "/usr/lib64/
[Mon Apr 22 10:49:26.263257 2019] [:error] [pid 99824] [remote ] result = func(*args,
[Mon Apr 22 10:49:26.263283 2019] [:error] [pid 99824] [remote ] UnicodeEncodeError: 'ascii' codec can't encode character u'\\xfc' in position 5: ordinal not in range(128)
Here while trying to list users (having special characters) in group (having special characters), the user dn is unicode & we are trying to convert that into a str (using _dn_to_id() in common.py). First we need to make sure that the user is string & not some unicode value which will cause UnicodeEncodeError.
Changed in keystone: | |
assignee: | nobody → Abhishek Sharma M (abhi.sharma) |
description: | updated |
Changed in keystone: | |
status: | Incomplete → New |
Fix proposed to branch: master /review. opendev. org/654601
Review: https:/