main
py 19 lines 639 Bytes
Raw
1 from helpers import runtime, crypto, dotenv
2
3 async def get_root_password():
4 if runtime.is_dockerized():
5 pswd = _get_root_password()
6 else:
7 priv = crypto._generate_private_key()
8 pub = crypto._generate_public_key(priv)
9 enc = await runtime.call_development_function(_provide_root_password, pub)
10 pswd = crypto.decrypt_data(enc, priv)
11 return pswd
12
13 def _provide_root_password(public_key_pem: str):
14 pswd = _get_root_password()
15 enc = crypto.encrypt_data(pswd, public_key_pem)
16 return enc
17
18 def _get_root_password():
19 return dotenv.get_dotenv_value(dotenv.KEY_ROOT_PASSWORD) or ""