On Thu, 2014-11-06 at 15:33 -0500, Nathaniel McCallum wrote:
> 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

I removed the period from the doc string to maintain consistency with
the rest of the plugin.

Nathaniel
From 24f8c5abe5c576e7399ce10b6634190bb67760d3 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..ead6fb40884157b31305c0d8fe540715ecf6a2a2 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