aboutsummaryrefslogtreecommitdiff
path: root/gn_auth
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-04-23 16:32:20 +0300
committerFrederick Muriuki Muriithi2024-04-23 16:32:20 +0300
commit010c2ac53edec91332cf22ef6d57a8ed0edae806 (patch)
treea78bdd3a1b4ea712a5c82bb35a3331ad386dcae2 /gn_auth
parent807e5322986bf9907cc7badfbbb5c4866353079c (diff)
downloadgn-auth-010c2ac53edec91332cf22ef6d57a8ed0edae806.tar.gz
Rename function and do minor bug-fixes.
Diffstat (limited to 'gn_auth')
-rw-r--r--gn_auth/__init__.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/gn_auth/__init__.py b/gn_auth/__init__.py
index 47e721b..0d0eb12 100644
--- a/gn_auth/__init__.py
+++ b/gn_auth/__init__.py
@@ -60,20 +60,23 @@ def load_secrets_conf(app: Flask) -> None:
app.config.from_pyfile(secretsfile)
-def parse_ssl_public_keys(app):
+def parse_ssl_keys(app):
+ """Parse the SSL keys."""
def __parse_key__(keypath: Path) -> JsonWebKey:
with open(keypath) as _sslkey:
return JsonWebKey.import_key(_sslkey.read())
key_storage_dir = Path(app.config["UPLOADS_DIR"]).joinpath(
"clients-ssl-keys")
+ key_storage_dir.mkdir(exist_ok=True)
app.config["CLIENTS_SSL_PUBLIC_KEYS_DIR"] = key_storage_dir
app.config["SSL_PUBLIC_KEYS"] = {
_key.as_dict()["kid"]: _key for _key in (
__parse_key__(Path(key_storage_dir).joinpath(key))
for key in os.listdir(key_storage_dir))}
- app.config["SSL_PRIVATE_KEY"] = __parse_key__(app.config["SSL_PRIVATE_KEY"])
+ app.config["SSL_PRIVATE_KEY"] = __parse_key__(
+ Path(app.config["SSL_PRIVATE_KEY"]))
def create_app(config: Optional[dict] = None) -> Flask:
"""Create and return a new flask application."""
@@ -90,7 +93,7 @@ def create_app(config: Optional[dict] = None) -> Flask:
override_settings_with_envvars(app)
load_secrets_conf(app)
- parse_ssl_public_keys(app)
+ parse_ssl_keys(app)
# ====== END: Setup configuration ======
check_mandatory_settings(app)