List yubikeys
This commit is contained in:
parent
2e9e58d8f4
commit
136ce6e4b0
4 changed files with 24 additions and 0 deletions
0
yubi_lock/api/__init__.py
Normal file
0
yubi_lock/api/__init__.py
Normal file
14
yubi_lock/api/yubikey.py
Normal file
14
yubi_lock/api/yubikey.py
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
import yubico
|
||||||
|
|
||||||
|
|
||||||
|
def get_all_yubikeys(debug):
|
||||||
|
keys = []
|
||||||
|
try:
|
||||||
|
skip = 0
|
||||||
|
while skip < 255:
|
||||||
|
key = yubico.find_yubikey(debug=debug, skip=skip)
|
||||||
|
keys.append(key)
|
||||||
|
skip += 1
|
||||||
|
except yubico.yubikey.YubiKeyError:
|
||||||
|
pass
|
||||||
|
return keys
|
0
yubi_lock/status/__init__.py
Normal file
0
yubi_lock/status/__init__.py
Normal file
10
yubi_lock/status/cli.py
Normal file
10
yubi_lock/status/cli.py
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
import click
|
||||||
|
from yubi_lock.api.yubikey import get_all_yubikeys
|
||||||
|
|
||||||
|
|
||||||
|
@click.command('status', short_help='List connected devices.')
|
||||||
|
def cli():
|
||||||
|
print('Scanning for keys...')
|
||||||
|
keys = get_all_yubikeys(False)
|
||||||
|
for key in keys:
|
||||||
|
print("Found {}!".format(key.description))
|
Reference in a new issue