This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
yubi-lock/yubi_lock/register/cli.py

23 lines
684 B
Python
Raw Normal View History

2016-05-19 21:32:01 +01:00
import click
from yubi_lock.api.yubikey import get_all_yubikeys, generate_ident
from yubi_lock.api.user import store_key
@click.command('register', short_help='Add a device')
def cli():
print("Scanning for keys...")
keys = get_all_yubikeys(False)
if not keys:
print("No YubiKeys detected!")
return 1
elif len(keys) > 1:
print("Please only insert the YubiKey you wish to register. Found {}.".format(len(keys)))
return 1
key = keys[0]
print("Found {} with Serial {}.".format(key.description, key.serial()))
ident = generate_ident(key)
store_key(ident)
print("YubiKey has been stored, you can now use it to login")