(self, params, **kwargs)
| 55 | return TfaListCommand.parser |
| 56 | |
| 57 | def execute(self, params, **kwargs): |
| 58 | rs = api.communicate_rest(params, None, 'authentication/2fa_list', rs_type=APIRequest_pb2.TwoFactorListResponse) |
| 59 | expire_at = '' |
| 60 | if rs.expireOn > 0: |
| 61 | if rs.expireOn > 3_000_000_000_000: |
| 62 | expire_at = 'Never' |
| 63 | else: |
| 64 | dt = datetime.datetime.fromtimestamp(rs.expireOn // 1000) |
| 65 | expire_at = dt.isoformat() |
| 66 | |
| 67 | if expire_at is not None: |
| 68 | logging.info('2FA authentication expires: %s\n', expire_at) |
| 69 | table = [] |
| 70 | for channel in rs.channels: |
| 71 | created_on = datetime.datetime.fromtimestamp(channel.createdOn // 1000) |
| 72 | row = [TwoFaCommand.two_factor_channel_to_desc(channel.channelType), |
| 73 | utils.base64_url_encode(channel.channel_uid), channel.channelName, created_on, channel.phoneNumber] |
| 74 | table.append(row) |
| 75 | |
| 76 | fmt = kwargs.get('format') |
| 77 | header = ['method', 'channel_uid', 'name', 'created', 'phone_number'] |
| 78 | if fmt != 'json': |
| 79 | header = [field_to_title(x) for x in header] |
| 80 | |
| 81 | return dump_report_data(table, header, fmt=fmt, filename=kwargs.get('output'), row_number=True) |
| 82 | |
| 83 | |
| 84 | class TfaAddCommand(Command): |
nothing calls this directly
no test coverage detected