diff options
author | mia <mia@mia.jetzt> | 2024-06-30 18:25:15 -0700 |
---|---|---|
committer | mia <mia@mia.jetzt> | 2024-06-30 18:25:15 -0700 |
commit | 95537d1d4846a9fe3e777017950f86d1a3b41168 (patch) | |
tree | 933294ba3648652805e83ed771cd2b207e379875 | |
parent | 3951bfb7c042ada824a66b420703b7587de48e5c (diff) | |
download | commia-main.tar.gz commia-main.zip |
-rw-r--r-- | commia/bearer.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/commia/bearer.py b/commia/bearer.py index 6202126..0ee761c 100644 --- a/commia/bearer.py +++ b/commia/bearer.py @@ -1,17 +1,21 @@ import base64 +import os import pyrage from commia.prelude import * from commia.ssh import sftp_exists, sftp_rm, ssh_opt_args +from commia.util import with_written _target = "secrets@bearer" _opts = lambda: ssh_opt_args(_target) @overload +def get_key(key: "Key", decode: bool = True) -> str: ... +@overload def get_key(key: "Key", decode: bool = False) -> bytes: ... -def get_key(key: "Key", decode: bool = True) -> str: +def get_key(key: "Key", decode: bool = True): found = None for recipient in key.recipients: idn = _identity(recipient) @@ -56,6 +60,16 @@ def has_key(key: "Key") -> bool: return sftp_exists(f"data/{key.path}", target=_target) +def edit_key(key: "Key"): + data = get_key(key) + + def callback(path: str): + run([os.environ["EDITOR"], path]) + set_key(key, Path(path).read_text().strip()) + + with_written(data, callback) + + _identity_c = {} @@ -90,6 +104,8 @@ class Key: class keys: test = Key("test", "fw") + domains = Key("domains", "fw") + class certificates: certs = Key("certificates:certs", "fw") state = Key("certificates:state", "fw") |