Univention Bugzilla – Bug 50529
UDM REST API can't handle umlaut in DN (HTTP 500)
Last modified: 2020-08-26 16:35:34 CEST
GET of https://HOST/univention/udm/users/user/uid=userä,cn=users,BASEDN leads to --------------------------------------------------------------------------- 21.11.19 15:07:14 ERROR ( 466) : Uncaught exception GET /udm/users/user/uid=user%C3%A4,cn=users,dc=ucs-test,dc=intranet (0.0.0.0) HTTPServerRequest(protocol='http', host='172.17.0.2', method='GET', uri='/udm/users/user/uid=user%C3%A4,cn=users,dc=ucs-test,dc=intranet', version='HTTP/1.1', remote_ip='0.0.0.0', headers={'X-Umc-Https': 'on', 'Via': '1.1 master.ucs-test.intranet', 'Accept-Language': 'de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7', 'Accept-Encoding': 'gzip, deflate, br', 'X-Forwarded-Host': '172.17.0.2', 'X-Forwarded-Ssl': 'on', 'Sec-Fetch-Site': 'cross-site', 'Host': '172.17.0.2', 'Accept': 'application/json', 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36', 'Dnt': '1', 'Connection': 'close', 'X-Forwarded-Proto': 'https', 'Cookie': 'rocketchatscreenshare=chrome; rocketchatscreenshare=chrome; rocketchatscreenshare=chrome', 'Sec-Fetch-Mode': 'cors', 'X-Forwarded-Server': 'master.ucs-test.intranet', 'X-Forwarded-For': '172.17.0.1', u'Authorization': 'Basic QWRtaW5pc3RyYXRvcjp1bml2ZW50aW9u'}) Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/tornado/web.py", line 1469, in _execute result = yield result File "/usr/lib/python2.7/dist-packages/tornado/gen.py", line 1015, in run value = future.result() File "/usr/lib/python2.7/dist-packages/tornado/concurrent.py", line 237, in result raise_exc_info(self._exc_info) File "/usr/lib/python2.7/dist-packages/tornado/gen.py", line 1024, in run yielded = self.gen.send(value) File "/usr/lib/python2.7/dist-packages/univention/admin/rest/module.py", line 2622, in get props.update(self._options(object_type, obj.dn)) File "/usr/lib/python2.7/dist-packages/univention/admin/rest/module.py", line 2647, in _options self.add_link(props, 'udm:object-modules', self.urljoin('../../'), title=_('All modules')) File "/usr/lib/python2.7/dist-packages/univention/admin/rest/module.py", line 762, in urljoin return urljoin(urljoin(urlunparse((scheme, base.netloc, 'univention/' if self.request.headers.get('X-Forwarded-Host') else '/', '', '', '')), quote(self.request.path_decoded.lstrip('/'))), '/'.join(args)) + query_string File "/usr/lib/python2.7/urllib.py", line 1299, in quote return ''.join(map(quoter, s)) KeyError: u'\xe4' 21.11.19 15:07:14 ERROR ( 466) : Uncaught exception in write_error Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/tornado/web.py", line 994, in send_error self.write_error(status_code, **kwargs) File "/usr/lib/python2.7/dist-packages/univention/admin/rest/module.py", line 884, in write_error self.add_link(response, 'self', self.urljoin(''), title=_('HTTP-Error %d: %s') % (status_code, title)) File "/usr/lib/python2.7/dist-packages/univention/admin/rest/module.py", line 762, in urljoin return urljoin(urljoin(urlunparse((scheme, base.netloc, 'univention/' if self.request.headers.get('X-Forwarded-Host') else '/', '', '', '')), quote(self.request.path_decoded.lstrip('/'))), '/'.join(args)) + query_string File "/usr/lib/python2.7/urllib.py", line 1299, in quote return ''.join(map(quoter, s)) KeyError: u'\xe4' 21.11.19 15:07:14 ERROR ( 466) : 500 GET /udm/users/user/uid=user%C3%A4,cn=users,dc=ucs-test,dc=intranet (0.0.0.0) 16.98ms ERROR:tornado.access:500 GET /udm/users/user/uid=user%C3%A4,cn=users,dc=ucs-test,dc=intranet (127.0.0.1) 20.11ms
The URL with umlaut is generated by the UDM REST API in the collection at https://HOST/univention/udm/users/user/
$ univention-ldapsearch -LLL 'uid=userä' dn uid dn:: dWlkPXVzZXLDpCxjbj11c2VycyxkYz11Y3MtdGVzdCxkYz1pbnRyYW5ldA== uid:: dXNlcsOk
Typo because of `from future import unicode_literals`: Patch in branch git:fbest/50529-unicode-dns: diff --git management/univention-directory-manager-rest/src/univention/admin/rest/module.py management/univention-directory-manager-rest/src/univention/admin/rest/module.py index a7f17f7739..a3f5c9a4c7 100755 --- management/univention-directory-manager-rest/src/univention/admin/rest/module.py +++ management/univention-directory-manager-rest/src/univention/admin/rest/module.py @@ -759,7 +759,7 @@ class ResourceBase(object): break if _scheme == 'http': scheme = 'http' - return urljoin(urljoin(urlunparse((scheme, base.netloc, 'univention/' if self.request.headers.get('X-Forwarded-Host') else '/', '', '', '')), quote(self.request.path_decoded.lstrip('/'))), '/'.join(args)) + query_string + return urljoin(urljoin(urlunparse((scheme, base.netloc, 'univention/' if self.request.headers.get('X-Forwarded-Host') else '/', '', '', '')), quote(self.request.path_decoded.lstrip(b'/'))), '/'.join(args)) + query_string def abspath(self, *args): return urljoin(self.urljoin('/univention/udm/' if self.request.headers.get('X-Forwarded-Host') else '/udm/'), '/'.join(args))
This issue appears to be responsible for a recent customer report that it is possible to create users by using the Kelvin-API but attempts to delete them will fail. directory-manager-rest.log shows the same exception
Some of the patches of the current UCS 5 have been backported to fix this. The problem was, as mentioned in comment #3, the unicode_literals import, which has been removed now. Additionally the quoting of the DN when moving an object has been fixed as well. A test case has also been added which tests creation, modification, moving and retrieval of objects containing umlauts in the DN. ucs-test (9.0.4-47) 8147ffed8f9e | Bug #50529: test with umlauts in DN univention-directory-manager-rest (9.0.16-9) 6af134dc4884 | Bug #50529: fix quoting of DN when moving objects 18507082fe16 | Bug #50529: (Bug #51685): fix python 3 compatibility c961c9bcaece | Bug #50529: (Bug #51685): remove __future__.unicode_literals import 1cce61ba91a2 | Bug #50529: (Bug #51685): fix Python3 imports cb4bd9fb8308 | Bug #50529: (Bug #51685): backport Python 3 compatibility fixes from UCS 5 9146ae3d63d1 | Bug #50529: (Bug #51685): Fix Python 3 dict.keys() concat
Code: OK Test: OK YAML: OK GET of https://HOST/univention/udm/users/user/uid=userä,cn=users,BASEDN: OK
<https://errata.software-univention.de/#/?erratum=4.4x721>