mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
otptoken_yubikey: fix otptoken_add_yubikey arguments
Copy args, options and output of otptoken_add_yubikey from otptoken_add. https://fedorahosted.org/freeipa/ticket/4739 Reviewed-By: David Kupka <dkupka@redhat.com>
This commit is contained in:
parent
be471699b6
commit
4a243536b3
11
API.txt
11
API.txt
@ -2973,17 +2973,24 @@ output: Output('completed', type=[<type 'int'>])
|
||||
output: Output('failed', type=[<type 'dict'>])
|
||||
output: Entry('result')
|
||||
command: otptoken_add_yubikey
|
||||
args: 1,8,1
|
||||
args: 1,13,3
|
||||
arg: Str('ipatokenuniqueid?', cli_name='id')
|
||||
option: Str('addattr*', cli_name='addattr')
|
||||
option: Flag('all', autofill=True, cli_name='all', default=False)
|
||||
option: Str('description?', cli_name='desc')
|
||||
option: Bool('ipatokendisabled?', cli_name='disabled')
|
||||
option: DateTime('ipatokennotafter?', cli_name='not_after')
|
||||
option: DateTime('ipatokennotbefore?', cli_name='not_before')
|
||||
option: IntEnum('ipatokenotpdigits?', autofill=True, cli_name='digits', default=6, values=[6, 8])
|
||||
option: Str('ipatokenowner?', cli_name='owner')
|
||||
option: Flag('no_members', autofill=True, default=False)
|
||||
option: Flag('raw', autofill=True, cli_name='raw', default=False)
|
||||
option: Str('setattr*', cli_name='setattr')
|
||||
option: IntEnum('slot?', cli_name='slot', values=[1, 2])
|
||||
option: Str('version?')
|
||||
output: Output('result')
|
||||
output: Entry('result')
|
||||
output: Output('summary', type=[<type 'unicode'>, <type 'NoneType'>])
|
||||
output: PrimaryKey('value')
|
||||
command: otptoken_del
|
||||
args: 1,2,3
|
||||
arg: Str('ipatokenuniqueid+', cli_name='id')
|
||||
|
4
VERSION
4
VERSION
@ -90,5 +90,5 @@ IPA_DATA_VERSION=20100614120000
|
||||
# #
|
||||
########################################################
|
||||
IPA_API_VERSION_MAJOR=2
|
||||
IPA_API_VERSION_MINOR=167
|
||||
# Last change: dns: do not rely on server data structures in code called on client
|
||||
IPA_API_VERSION_MINOR=168
|
||||
# Last change: otptoken_yubikey: fix otptoken_add_yubikey arguments
|
||||
|
@ -17,17 +17,16 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from ipalib import _, Str, IntEnum
|
||||
from ipalib.errors import NotFound
|
||||
from ipalib.plugable import Registry
|
||||
from ipalib.frontend import Command
|
||||
from ipalib.plugins.otptoken import otptoken
|
||||
|
||||
import os
|
||||
|
||||
import six
|
||||
import usb.core
|
||||
import yubico
|
||||
import six
|
||||
|
||||
from ipalib import _, IntEnum
|
||||
from ipalib.errors import NotFound
|
||||
from ipalib.frontend import Command
|
||||
from ipalib.plugable import Registry
|
||||
|
||||
if six.PY3:
|
||||
unicode = str
|
||||
@ -55,35 +54,40 @@ topic = ('otp', _('One time password commands'))
|
||||
class otptoken_add_yubikey(Command):
|
||||
__doc__ = _('Add a new YubiKey OTP token.')
|
||||
|
||||
takes_args = (
|
||||
Str('ipatokenuniqueid?',
|
||||
cli_name='id',
|
||||
label=_('Unique ID'),
|
||||
primary_key=True,
|
||||
),
|
||||
)
|
||||
|
||||
takes_options = Command.takes_options + (
|
||||
takes_options = (
|
||||
IntEnum('slot?',
|
||||
cli_name='slot',
|
||||
label=_('YubiKey slot'),
|
||||
values=(1, 2),
|
||||
),
|
||||
) + tuple(x for x in otptoken.takes_params if x.name in (
|
||||
'description',
|
||||
'ipatokenowner',
|
||||
'ipatokendisabled',
|
||||
'ipatokennotbefore',
|
||||
'ipatokennotafter',
|
||||
'ipatokenotpdigits'
|
||||
))
|
||||
)
|
||||
|
||||
has_output_params = Command.has_output_params + \
|
||||
tuple(x for x in otptoken.takes_params if x.name in (
|
||||
'ipatokenvendor',
|
||||
'ipatokenmodel',
|
||||
'ipatokenserial',
|
||||
))
|
||||
def get_args(self):
|
||||
for arg in self.api.Command.otptoken_add.args():
|
||||
yield arg
|
||||
for arg in super(otptoken_add_yubikey, self).get_args():
|
||||
yield arg
|
||||
|
||||
def get_options(self):
|
||||
for option in self.api.Command.otptoken_add.options():
|
||||
if option.name not in ('type',
|
||||
'ipatokenvendor',
|
||||
'ipatokenmodel',
|
||||
'ipatokenserial',
|
||||
'ipatokenotpalgorithm',
|
||||
'ipatokenhotpcounter',
|
||||
'ipatokenotpkey',
|
||||
'ipatokentotpclockoffset',
|
||||
'ipatokentotptimestep',
|
||||
'no_qrcode',
|
||||
'qrcode',
|
||||
'version'):
|
||||
yield option
|
||||
for option in super(otptoken_add_yubikey, self).get_options():
|
||||
yield option
|
||||
|
||||
def _iter_output(self):
|
||||
return self.api.Command.otptoken_add.output()
|
||||
|
||||
def forward(self, *args, **kwargs):
|
||||
# Open the YubiKey
|
||||
@ -145,6 +149,4 @@ class otptoken_add_yubikey(Command):
|
||||
# Return which slot was used for writing.
|
||||
answer.get('result', {})['slot'] = kwargs['slot']
|
||||
|
||||
del answer['value'] # Why does this cause an error if omitted?
|
||||
del answer['summary'] # Why does this cause an error if omitted?
|
||||
return answer
|
||||
|
Loading…
Reference in New Issue
Block a user