From 118c15bd84c2bccc8419a914b6bf3d84890e4fdb Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Thu, 25 Apr 2024 08:01:15 +0300 Subject: Make `CLIENTS_SSL_PUBLIC_KEYS_DIR` explicitly a config setting. --- gn_auth/__init__.py | 6 ++---- gn_auth/settings.py | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/gn_auth/__init__.py b/gn_auth/__init__.py index 895f593..b3df070 100644 --- a/gn_auth/__init__.py +++ b/gn_auth/__init__.py @@ -24,7 +24,7 @@ def check_mandatory_settings(app: Flask) -> None: undefined = tuple( setting for setting in ( "SECRET_KEY", "SQL_URI", "AUTH_DB", "AUTH_MIGRATIONS", - "OAUTH2_SCOPE", "SSL_PRIVATE_KEY", "UPLOADS_DIR") + "OAUTH2_SCOPE", "SSL_PRIVATE_KEY", "CLIENTS_SSL_PUBLIC_KEYS_DIR") if not ((setting in app.config) and bool(app.config[setting]))) if len(undefined) > 0: raise ConfigurationError( @@ -57,10 +57,8 @@ def parse_ssl_keys(app): with open(keypath) as _sslkey:# pylint: disable=[unspecified-encoding] return JsonWebKey.import_key(_sslkey.read()) - key_storage_dir = Path(app.config["UPLOADS_DIR"]).joinpath( - "clients-ssl-keys") + key_storage_dir = Path(app.config["CLIENTS_SSL_PUBLIC_KEYS_DIR"]) 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)) diff --git a/gn_auth/settings.py b/gn_auth/settings.py index f65b24b..771aecf 100644 --- a/gn_auth/settings.py +++ b/gn_auth/settings.py @@ -29,7 +29,6 @@ CORS_HEADERS = [ "Access-Control-Allow-Credentials" ] -UPLOADS_DIR = "" - # OpenSSL keys +CLIENTS_SSL_PUBLIC_KEYS_DIR = "" # clients' public keys' directory SSL_PRIVATE_KEY = "" # authorisation server primary key -- cgit v1.2.3