This is possible because python-qrcode's output now fits in a standard
terminal. Also, update ipa-otp-import and otptoken-add-yubikey to
disable QR code output as it doesn't make sense in these contexts.

https://fedorahosted.org/freeipa/ticket/4703
From 86d9c7f6ec82db1c4b29e97c0529970e888d7bb8 Mon Sep 17 00:00:00 2001
From: Nathaniel McCallum <npmccal...@redhat.com>
Date: Thu, 6 Nov 2014 15:30:13 -0500
Subject: [PATCH] Enable QR code display by default in otptoken-add

This is possible because python-qrcode's output now fits in a standard
terminal. Also, update ipa-otp-import and otptoken-add-yubikey to
disable QR code output as it doesn't make sense in these contexts.

https://fedorahosted.org/freeipa/ticket/4703
---
 ipalib/plugins/otptoken.py               | 4 ++--
 ipalib/plugins/otptoken_yubikey.py       | 1 +
 ipaserver/install/ipa_otptoken_import.py | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/ipalib/plugins/otptoken.py b/ipalib/plugins/otptoken.py
index 2b5f1c5fb83341d392e165a3507f5076820f1d3a..f16bce04f5274c3e519856512025e38b3995a4f4 100644
--- a/ipalib/plugins/otptoken.py
+++ b/ipalib/plugins/otptoken.py
@@ -249,7 +249,7 @@ class otptoken_add(LDAPCreate):
     msg_summary = _('Added OTP token "%(value)s"')
 
     takes_options = LDAPCreate.takes_options + (
-        Flag('qrcode?', label=_('Display QR code')),
+        Flag('qrcode', label=_('Display QR code.'), default=True),
     )
 
     has_output_params = LDAPCreate.has_output_params + (
@@ -329,7 +329,7 @@ class otptoken_add(LDAPCreate):
         rv = super(otptoken_add, self).output_for_cli(textui, output, *args, **options)
 
         # Print QR code to terminal if specified
-        if uri and options.get('qrcode', False):
+        if uri and options['qrcode']:
             print "\n"
             qr = qrcode.QRCode()
             qr.add_data(uri)
diff --git a/ipalib/plugins/otptoken_yubikey.py b/ipalib/plugins/otptoken_yubikey.py
index e70ddb6e42b5ea34d7ebecb252d6bbd73ac64d03..643096a507121f3596d7d3798bff024c08d738fb 100644
--- a/ipalib/plugins/otptoken_yubikey.py
+++ b/ipalib/plugins/otptoken_yubikey.py
@@ -124,6 +124,7 @@ class otptoken_add_yubikey(Command):
                                                 ipatokenotpalgorithm=u'sha1',
                                                 ipatokenhotpcounter=0,
                                                 ipatokenotpkey=key,
+                                                qrcode=False,
                                                 **options)
 
         # Suppress values we don't want to return.
diff --git a/ipaserver/install/ipa_otptoken_import.py b/ipaserver/install/ipa_otptoken_import.py
index 31a6902014b8e3b2aafb3ba98a4190dc2059a3e7..70a38867c64674ce5879be6b7b03270856a31c77 100644
--- a/ipaserver/install/ipa_otptoken_import.py
+++ b/ipaserver/install/ipa_otptoken_import.py
@@ -517,7 +517,7 @@ class OTPTokenImport(admintool.AdminTool):
             # Parse tokens
             for keypkg in self.doc.getKeyPackages():
                 try:
-                    api.Command.otptoken_add(keypkg.id, **keypkg.options)
+                    api.Command.otptoken_add(keypkg.id, qrcode=False, **keypkg.options)
                 except Exception as e:
                     self.log.warn("Error adding token: %s", e)
                 else:
-- 
2.1.0

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to