From 99f5f740e947fd2c5e746c6b40d0cb7dccce051b Mon Sep 17 00:00:00 2001 From: "Alexander \"PapaTutuWawa" Date: Wed, 24 Nov 2021 14:19:35 +0100 Subject: [PATCH] base: Allow loading the password from a secret file --- mira/base.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mira/base.py b/mira/base.py index 477d939..80b8774 100644 --- a/mira/base.py +++ b/mira/base.py @@ -41,10 +41,18 @@ class MiraBot: self._config = toml.load(config_path) self._jid = aioxmpp.JID.fromstr(self._config["jid"]) - self._password = self._config["password"] self._avatar = self._config.get("avatar", None) self._client = None + # Also supports situations where the secret cannot be in the config file + if "password" in self._config: + self._password = self._config["password"] + else if "password_file" in self._config: + with open(self._config["password_file"], "r") as f: + self._password = f.read() + else: + raise Exception("Neither password nor password_file specified") + self._modules = {} # Module name -> module self._storage_manager = StorageManager.get_instance( self._config.get("storage_path", "/etc/mira/storage.json")