|
|
b3b562 |
From bfe2e6a96570102d3485200c476510b5b0d6f9ba Mon Sep 17 00:00:00 2001
|
|
|
b3b562 |
From: Christian Heimes <cheimes@redhat.com>
|
|
|
b3b562 |
Date: Thu, 28 Nov 2019 11:44:27 +0100
|
|
|
b3b562 |
Subject: [PATCH] Fix otptoken_sync plugin
|
|
|
b3b562 |
|
|
|
b3b562 |
The plugin had two bugs:
|
|
|
b3b562 |
|
|
|
b3b562 |
For one it did not work under Python 3 because urlencode() returns a string
|
|
|
b3b562 |
but HTTPSHandler expects bytes as data argument.
|
|
|
b3b562 |
|
|
|
b3b562 |
The primary key field name is not available in client plugins. Just pass
|
|
|
b3b562 |
the token name and let server code convert the name to DN.
|
|
|
b3b562 |
|
|
|
b3b562 |
Fixes: https://pagure.io/freeipa/issue/7804
|
|
|
b3b562 |
Signed-off-by: Christian Heimes <cheimes@redhat.com>
|
|
|
b3b562 |
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
|
|
|
b3b562 |
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
|
|
|
b3b562 |
---
|
|
|
b3b562 |
ipaclient/plugins/otptoken.py | 11 +++++------
|
|
|
b3b562 |
1 file changed, 5 insertions(+), 6 deletions(-)
|
|
|
b3b562 |
|
|
|
b3b562 |
diff --git a/ipaclient/plugins/otptoken.py b/ipaclient/plugins/otptoken.py
|
|
|
b3b562 |
index 3f389c46be2feedf0bb7cb95bd451bf0e6fe6333..e2dcb04a66648276b3f5dd033d048ab6df611b42 100644
|
|
|
b3b562 |
--- a/ipaclient/plugins/otptoken.py
|
|
|
b3b562 |
+++ b/ipaclient/plugins/otptoken.py
|
|
|
b3b562 |
@@ -27,7 +27,6 @@ from ipalib.messages import add_message, ResultFormattingError
|
|
|
b3b562 |
from ipalib.plugable import Registry
|
|
|
b3b562 |
from ipalib.frontend import Local
|
|
|
b3b562 |
from ipalib.util import create_https_connection
|
|
|
b3b562 |
-from ipapython.dn import DN
|
|
|
b3b562 |
from ipapython.version import API_VERSION
|
|
|
b3b562 |
|
|
|
b3b562 |
import locale
|
|
|
b3b562 |
@@ -162,13 +161,13 @@ class otptoken_sync(Local):
|
|
|
b3b562 |
sync_uri = urllib.parse.urlunparse(segments)
|
|
|
b3b562 |
|
|
|
b3b562 |
# Prepare the query.
|
|
|
b3b562 |
- query = {k: v for k, v in kwargs.items()
|
|
|
b3b562 |
- if k in {x.name for x in self.takes_options}}
|
|
|
b3b562 |
+ options = {x.name for x in self.takes_options}
|
|
|
b3b562 |
+ query = {k: v for k, v in kwargs.items() if k in options}
|
|
|
b3b562 |
if args and args[0] is not None:
|
|
|
b3b562 |
- obj = self.api.Object.otptoken
|
|
|
b3b562 |
- query['token'] = DN((obj.primary_key.name, args[0]),
|
|
|
b3b562 |
- obj.container_dn, self.api.env.basedn)
|
|
|
b3b562 |
+ # sync_token converts token name to token DN
|
|
|
b3b562 |
+ query['token'] = args[0]
|
|
|
b3b562 |
query = urllib.parse.urlencode(query)
|
|
|
b3b562 |
+ query = query.encode('utf-8')
|
|
|
b3b562 |
|
|
|
b3b562 |
# Sync the token.
|
|
|
b3b562 |
# pylint: disable=E1101
|
|
|
b3b562 |
--
|
|
|
b3b562 |
2.37.3
|
|
|
b3b562 |
|