aboutsummaryrefslogtreecommitdiff
path: root/gn2
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-11-04 16:08:26 -0600
committerFrederick Muriuki Muriithi2024-11-04 16:09:12 -0600
commit578a8ebe14bcc116c8cf12736a06cd56595b80fb (patch)
treef32a546484961796e601e8b381f5bd4cefd7f078 /gn2
parentfb98c5389836c71f206c03f061b95ad0c0d1761c (diff)
downloadgenenetwork2-578a8ebe14bcc116c8cf12736a06cd56595b80fb.tar.gz
Add debug logging: Figure out how keys are loaded on production.
Diffstat (limited to 'gn2')
-rw-r--r--gn2/wqflask/oauth2/jwks.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/gn2/wqflask/oauth2/jwks.py b/gn2/wqflask/oauth2/jwks.py
index efd04997..08dfd8c4 100644
--- a/gn2/wqflask/oauth2/jwks.py
+++ b/gn2/wqflask/oauth2/jwks.py
@@ -8,6 +8,8 @@ from flask import Flask
from authlib.jose import JsonWebKey
from pymonad.either import Left, Right, Either
+from gn2.debug import __pk__
+
def jwks_directory(app: Flask, configname: str) -> Path:
"""Compute the directory where the JWKs are stored."""
appsecretsdir = Path(app.config[configname]).parent
@@ -44,10 +46,11 @@ def pem_to_jwk(filepath: Path) -> JsonWebKey:
def __sorted_jwks_paths__(storagedir: Path) -> tuple[tuple[float, Path], ...]:
"""A sorted list of the JWK file paths with their creation timestamps."""
- return tuple(sorted(((os.stat(keypath).st_ctime, keypath)
- for keypath in (Path(storagedir, keyfile)
- for keyfile in os.listdir(storagedir)
- if keyfile.endswith(".pem"))),
+ all_files = tuple(__pk__("STORAGE DIRECTORY ===========>", storagedir).iterdir())
+ return tuple(sorted(((os.stat(keypath).st_ctime, __pk__("FOUND KEY ==========>", keypath))
+ for keypath in (keyfile
+ for keyfile in __pk__("DIRECTORY CONTENT", all_files)
+ if __pk__("KEYFILE SUFFIX ========>", keyfile.suffix) == ".pem")),
key=lambda tpl: tpl[0]))