Skip to content

Commit

Permalink
Uses more explicit var names in v3 keygen
Browse files Browse the repository at this point in the history
The per-service vars weren't intuitively explained in the JSON file.
Updated the var names so that their use in the corresponding Ansible
logic is more readable, and less error-prone.

We should move the v3 keygen logic out of securedrop-admin and into
Ansible, since otherwise it will not work in developer environments, or
CI.
  • Loading branch information
Conor Schaefer committed Aug 8, 2019
1 parent 07fed0c commit fea52e0
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions admin/securedrop_admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,18 +591,21 @@ def find_or_generate_new_torv3_keys(args):
if os.path.exists(secret_key_path):
return get_v3_keys(secret_key_path)
# No old keys, generate and store them first
public_key, private_key = generate_new_v3_keys()
app_journalist_public_key, app_journalist_private_key = generate_new_v3_keys()
# For app ssh service
app_ssh_key, app_ssh_private_key = generate_new_v3_keys()
app_ssh_public_key, app_ssh_private_key = generate_new_v3_keys()
# For mon ssh service
mon_ssh_key, mon_ssh_private_key = generate_new_v3_keys()
data = {"public_key": public_key, "private_key": private_key,
"app_ssh_key": app_ssh_key,
mon_ssh__public_key, mon_ssh_private_key = generate_new_v3_keys()
tor_v3_service_info = dict(
"app_journalist_public_key": app_journalist_public_key,
"app_journalist_private_key": app_journalist_private_key,
"app_ssh_public_key": app_ssh_public_key,
"app_ssh_private_key": app_ssh_private_key,
"mon_ssh_key": mon_ssh_key,
"mon_ssh_private_key": mon_ssh_private_key}
"mon_ssh_public_key": mon_public_ssh_key,
"mon_ssh_private_key": mon_ssh_private_key,
)
with open(secret_key_path, 'w') as fobj:
json.dump(data, fobj)
json.dump(tor_v3_service_info, fobj, indent=4)


def install_securedrop(args):
Expand Down

0 comments on commit fea52e0

Please sign in to comment.