On Thu, 2014-11-13 at 13:17 +0100, Martin Kosek wrote: > On 11/13/2014 07:53 AM, Nathaniel McCallum wrote: > > 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 > > > > I am not reviewing, just curious. What is the purpose of --qrcode option with > default=True? > > takes_options = LDAPCreate.takes_options + ( > - Flag('qrcode?', label=_('Display QR code')), > + Flag('qrcode', label=_('Display QR code'), default=True), > ) > > How can user turn it off? Both passing no option and passing --qrcode will get > the same result, no? :-) > > Shouldn't we instead change --qrcode to --no-qrcode and process somehow fill > qrcode=0 when it's enabled? (To achieve API compatibility with old clients).
I see three options: 1. Don't let the user turn it off from the command line (he can still turn it off from the Python API). 2. Change it to --no-qrcode (API change) 3. Change the type to Bool (API change) Like you, I like #2 the best. Attached is an implementation.
From 816d3d5f98b78a8b82d81ef2f7162614b8ead4b2 Mon Sep 17 00:00:00 2001 From: Nathaniel McCallum <[email protected]> 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 --- API.txt | 2 +- VERSION | 4 ++-- ipalib/plugins/otptoken.py | 4 ++-- ipalib/plugins/otptoken_yubikey.py | 1 + ipaserver/install/ipa_otptoken_import.py | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/API.txt b/API.txt index 0000491d7a76fd1d2d50208d314d1600839ce295..357c0b1aeaafcacf8d82d57fbfb3fabc21ec8f93 100644 --- a/API.txt +++ b/API.txt @@ -2611,7 +2611,7 @@ option: Int('ipatokentotpclockoffset', attribute=True, autofill=True, cli_name=' option: Int('ipatokentotptimestep', attribute=True, autofill=True, cli_name='interval', default=30, minvalue=5, multivalue=False, required=False) option: Str('ipatokenvendor', attribute=True, cli_name='vendor', multivalue=False, required=False) option: Flag('no_members', autofill=True, default=False, exclude='webui') -option: Flag('qrcode?', autofill=True, default=False) +option: Flag('no_qrcode', autofill=True, default=False) option: Flag('raw', autofill=True, cli_name='raw', default=False, exclude='webui') option: Str('setattr*', cli_name='setattr', exclude='webui') option: StrEnum('type', attribute=False, autofill=True, cli_name='type', default=u'totp', multivalue=False, required=False, values=(u'totp', u'hotp', u'TOTP', u'HOTP')) diff --git a/VERSION b/VERSION index b0d41e5e1ec59ddefbdcccf588b97bac2ff798ee..bae782a4ec4333f8fdb610465a7b9ea3877c990e 100644 --- a/VERSION +++ b/VERSION @@ -90,5 +90,5 @@ IPA_DATA_VERSION=20100614120000 # # ######################################################## IPA_API_VERSION_MAJOR=2 -IPA_API_VERSION_MINOR=108 -# Last change: pvoborni - manage authorization of keytab operations +IPA_API_VERSION_MINOR=109 +# Last change: npmccallum - display qrcode by default diff --git a/ipalib/plugins/otptoken.py b/ipalib/plugins/otptoken.py index 2b5f1c5fb83341d392e165a3507f5076820f1d3a..dc687e37b398fb413cd565ac9793a013beda8504 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('no_qrcode', label=_('Do not display QR code'), default=False), ) 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 not options.get('no_qrcode', False): 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..7095887ac7cdf5d4b7d0d30edc6cab0222246664 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, + no_qrcode=True, **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..b78aba93a2edc987450d921c87ea4f61b014b419 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, no_qrcode=True, **keypkg.options) except Exception as e: self.log.warn("Error adding token: %s", e) else: -- 2.1.0
_______________________________________________ Freeipa-devel mailing list [email protected] https://www.redhat.com/mailman/listinfo/freeipa-devel
