From 20ee2b7bbcfcb1a7bf95a6a90c7681d2a0962b07 Mon Sep 17 00:00:00 2001 From: Donald Date: Tue, 11 Jun 2024 11:54:16 -0700 Subject: [PATCH 1/2] Adjusted the key_setup() function to setup the directory and file as is inline with the quick start setup --- easyauth/server.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/easyauth/server.py b/easyauth/server.py index d9cc63f..e055058 100755 --- a/easyauth/server.py +++ b/easyauth/server.py @@ -274,11 +274,18 @@ def key_setup(self): # check if keys exist in KEY_PATH else create assert "KEY_NAME" in os.environ, f"missing KEY_NAME env variable" key_path = os.getenv("KEY_PATH", "") + + if not os.path.exists(key_path + ".key"): + os.makedirs(key_path) + if key_path: - key_path = f"{key_path}/{os.environ['KEY_NAME']}.key" + key_path = f"{key_path}/{os.environ['KEY_NAME']}" else: key_path = f"{os.environ['KEY_NAME']}" + if not os.path.exists(key_path): + with open(key_path, "w") as file: + file.write("") try: with open(key_path + ".key", "r") as k: self._privkey = jwk.JWK.from_json(k.readline()) @@ -429,9 +436,9 @@ async def send_email( message = MessageSchema( subject=f"{subject}", - recipients=recipients - if isinstance(recipients, list) - else [recipients], # List of recipients, as many as you can pass + recipients=( + recipients if isinstance(recipients, list) else [recipients] + ), # List of recipients, as many as you can pass body=body, subtype="html", ) From f0c519669daf9597b91ea3cc8d01e52e897571b5 Mon Sep 17 00:00:00 2001 From: Donald Isbell Date: Tue, 11 Jun 2024 12:11:06 -0700 Subject: [PATCH 2/2] Update server.py Fixed an oversite where I was preappending key to the directory path --- easyauth/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easyauth/server.py b/easyauth/server.py index e055058..4ca54f3 100755 --- a/easyauth/server.py +++ b/easyauth/server.py @@ -275,7 +275,7 @@ def key_setup(self): assert "KEY_NAME" in os.environ, f"missing KEY_NAME env variable" key_path = os.getenv("KEY_PATH", "") - if not os.path.exists(key_path + ".key"): + if not os.path.exists(key_path): os.makedirs(key_path) if key_path: