summaryrefslogtreecommitdiff
path: root/scripts/db_access
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2015-07-22 15:44:01 -0300
committerKali Kaneko <kali@leap.se>2015-07-23 14:03:01 -0400
commit70f80e6ff893901dcd94b7964570a896cb753a69 (patch)
treed5e5d7b6ba6270904ac5e0554dbfb8cf736d8c91 /scripts/db_access
parent0e3304de39aa4a0c0859eab9847cb85990cdec28 (diff)
[feat] add auth data storage on client db script
Diffstat (limited to 'scripts/db_access')
-rw-r--r--scripts/db_access/client_side_db.py32
1 files changed, 30 insertions, 2 deletions
diff --git a/scripts/db_access/client_side_db.py b/scripts/db_access/client_side_db.py
index 1d8d32e2..3995d91d 100644
--- a/scripts/db_access/client_side_db.py
+++ b/scripts/db_access/client_side_db.py
@@ -163,6 +163,12 @@ def _parse_args():
parser.add_argument(
'--export-incoming-messages',
help="export incoming messages to a directory")
+ parser.add_argument(
+ '--export-auth-data',
+ help="export authentication data to a file")
+ parser.add_argument(
+ '--use-auth-data',
+ help="use authentication data from a file")
return parser.parse_args()
@@ -237,8 +243,30 @@ if __name__ == '__main__':
args = _parse_args()
passphrase = _get_passphrase(args)
basedir = _get_basedir(args)
- uuid, server_url, cert_file, token = \
- _get_soledad_info(args.username, args.provider, passphrase, basedir)
+
+ if not args.use_auth_data:
+ # get auth data from server
+ uuid, server_url, cert_file, token = \
+ _get_soledad_info(args.username, args.provider, passphrase, basedir)
+ else:
+ # load auth data from file
+ with open(args.use_auth_data) as f:
+ auth_data = json.loads(f.read())
+ uuid = auth_data['uuid']
+ server_url = auth_data['server_url']
+ cert_file = auth_data['cert_file']
+ token = auth_data['token']
+
+ # export auth data to a file
+ if args.export_auth_data:
+ with open(args.export_auth_data, "w") as f:
+ f.write(json.dumps({
+ 'uuid': uuid,
+ 'server_url': server_url,
+ 'cert_file': cert_file,
+ 'token': token,
+ }))
+
soledad = _get_soledad_instance(
uuid, passphrase, basedir, server_url, cert_file, token)
km = _get_keymanager_instance(