add path argument for secret

master
Felix Pankratz 8 months ago
parent bded598a6e
commit f0e613919a

@ -30,15 +30,18 @@ def generate_seed(secret):
def main(): def main():
import argparse import argparse
parser = argparse.ArgumentParser(prog='Remote Admin Password Solution', description='Generate rotating passwords based on a shared secret') parser = argparse.ArgumentParser(prog='Remote Admin Password Solution', description='Generate rotating passwords based on a shared secret')
parser.add_argument('--secret', action='store', help='path to secret file')
parser.add_argument('--new-secret', action='store_true', help='generate a new secret') parser.add_argument('--new-secret', action='store_true', help='generate a new secret')
args = parser.parse_args() args = parser.parse_args()
secret_path = args.secret if args.secret else SECRET_FILE
secret = '' secret = ''
if not os.path.isfile(SECRET_FILE) or args.new_secret: if not os.path.isfile(secret_path) or args.new_secret:
print('Generating a new secret... ', end='') print('Generating a new secret... ', end='')
secret = create_secret() secret = create_secret()
with open(SECRET_FILE, 'w') as f: with open(secret_path, 'w') as f:
f.write(secret) f.write(secret)
print('done. Send this to the other party:') print('done. Send this to the other party:')
print(secret) print(secret)
@ -48,7 +51,7 @@ def main():
print('Secret loaded.') print('Secret loaded.')
random.seed(generate_seed(secret)) random.seed(generate_seed(secret))
print('The password of the month is:') print('The password of the month is:')
print(generate_password()) print(generate_password())

Loading…
Cancel
Save