uotp-client added

This commit is contained in:
ahmadbilalkhalid 2019-12-07 19:20:34 +05:00
parent 106b7df5db
commit 78326a52df
3 changed files with 13 additions and 11 deletions

View file

@ -1,11 +1,17 @@
#!/usr/bin/env python3
import requests import requests
import pyotp import pyotp
import argparse import argparse
from .config import env_vars from uotp.config import env_vars, etcd_client
from os.path import join as join_path
from etcd3_wrapper import Etcd3Wrapper
arg_parser = argparse.ArgumentParser() arg_parser = argparse.ArgumentParser()
arg_parser.add_argument("action", choices=["list", "create", "verify", "delete"]) arg_parser.add_argument("action",
choices=["list", "create", "verify", "delete",
"get-admin"])
arg_parser.add_argument("--name") arg_parser.add_argument("--name")
arg_parser.add_argument("--realm") arg_parser.add_argument("--realm")
arg_parser.add_argument("--seed") arg_parser.add_argument("--seed")
@ -80,3 +86,7 @@ elif action == "delete":
url = "http://localhost:{}/delete/".format(env_vars.get('PORT')) url = "http://localhost:{}/delete/".format(env_vars.get('PORT'))
r = requests.post(url, json=data) r = requests.post(url, json=data)
print(r.content.decode("utf-8")) print(r.content.decode("utf-8"))
elif action == "get-admin":
admin_uotp = etcd_client.get(join_path(env_vars.get('BASE_PREFIX'), 'admin'))
print(admin_uotp.value)

View file

@ -26,5 +26,5 @@ setup(name='uotp',
'pyotp', 'pyotp',
'click' 'click'
], ],
scripts=['bin/uotp'], scripts=['bin/uotp', 'bin/uotp-client'],
zip_safe=False) zip_safe=False)

View file

@ -1,8 +0,0 @@
import decouple
from os.path import join as join_path
from etcd3_wrapper import Etcd3Wrapper
client = Etcd3Wrapper()
admin_uotp = client.get(join_path(decouple.config('BASE_PREFIX'), 'admin'))
print(admin_uotp.value)