Added support for keyfiles
This commit is contained in:
parent
c680a78937
commit
fc147deb89
@ -115,11 +115,8 @@ def credentials_ini_fmt(k, v):
|
|||||||
|
|
||||||
def credentials_ini(label, setting):
|
def credentials_ini(label, setting):
|
||||||
r = "[{}]\n".format(label)
|
r = "[{}]\n".format(label)
|
||||||
dictitems = getattr(type(setting), "items", None)
|
for k, v in setting.items():
|
||||||
if dictitems and callable(dictitems):
|
r.append("{}={}\n".format(k, v))
|
||||||
r += "\n".join([credentials_ini_fmt(k, v) for k, v in setting.items()])
|
|
||||||
else:
|
|
||||||
r += credentials_ini_fmt(label, str(setting))
|
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
|
||||||
@ -133,6 +130,7 @@ def main():
|
|||||||
epilog="",
|
epilog="",
|
||||||
add_help=True)
|
add_help=True)
|
||||||
parser.add_argument("-c", "--config", help="Use time localization settings from a pyhton config file (omit the .py extension)", default=None)
|
parser.add_argument("-c", "--config", help="Use time localization settings from a pyhton config file (omit the .py extension)", default=None)
|
||||||
|
parser.add_argument("-k", "--keyfile", help="Keyfile used for decryption", default=None)
|
||||||
parser.add_argument("--plain", help="Output credentials in plain ini format", action="store_true")
|
parser.add_argument("--plain", help="Output credentials in plain ini format", action="store_true")
|
||||||
parser.add_argument("--minimal", help="Only print OAuth credentials, ignoring encryption settings", action="store_true")
|
parser.add_argument("--minimal", help="Only print OAuth credentials, ignoring encryption settings", action="store_true")
|
||||||
arguments = parser.parse_args()
|
arguments = parser.parse_args()
|
||||||
@ -182,11 +180,15 @@ def main():
|
|||||||
ans = _input("Do you want to encrypt your credentials? (y/n)", default("encrypt"))
|
ans = _input("Do you want to encrypt your credentials? (y/n)", default("encrypt"))
|
||||||
if ans.upper() in ("Y", "YES"):
|
if ans.upper() in ("Y", "YES"):
|
||||||
encrypt = True
|
encrypt = True
|
||||||
salt, settings_server = encryption.settings_server_encrypt_cfg(settings_server)
|
salt, settings_server = encryption.settings_server_encrypt(settings_server, arguments.keyfile)
|
||||||
|
|
||||||
settings_encrypt = OrderedDict([
|
settings_encrypt = OrderedDict([
|
||||||
("encrypt", encrypt),
|
("encrypt", encrypt),
|
||||||
("salt", salt),
|
("salt", salt),
|
||||||
|
("keyfile", arguments.keyfile)
|
||||||
|
])
|
||||||
|
settings_reminder = OrderedDict([
|
||||||
|
("settings_reminder", reminder)
|
||||||
])
|
])
|
||||||
|
|
||||||
# Credential formatting functions
|
# Credential formatting functions
|
||||||
@ -196,7 +198,7 @@ def main():
|
|||||||
print("Copy to your config file!!!")
|
print("Copy to your config file!!!")
|
||||||
print(formatted_credentials("settings_server", settings_server))
|
print(formatted_credentials("settings_server", settings_server))
|
||||||
if not arguments.minimal:
|
if not arguments.minimal:
|
||||||
print("\n{}\n".format(formatted_credentials("settings_reminder", reminder)))
|
print("\n{}\n".format(formatted_credentials("settings_reminder", settings_reminder)))
|
||||||
print(formatted_credentials("settings_encrypt", settings_encrypt))
|
print(formatted_credentials("settings_encrypt", settings_encrypt))
|
||||||
|
|
||||||
print("Success :)")
|
print("Success :)")
|
||||||
|
Loading…
Reference in New Issue
Block a user